From 4a796003f29d10181a6c9d6f91fdc9230af7a18a Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 21 Jul 2022 16:52:47 +0000 Subject: [PATCH] CodeGen from PR 19823 in Azure/azure-rest-api-specs Merge 5b1902de585f17781ee08b8c9a529b138cf37f74 into 9d67b48d784fb4a47ebe8819a437d5e4d388c9f2 --- sdk/monitor/azure-mgmt-monitor/_meta.json | 6 +- .../monitor/_monitor_management_client.py | 38 +- .../monitor/aio/_monitor_management_client.py | 38 +- .../azure/mgmt/monitor/models.py | 4 +- .../mgmt/monitor/v2015_04_01/__init__.py | 13 +- .../monitor/v2015_04_01/_configuration.py | 2 +- .../mgmt/monitor/v2015_04_01/_metadata.json | 4 +- .../v2015_04_01/_monitor_management_client.py | 33 +- .../mgmt/monitor/v2015_04_01/_version.py | 2 +- .../mgmt/monitor/v2015_04_01/aio/__init__.py | 13 +- .../monitor/v2015_04_01/aio/_configuration.py | 2 +- .../aio/_monitor_management_client.py | 31 +- .../v2015_04_01/aio/operations/__init__.py | 5 + .../operations/_activity_logs_operations.py | 70 +- .../aio/operations/_alert_rules_operations.py | 212 ++- .../_autoscale_settings_operations.py | 212 ++- .../_event_categories_operations.py | 67 +- .../v2015_04_01/aio/operations/_operations.py | 61 +- .../v2015_04_01/aio/operations/_patch.py | 19 + .../_tenant_activity_logs_operations.py | 72 +- .../monitor/v2015_04_01/models/__init__.py | 6 +- .../monitor/v2015_04_01/models/_models_py3.py | 163 +- .../_monitor_management_client_enums.py | 21 +- .../mgmt/monitor/v2015_04_01/models/_patch.py | 19 + .../v2015_04_01/operations/__init__.py | 5 + .../operations/_activity_logs_operations.py | 102 +- .../operations/_alert_rules_operations.py | 372 ++-- .../_autoscale_settings_operations.py | 372 ++-- .../_event_categories_operations.py | 93 +- .../v2015_04_01/operations/_operations.py | 88 +- .../monitor/v2015_04_01/operations/_patch.py | 19 + .../_tenant_activity_logs_operations.py | 102 +- .../mgmt/monitor/v2015_07_01/__init__.py | 13 +- .../monitor/v2015_07_01/_configuration.py | 2 +- .../mgmt/monitor/v2015_07_01/_metadata.json | 4 +- .../v2015_07_01/_monitor_management_client.py | 25 +- .../mgmt/monitor/v2015_07_01/_version.py | 2 +- .../mgmt/monitor/v2015_07_01/aio/__init__.py | 13 +- .../monitor/v2015_07_01/aio/_configuration.py | 2 +- .../aio/_monitor_management_client.py | 23 +- .../v2015_07_01/aio/operations/__init__.py | 5 + .../aio/operations/_alert_rules_operations.py | 212 ++- .../_metric_definitions_operations.py | 69 +- .../v2015_07_01/aio/operations/_operations.py | 61 +- .../v2015_07_01/aio/operations/_patch.py | 19 + ..._service_diagnostic_settings_operations.py | 91 +- .../monitor/v2015_07_01/models/__init__.py | 6 +- .../monitor/v2015_07_01/models/_models_py3.py | 104 +- .../_monitor_management_client_enums.py | 9 +- .../mgmt/monitor/v2015_07_01/models/_patch.py | 19 + .../v2015_07_01/operations/__init__.py | 5 + .../operations/_alert_rules_operations.py | 372 ++-- .../_metric_definitions_operations.py | 99 +- .../v2015_07_01/operations/_operations.py | 88 +- .../monitor/v2015_07_01/operations/_patch.py | 19 + ..._service_diagnostic_settings_operations.py | 150 +- .../mgmt/monitor/v2016_03_01/__init__.py | 13 +- .../monitor/v2016_03_01/_configuration.py | 9 +- .../mgmt/monitor/v2016_03_01/_metadata.json | 4 +- .../v2016_03_01/_monitor_management_client.py | 28 +- .../mgmt/monitor/v2016_03_01/_version.py | 2 +- .../mgmt/monitor/v2016_03_01/aio/__init__.py | 13 +- .../monitor/v2016_03_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 26 +- .../v2016_03_01/aio/operations/__init__.py | 5 + .../_alert_rule_incidents_operations.py | 87 +- .../aio/operations/_alert_rules_operations.py | 194 +- .../operations/_log_profiles_operations.py | 165 +- .../_metric_definitions_operations.py | 66 +- .../v2016_03_01/aio/operations/_patch.py | 19 + .../monitor/v2016_03_01/models/__init__.py | 6 +- .../monitor/v2016_03_01/models/_models_py3.py | 84 +- .../_monitor_management_client_enums.py | 9 +- .../mgmt/monitor/v2016_03_01/models/_patch.py | 19 + .../v2016_03_01/operations/__init__.py | 5 + .../_alert_rule_incidents_operations.py | 140 +- .../operations/_alert_rules_operations.py | 354 ++-- .../operations/_log_profiles_operations.py | 292 +-- .../_metric_definitions_operations.py | 96 +- .../monitor/v2016_03_01/operations/_patch.py | 19 + .../mgmt/monitor/v2016_09_01/__init__.py | 13 +- .../monitor/v2016_09_01/_configuration.py | 9 +- .../mgmt/monitor/v2016_09_01/_metadata.json | 4 +- .../v2016_09_01/_monitor_management_client.py | 20 +- .../mgmt/monitor/v2016_09_01/_version.py | 2 +- .../mgmt/monitor/v2016_09_01/aio/__init__.py | 13 +- .../monitor/v2016_09_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../v2016_09_01/aio/operations/__init__.py | 5 + .../aio/operations/_metrics_operations.py | 66 +- .../v2016_09_01/aio/operations/_patch.py | 19 + ..._service_diagnostic_settings_operations.py | 112 +- .../monitor/v2016_09_01/models/__init__.py | 6 +- .../monitor/v2016_09_01/models/_models_py3.py | 38 +- .../_monitor_management_client_enums.py | 3 +- .../mgmt/monitor/v2016_09_01/models/_patch.py | 19 + .../v2016_09_01/operations/__init__.py | 5 + .../operations/_metrics_operations.py | 96 +- .../monitor/v2016_09_01/operations/_patch.py | 19 + ..._service_diagnostic_settings_operations.py | 200 +- .../monitor/v2017_03_01_preview/__init__.py | 13 +- .../v2017_03_01_preview/_configuration.py | 9 +- .../v2017_03_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 16 +- .../monitor/v2017_03_01_preview/_version.py | 2 +- .../v2017_03_01_preview/aio/__init__.py | 13 +- .../v2017_03_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../aio/operations/__init__.py | 5 + .../_activity_log_alerts_operations.py | 194 +- .../aio/operations/_patch.py | 19 + .../v2017_03_01_preview/models/__init__.py | 6 +- .../v2017_03_01_preview/models/_models_py3.py | 16 +- .../v2017_03_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../_activity_log_alerts_operations.py | 354 ++-- .../v2017_03_01_preview/operations/_patch.py | 19 + .../mgmt/monitor/v2017_04_01/__init__.py | 13 +- .../monitor/v2017_04_01/_configuration.py | 9 +- .../mgmt/monitor/v2017_04_01/_metadata.json | 4 +- .../v2017_04_01/_monitor_management_client.py | 20 +- .../mgmt/monitor/v2017_04_01/_version.py | 2 +- .../mgmt/monitor/v2017_04_01/aio/__init__.py | 13 +- .../monitor/v2017_04_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../v2017_04_01/aio/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 221 ++- .../_activity_log_alerts_operations.py | 194 +- .../v2017_04_01/aio/operations/_patch.py | 19 + .../monitor/v2017_04_01/models/__init__.py | 6 +- .../monitor/v2017_04_01/models/_models_py3.py | 36 +- .../_monitor_management_client_enums.py | 3 +- .../mgmt/monitor/v2017_04_01/models/_patch.py | 19 + .../v2017_04_01/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 410 ++-- .../_activity_log_alerts_operations.py | 354 ++-- .../monitor/v2017_04_01/operations/_patch.py | 19 + .../monitor/v2017_05_01_preview/__init__.py | 13 +- .../v2017_05_01_preview/_configuration.py | 9 +- .../v2017_05_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 32 +- .../monitor/v2017_05_01_preview/_version.py | 2 +- .../v2017_05_01_preview/aio/__init__.py | 13 +- .../v2017_05_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 30 +- .../aio/operations/__init__.py | 5 + ...diagnostic_settings_category_operations.py | 82 +- .../_diagnostic_settings_operations.py | 133 +- .../_metric_definitions_operations.py | 64 +- .../aio/operations/_metrics_operations.py | 75 +- .../aio/operations/_patch.py | 19 + ...cription_diagnostic_settings_operations.py | 133 +- .../v2017_05_01_preview/models/__init__.py | 6 +- .../v2017_05_01_preview/models/_models_py3.py | 76 +- .../_monitor_management_client_enums.py | 9 +- .../v2017_05_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + ...diagnostic_settings_category_operations.py | 135 +- .../_diagnostic_settings_operations.py | 240 ++- .../_metric_definitions_operations.py | 92 +- .../operations/_metrics_operations.py | 120 +- .../v2017_05_01_preview/operations/_patch.py | 19 + ...cription_diagnostic_settings_operations.py | 240 ++- .../monitor/v2017_11_01_preview/_patch.py | 31 - .../monitor/v2017_11_01_preview/aio/_patch.py | 31 - .../operations/_metric_baseline_operations.py | 182 -- .../v2017_11_01_preview/models/__init__.py | 33 - .../v2017_11_01_preview/models/_models_py3.py | 355 ---- .../operations/_metric_baseline_operations.py | 274 --- .../monitor/v2017_12_01_preview/__init__.py | 13 +- .../v2017_12_01_preview/_configuration.py | 9 +- .../v2017_12_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 16 +- .../monitor/v2017_12_01_preview/_version.py | 2 +- .../v2017_12_01_preview/aio/__init__.py | 13 +- .../v2017_12_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../aio/operations/__init__.py | 5 + .../_metric_namespaces_operations.py | 66 +- .../aio/operations/_patch.py | 19 + .../v2017_12_01_preview/models/__init__.py | 6 +- .../v2017_12_01_preview/models/_models_py3.py | 17 +- .../_monitor_management_client_enums.py | 3 +- .../v2017_12_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../_metric_namespaces_operations.py | 96 +- .../v2017_12_01_preview/operations/_patch.py | 19 + .../mgmt/monitor/v2018_01_01/__init__.py | 13 +- .../monitor/v2018_01_01/_configuration.py | 9 +- .../mgmt/monitor/v2018_01_01/_metadata.json | 4 +- .../v2018_01_01/_monitor_management_client.py | 20 +- .../mgmt/monitor/v2018_01_01/_version.py | 2 +- .../mgmt/monitor/v2018_01_01/aio/__init__.py | 13 +- .../monitor/v2018_01_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../v2018_01_01/aio/operations/__init__.py | 5 + .../_metric_definitions_operations.py | 67 +- .../aio/operations/_metrics_operations.py | 78 +- .../v2018_01_01/aio/operations/_patch.py | 19 + .../monitor/v2018_01_01/models/__init__.py | 6 +- .../monitor/v2018_01_01/models/_models_py3.py | 62 +- .../_monitor_management_client_enums.py | 9 +- .../mgmt/monitor/v2018_01_01/models/_patch.py | 19 + .../v2018_01_01/operations/__init__.py | 5 + .../_metric_definitions_operations.py | 97 +- .../operations/_metrics_operations.py | 125 +- .../monitor/v2018_01_01/operations/_patch.py | 19 + .../mgmt/monitor/v2018_03_01/__init__.py | 13 +- .../monitor/v2018_03_01/_configuration.py | 9 +- .../mgmt/monitor/v2018_03_01/_metadata.json | 4 +- .../v2018_03_01/_monitor_management_client.py | 24 +- .../mgmt/monitor/v2018_03_01/_version.py | 2 +- .../mgmt/monitor/v2018_03_01/aio/__init__.py | 13 +- .../monitor/v2018_03_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 22 +- .../v2018_03_01/aio/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 221 ++- .../operations/_metric_alerts_operations.py | 194 +- .../_metric_alerts_status_operations.py | 82 +- .../v2018_03_01/aio/operations/_patch.py | 19 + .../monitor/v2018_03_01/models/__init__.py | 6 +- .../monitor/v2018_03_01/models/_models_py3.py | 122 +- .../_monitor_management_client_enums.py | 15 +- .../mgmt/monitor/v2018_03_01/models/_patch.py | 19 + .../v2018_03_01/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 410 ++-- .../operations/_metric_alerts_operations.py | 354 ++-- .../_metric_alerts_status_operations.py | 135 +- .../monitor/v2018_03_01/operations/_patch.py | 19 + .../mgmt/monitor/v2018_04_16/__init__.py | 13 +- .../monitor/v2018_04_16/_configuration.py | 9 +- .../mgmt/monitor/v2018_04_16/_metadata.json | 4 +- .../v2018_04_16/_monitor_management_client.py | 16 +- .../mgmt/monitor/v2018_04_16/_version.py | 2 +- .../mgmt/monitor/v2018_04_16/aio/__init__.py | 13 +- .../monitor/v2018_04_16/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../v2018_04_16/aio/operations/__init__.py | 5 + .../v2018_04_16/aio/operations/_patch.py | 19 + .../_scheduled_query_rules_operations.py | 198 +- .../monitor/v2018_04_16/models/__init__.py | 6 +- .../monitor/v2018_04_16/models/_models_py3.py | 90 +- .../_monitor_management_client_enums.py | 15 +- .../mgmt/monitor/v2018_04_16/models/_patch.py | 19 + .../v2018_04_16/operations/__init__.py | 5 + .../monitor/v2018_04_16/operations/_patch.py | 19 + .../_scheduled_query_rules_operations.py | 362 ++-- .../monitor/v2018_06_01_preview/__init__.py | 13 +- .../v2018_06_01_preview/_configuration.py | 9 +- .../v2018_06_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 20 +- .../monitor/v2018_06_01_preview/_version.py | 2 +- .../v2018_06_01_preview/aio/__init__.py | 13 +- .../v2018_06_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../aio/operations/__init__.py | 5 + ...nostics_settings_association_operations.py | 194 +- .../_guest_diagnostics_settings_operations.py | 194 +- .../aio/operations/_patch.py | 19 + .../v2018_06_01_preview/models/__init__.py | 6 +- .../v2018_06_01_preview/models/_models_py3.py | 58 +- .../_monitor_management_client_enums.py | 7 +- .../v2018_06_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + ...nostics_settings_association_operations.py | 354 ++-- .../_guest_diagnostics_settings_operations.py | 354 ++-- .../v2018_06_01_preview/operations/_patch.py | 19 + .../mgmt/monitor/v2018_09_01/__init__.py | 13 +- .../monitor/v2018_09_01/_configuration.py | 9 +- .../mgmt/monitor/v2018_09_01/_metadata.json | 8 +- .../v2018_09_01/_monitor_management_client.py | 25 +- .../mgmt/monitor/v2018_09_01/_version.py | 2 +- .../mgmt/monitor/v2018_09_01/aio/__init__.py | 13 +- .../monitor/v2018_09_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 23 +- .../v2018_09_01/aio/operations/__init__.py | 9 +- .../operations/_action_groups_operations.py | 221 ++- .../aio/operations/_baseline_operations.py | 133 -- .../operations/_metric_baseline_operations.py | 191 -- .../v2018_09_01/aio/operations/_patch.py | 19 + .../monitor/v2018_09_01/models/__init__.py | 28 +- .../monitor/v2018_09_01/models/_models_py3.py | 450 +---- .../_monitor_management_client_enums.py | 36 +- .../mgmt/monitor/v2018_09_01/models/_patch.py | 19 + .../v2018_09_01/operations/__init__.py | 9 +- .../operations/_action_groups_operations.py | 410 ++-- .../operations/_baseline_operations.py | 191 -- .../operations/_metric_baseline_operations.py | 289 --- .../monitor/v2018_09_01/operations/_patch.py | 19 + .../monitor/v2018_11_27_preview/__init__.py | 13 +- .../v2018_11_27_preview/_configuration.py | 9 +- .../v2018_11_27_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 16 +- .../monitor/v2018_11_27_preview/_version.py | 2 +- .../v2018_11_27_preview/aio/__init__.py | 13 +- .../v2018_11_27_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../aio/operations/__init__.py | 5 + .../aio/operations/_patch.py | 19 + .../aio/operations/_vm_insights_operations.py | 58 +- .../v2018_11_27_preview/models/__init__.py | 6 +- .../v2018_11_27_preview/models/_models_py3.py | 24 +- .../_monitor_management_client_enums.py | 5 +- .../v2018_11_27_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../v2018_11_27_preview/operations/_patch.py | 19 + .../operations/_vm_insights_operations.py | 87 +- .../mgmt/monitor/v2019_03_01/__init__.py | 13 +- .../monitor/v2019_03_01/_configuration.py | 9 +- .../mgmt/monitor/v2019_03_01/_metadata.json | 4 +- .../v2019_03_01/_monitor_management_client.py | 20 +- .../mgmt/monitor/v2019_03_01/_version.py | 2 +- .../mgmt/monitor/v2019_03_01/aio/__init__.py | 13 +- .../monitor/v2019_03_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../v2019_03_01/aio/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 221 ++- .../aio/operations/_baselines_operations.py | 83 +- .../v2019_03_01/aio/operations/_patch.py | 19 + .../monitor/v2019_03_01/models/__init__.py | 6 +- .../monitor/v2019_03_01/models/_models_py3.py | 70 +- .../_monitor_management_client_enums.py | 7 +- .../mgmt/monitor/v2019_03_01/models/_patch.py | 19 + .../v2019_03_01/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 410 ++-- .../operations/_baselines_operations.py | 127 +- .../monitor/v2019_03_01/operations/_patch.py | 19 + .../mgmt/monitor/v2019_06_01/__init__.py | 13 +- .../monitor/v2019_06_01/_configuration.py | 9 +- .../mgmt/monitor/v2019_06_01/_metadata.json | 4 +- .../v2019_06_01/_monitor_management_client.py | 16 +- .../mgmt/monitor/v2019_06_01/_version.py | 2 +- .../mgmt/monitor/v2019_06_01/aio/__init__.py | 13 +- .../monitor/v2019_06_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../v2019_06_01/aio/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 221 ++- .../v2019_06_01/aio/operations/_patch.py | 19 + .../monitor/v2019_06_01/models/__init__.py | 6 +- .../monitor/v2019_06_01/models/_models_py3.py | 52 +- .../_monitor_management_client_enums.py | 3 +- .../mgmt/monitor/v2019_06_01/models/_patch.py | 19 + .../v2019_06_01/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 410 ++-- .../monitor/v2019_06_01/operations/_patch.py | 19 + .../mgmt/monitor/v2019_10_17/__init__.py | 13 +- .../monitor/v2019_10_17/_configuration.py | 9 +- .../mgmt/monitor/v2019_10_17/_metadata.json | 4 +- .../v2019_10_17/_monitor_management_client.py | 32 +- .../mgmt/monitor/v2019_10_17/_version.py | 2 +- .../mgmt/monitor/v2019_10_17/aio/__init__.py | 13 +- .../monitor/v2019_10_17/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 30 +- .../v2019_10_17/aio/operations/__init__.py | 5 + .../v2019_10_17/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 201 +- .../_private_link_resources_operations.py | 87 +- ..._link_scope_operation_status_operations.py | 58 +- ...rivate_link_scoped_resources_operations.py | 201 +- .../_private_link_scopes_operations.py | 222 ++- .../monitor/v2019_10_17/models/__init__.py | 6 +- .../monitor/v2019_10_17/models/_models_py3.py | 14 +- .../mgmt/monitor/v2019_10_17/models/_patch.py | 19 + .../v2019_10_17/operations/__init__.py | 5 + .../monitor/v2019_10_17/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 299 +-- .../_private_link_resources_operations.py | 140 +- ..._link_scope_operation_status_operations.py | 87 +- ...rivate_link_scoped_resources_operations.py | 299 +-- .../_private_link_scopes_operations.py | 373 ++-- .../monitor/v2019_11_01_preview/__init__.py | 13 +- .../v2019_11_01_preview/_configuration.py | 9 +- .../v2019_11_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 20 +- .../monitor/v2019_11_01_preview/_version.py | 2 +- .../v2019_11_01_preview/aio/__init__.py | 13 +- .../v2019_11_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 18 +- .../aio/operations/__init__.py | 5 + ...collection_rule_associations_operations.py | 169 +- .../_data_collection_rules_operations.py | 198 +- .../aio/operations/_patch.py | 19 + .../v2019_11_01_preview/models/__init__.py | 6 +- .../v2019_11_01_preview/models/_models_py3.py | 86 +- .../_monitor_management_client_enums.py | 21 +- .../v2019_11_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + ...collection_rule_associations_operations.py | 300 +-- .../_data_collection_rules_operations.py | 358 ++-- .../v2019_11_01_preview/operations/_patch.py | 19 + .../monitor/v2020_01_01_preview/__init__.py | 13 +- .../v2020_01_01_preview/_configuration.py | 9 +- .../v2020_01_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 16 +- .../monitor/v2020_01_01_preview/_version.py | 2 +- .../v2020_01_01_preview/aio/__init__.py | 13 +- .../v2020_01_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../aio/operations/__init__.py | 5 + ...nt_group_diagnostic_settings_operations.py | 138 +- .../aio/operations/_patch.py | 19 + .../v2020_01_01_preview/models/__init__.py | 6 +- .../v2020_01_01_preview/models/_models_py3.py | 10 +- .../v2020_01_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + ...nt_group_diagnostic_settings_operations.py | 245 ++- .../v2020_01_01_preview/operations/_patch.py | 19 + .../monitor/v2020_05_01_preview/__init__.py | 13 +- .../v2020_05_01_preview/_configuration.py | 9 +- .../v2020_05_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 16 +- .../monitor/v2020_05_01_preview/_version.py | 2 +- .../v2020_05_01_preview/aio/__init__.py | 13 +- .../v2020_05_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../aio/operations/__init__.py | 5 + .../aio/operations/_patch.py | 19 + .../_scheduled_query_rules_operations.py | 194 +- .../v2020_05_01_preview/models/__init__.py | 6 +- .../v2020_05_01_preview/models/_models_py3.py | 62 +- .../_monitor_management_client_enums.py | 9 +- .../v2020_05_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../v2020_05_01_preview/operations/_patch.py | 19 + .../_scheduled_query_rules_operations.py | 354 ++-- .../mgmt/monitor/v2020_10_01/__init__.py | 13 +- .../monitor/v2020_10_01/_configuration.py | 9 +- .../mgmt/monitor/v2020_10_01/_metadata.json | 4 +- .../v2020_10_01/_monitor_management_client.py | 16 +- .../mgmt/monitor/v2020_10_01/_version.py | 2 +- .../mgmt/monitor/v2020_10_01/aio/__init__.py | 13 +- .../monitor/v2020_10_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../v2020_10_01/aio/operations/__init__.py | 5 + .../_activity_log_alerts_operations.py | 194 +- .../v2020_10_01/aio/operations/_patch.py | 19 + .../monitor/v2020_10_01/models/__init__.py | 6 +- .../monitor/v2020_10_01/models/_models_py3.py | 18 +- .../mgmt/monitor/v2020_10_01/models/_patch.py | 19 + .../v2020_10_01/operations/__init__.py | 5 + .../_activity_log_alerts_operations.py | 354 ++-- .../monitor/v2020_10_01/operations/_patch.py | 19 + .../mgmt/monitor/v2021_04_01/__init__.py | 13 +- .../monitor/v2021_04_01/_configuration.py | 9 +- .../mgmt/monitor/v2021_04_01/_metadata.json | 4 +- .../v2021_04_01/_monitor_management_client.py | 24 +- .../mgmt/monitor/v2021_04_01/_version.py | 2 +- .../mgmt/monitor/v2021_04_01/aio/__init__.py | 13 +- .../monitor/v2021_04_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 22 +- .../v2021_04_01/aio/operations/__init__.py | 5 + .../_data_collection_endpoints_operations.py | 198 +- ...collection_rule_associations_operations.py | 169 +- .../_data_collection_rules_operations.py | 198 +- .../v2021_04_01/aio/operations/_patch.py | 19 + .../monitor/v2021_04_01/models/__init__.py | 6 +- .../monitor/v2021_04_01/models/_models_py3.py | 208 +- .../_monitor_management_client_enums.py | 29 +- .../mgmt/monitor/v2021_04_01/models/_patch.py | 19 + .../v2021_04_01/operations/__init__.py | 5 + .../_data_collection_endpoints_operations.py | 358 ++-- ...collection_rule_associations_operations.py | 300 +-- .../_data_collection_rules_operations.py | 358 ++-- .../monitor/v2021_04_01/operations/_patch.py | 19 + .../monitor/v2021_05_01_preview/__init__.py | 13 +- .../v2021_05_01_preview/_configuration.py | 9 +- .../v2021_05_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 36 +- .../monitor/v2021_05_01_preview/_version.py | 2 +- .../v2021_05_01_preview/aio/__init__.py | 13 +- .../v2021_05_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 34 +- .../aio/operations/__init__.py | 5 + .../_autoscale_settings_operations.py | 194 +- ...diagnostic_settings_category_operations.py | 87 +- .../_diagnostic_settings_operations.py | 138 +- ...nt_group_diagnostic_settings_operations.py | 138 +- .../aio/operations/_patch.py | 19 + .../_predictive_metric_operations.py | 58 +- ...cription_diagnostic_settings_operations.py | 138 +- .../v2021_05_01_preview/models/__init__.py | 6 +- .../v2021_05_01_preview/models/_models_py3.py | 163 +- .../_monitor_management_client_enums.py | 21 +- .../v2021_05_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../_autoscale_settings_operations.py | 354 ++-- ...diagnostic_settings_category_operations.py | 140 +- .../_diagnostic_settings_operations.py | 245 ++- ...nt_group_diagnostic_settings_operations.py | 245 ++- .../v2021_05_01_preview/operations/_patch.py | 19 + .../_predictive_metric_operations.py | 97 +- ...cription_diagnostic_settings_operations.py | 245 ++- .../mgmt/monitor/v2021_09_01/__init__.py | 13 +- .../monitor/v2021_09_01/_configuration.py | 9 +- .../mgmt/monitor/v2021_09_01/_metadata.json | 4 +- .../v2021_09_01/_monitor_management_client.py | 16 +- .../mgmt/monitor/v2021_09_01/_version.py | 2 +- .../mgmt/monitor/v2021_09_01/aio/__init__.py | 13 +- .../monitor/v2021_09_01/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 14 +- .../v2021_09_01/aio/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 750 +++++++- .../v2021_09_01/aio/operations/_patch.py | 19 + .../monitor/v2021_09_01/models/__init__.py | 8 +- .../monitor/v2021_09_01/models/_models_py3.py | 141 +- .../_monitor_management_client_enums.py | 3 +- .../mgmt/monitor/v2021_09_01/models/_patch.py | 19 + .../v2021_09_01/operations/__init__.py | 5 + .../operations/_action_groups_operations.py | 1154 ++++++++--- .../monitor/v2021_09_01/operations/_patch.py | 19 + .../monitor/v2022_02_01_preview/__init__.py | 13 +- .../v2022_02_01_preview/_configuration.py | 9 +- .../v2022_02_01_preview/_metadata.json | 4 +- .../_monitor_management_client.py | 24 +- .../monitor/v2022_02_01_preview/_version.py | 2 +- .../v2022_02_01_preview/aio/__init__.py | 13 +- .../v2022_02_01_preview/aio/_configuration.py | 9 +- .../aio/_monitor_management_client.py | 22 +- .../aio/operations/__init__.py | 5 + .../_data_collection_endpoints_operations.py | 198 +- ...collection_rule_associations_operations.py | 198 +- .../_data_collection_rules_operations.py | 198 +- .../aio/operations/_patch.py | 19 + .../v2022_02_01_preview/models/__init__.py | 6 +- .../v2022_02_01_preview/models/_models_py3.py | 274 +-- .../_monitor_management_client_enums.py | 35 +- .../v2022_02_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../_data_collection_endpoints_operations.py | 358 ++-- ...collection_rule_associations_operations.py | 353 ++-- .../_data_collection_rules_operations.py | 358 ++-- .../v2022_02_01_preview/operations/_patch.py | 19 + .../__init__.py | 13 +- .../_configuration.py | 15 +- .../_metadata.json | 26 +- .../_monitor_management_client.py | 30 +- .../azure/mgmt/monitor/v2022_04_01/_patch.py | 19 + .../_vendor.py | 0 .../_version.py | 2 +- .../aio/__init__.py | 13 +- .../aio/_configuration.py | 15 +- .../aio/_monitor_management_client.py | 29 +- .../mgmt/monitor/v2022_04_01/aio/_patch.py | 19 + .../aio/operations/__init__.py | 9 +- .../operations/_action_groups_operations.py | 950 ++++++++++ .../v2022_04_01/aio/operations/_patch.py | 19 + .../monitor/v2022_04_01/models/__init__.py | 63 + .../monitor/v2022_04_01/models/_models_py3.py | 1315 +++++++++++++ .../_monitor_management_client_enums.py | 17 +- .../mgmt/monitor/v2022_04_01/models/_patch.py | 19 + .../v2022_04_01/operations/__init__.py | 18 + .../operations/_action_groups_operations.py | 1385 ++++++++++++++ .../monitor/v2022_04_01/operations/_patch.py | 19 + .../py.typed | 0 .../mgmt/monitor/v2022_06_01/__init__.py | 23 + .../monitor/v2022_06_01/_configuration.py | 73 + .../mgmt/monitor/v2022_06_01/_metadata.json | 102 + .../v2022_06_01/_monitor_management_client.py | 99 + .../azure/mgmt/monitor/v2022_06_01/_patch.py | 19 + .../azure/mgmt/monitor/v2022_06_01/_vendor.py | 27 + .../__init__.py => v2022_06_01/_version.py} | 6 +- .../mgmt/monitor/v2022_06_01/aio/__init__.py | 20 + .../monitor/v2022_06_01/aio/_configuration.py | 72 + .../aio/_monitor_management_client.py | 97 + .../mgmt/monitor/v2022_06_01/aio/_patch.py | 19 + .../v2022_06_01/aio/operations/__init__.py | 18 + .../operations/_action_groups_operations.py | 1165 ++++++++++++ .../v2022_06_01/aio/operations/_patch.py | 19 + .../monitor/v2022_06_01/models/__init__.py | 63 + .../monitor/v2022_06_01/models/_models_py3.py | 1315 +++++++++++++ .../_monitor_management_client_enums.py | 20 + .../mgmt/monitor/v2022_06_01/models/_patch.py | 19 + .../v2022_06_01/operations/__init__.py | 18 + .../operations/_action_groups_operations.py | 1684 +++++++++++++++++ .../monitor/v2022_06_01/operations/_patch.py | 19 + .../azure/mgmt/monitor/v2022_06_01/py.typed | 1 + 576 files changed, 29886 insertions(+), 13041 deletions(-) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py delete mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/__init__.py (68%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/_configuration.py (80%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/_metadata.json (79%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/_monitor_management_client.py (75%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/_vendor.py (100%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/_version.py (95%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/aio/__init__.py (66%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/aio/_configuration.py (80%) rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/aio/_monitor_management_client.py (76%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/aio/operations/__init__.py (59%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/models/_monitor_management_client_enums.py (63%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview => v2022_04_01}/py.typed (100%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py rename sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/{v2017_11_01_preview/operations/__init__.py => v2022_06_01/_version.py} (80%) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index f5d16436e4bc..6ec1c6f32676 100644 --- a/sdk/monitor/azure-mgmt-monitor/_meta.json +++ b/sdk/monitor/azure-mgmt-monitor/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "8174b2fc60e288a9d7fcdff5f9414e43a6ad5989", + "commit": "c6329aa9d0fda3e4f25ad666debe47946af20268", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/monitor/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/monitor/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/monitor/resource-manager/readme.md" } \ No newline at end of file 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 d810d1e177d4..18282c2182cd 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 @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration @@ -55,7 +56,7 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-06-01' _PROFILE_TAG = "azure.mgmt.monitor.MonitorManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -65,7 +66,6 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): 'alert_rule_incidents': '2016-03-01', 'alert_rules': '2016-03-01', 'autoscale_settings': '2015-04-01', - 'baseline': '2018-09-01', 'baselines': '2019-03-01', 'data_collection_endpoints': '2021-04-01', 'data_collection_rule_associations': '2021-04-01', @@ -79,7 +79,7 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): 'management_group_diagnostic_settings': '2021-05-01-preview', 'metric_alerts': '2018-03-01', 'metric_alerts_status': '2018-03-01', - 'metric_baseline': '2018-09-01', + 'metric_baseline': '2017-11-01-preview', 'metric_definitions': '2018-01-01', 'metric_namespaces': '2017-12-01-preview', 'metrics': '2018-01-01', @@ -149,6 +149,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` * 2021-09-01: :mod:`v2021_09_01.models` * 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` """ if api_version == '2015-04-01': from .v2015_04_01 import models @@ -228,6 +230,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-01-preview': from .v2022_02_01_preview import models return models + elif api_version == '2022-04-01': + from .v2022_04_01 import models + return models + elif api_version == '2022-06-01': + from .v2022_06_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -240,6 +248,8 @@ def action_groups(self): * 2019-03-01: :class:`ActionGroupsOperations` * 2019-06-01: :class:`ActionGroupsOperations` * 2021-09-01: :class:`ActionGroupsOperations` + * 2022-04-01: :class:`ActionGroupsOperations` + * 2022-06-01: :class:`ActionGroupsOperations` """ api_version = self._get_api_version('action_groups') if api_version == '2017-04-01': @@ -254,6 +264,10 @@ def action_groups(self): from .v2019_06_01.operations import ActionGroupsOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import ActionGroupsOperations as OperationClass + elif api_version == '2022-04-01': + from .v2022_04_01.operations import ActionGroupsOperations as OperationClass + elif api_version == '2022-06-01': + from .v2022_06_01.operations import ActionGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'action_groups'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -338,19 +352,6 @@ def autoscale_settings(self): raise ValueError("API version {} does not have operation group 'autoscale_settings'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property - def baseline(self): - """Instance depends on the API version: - - * 2018-09-01: :class:`BaselineOperations` - """ - api_version = self._get_api_version('baseline') - if api_version == '2018-09-01': - from .v2018_09_01.operations import BaselineOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'baseline'".format(api_version)) - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property def baselines(self): """Instance depends on the API version: @@ -549,13 +550,10 @@ def metric_baseline(self): """Instance depends on the API version: * 2017-11-01-preview: :class:`MetricBaselineOperations` - * 2018-09-01: :class:`MetricBaselineOperations` """ api_version = self._get_api_version('metric_baseline') if api_version == '2017-11-01-preview': from .v2017_11_01_preview.operations import MetricBaselineOperations as OperationClass - elif api_version == '2018-09-01': - from .v2018_09_01.operations import MetricBaselineOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'metric_baseline'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/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 4baa61a8055b..72863815f19e 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 @@ -11,10 +11,11 @@ from typing import Any, Optional, TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration @@ -54,7 +55,7 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-06-01' _PROFILE_TAG = "azure.mgmt.monitor.MonitorManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -64,7 +65,6 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): 'alert_rule_incidents': '2016-03-01', 'alert_rules': '2016-03-01', 'autoscale_settings': '2015-04-01', - 'baseline': '2018-09-01', 'baselines': '2019-03-01', 'data_collection_endpoints': '2021-04-01', 'data_collection_rule_associations': '2021-04-01', @@ -78,7 +78,7 @@ class MonitorManagementClient(MultiApiClientMixin, _SDKClient): 'management_group_diagnostic_settings': '2021-05-01-preview', 'metric_alerts': '2018-03-01', 'metric_alerts_status': '2018-03-01', - 'metric_baseline': '2018-09-01', + 'metric_baseline': '2017-11-01-preview', 'metric_definitions': '2018-01-01', 'metric_namespaces': '2017-12-01-preview', 'metrics': '2018-01-01', @@ -148,6 +148,8 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-05-01-preview: :mod:`v2021_05_01_preview.models` * 2021-09-01: :mod:`v2021_09_01.models` * 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` """ if api_version == '2015-04-01': from ..v2015_04_01 import models @@ -227,6 +229,12 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-01-preview': from ..v2022_02_01_preview import models return models + elif api_version == '2022-04-01': + from ..v2022_04_01 import models + return models + elif api_version == '2022-06-01': + from ..v2022_06_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -239,6 +247,8 @@ def action_groups(self): * 2019-03-01: :class:`ActionGroupsOperations` * 2019-06-01: :class:`ActionGroupsOperations` * 2021-09-01: :class:`ActionGroupsOperations` + * 2022-04-01: :class:`ActionGroupsOperations` + * 2022-06-01: :class:`ActionGroupsOperations` """ api_version = self._get_api_version('action_groups') if api_version == '2017-04-01': @@ -253,6 +263,10 @@ def action_groups(self): from ..v2019_06_01.aio.operations import ActionGroupsOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import ActionGroupsOperations as OperationClass + elif api_version == '2022-04-01': + from ..v2022_04_01.aio.operations import ActionGroupsOperations as OperationClass + elif api_version == '2022-06-01': + from ..v2022_06_01.aio.operations import ActionGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'action_groups'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -337,19 +351,6 @@ def autoscale_settings(self): raise ValueError("API version {} does not have operation group 'autoscale_settings'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property - def baseline(self): - """Instance depends on the API version: - - * 2018-09-01: :class:`BaselineOperations` - """ - api_version = self._get_api_version('baseline') - if api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import BaselineOperations as OperationClass - else: - raise ValueError("API version {} does not have operation group 'baseline'".format(api_version)) - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - @property def baselines(self): """Instance depends on the API version: @@ -548,13 +549,10 @@ def metric_baseline(self): """Instance depends on the API version: * 2017-11-01-preview: :class:`MetricBaselineOperations` - * 2018-09-01: :class:`MetricBaselineOperations` """ api_version = self._get_api_version('metric_baseline') if api_version == '2017-11-01-preview': from ..v2017_11_01_preview.aio.operations import MetricBaselineOperations as OperationClass - elif api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import MetricBaselineOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'metric_baseline'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py index 9def65086344..9faffa30f5ca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py @@ -8,16 +8,16 @@ from .v2015_07_01.models import * from .v2016_03_01.models import * from .v2016_09_01.models import * +from .v2017_11_01_preview.models import * from .v2017_12_01_preview.models import * from .v2018_01_01.models import * from .v2018_03_01.models import * from .v2018_04_16.models import * from .v2018_06_01_preview.models import * -from .v2018_09_01.models import * from .v2018_11_27_preview.models import * from .v2019_03_01.models import * from .v2019_10_17.models import * from .v2020_10_01.models import * from .v2021_04_01.models import * from .v2021_05_01_preview.models import * -from .v2021_09_01.models import * +from .v2022_06_01.models import * 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 e1f58c99be3f..b152f1a01ba7 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 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 3399fadde882..b271c6f03d5c 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 de9d3cc08044..f5dd17d46833 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -43,7 +44,7 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str """ @@ -61,17 +62,29 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event_categories = EventCategoriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_logs = ActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_categories = EventCategoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_activity_logs = TenantActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py index 34bea0f7b202..fe42fc99d8d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 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 1859b81d454f..b9409ed878ba 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -44,7 +45,7 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str """ @@ -62,12 +63,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event_categories = EventCategoriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_logs = ActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_categories = EventCategoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tenant_activity_logs = TenantActivityLogsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 76293309fbf0..3f665d258d3a 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 @@ -13,6 +13,9 @@ from ._tenant_activity_logs_operations import TenantActivityLogsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogsOperations', 'AutoscaleSettingsOperations', @@ -21,3 +24,5 @@ 'TenantActivityLogsOperations', 'AlertRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 6ebd670f23bf..0fc2c29a2b19 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActivityLogsOperations: - """ActivityLogsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`activity_logs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +49,7 @@ def list( filter: str, select: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventDataCollection"]: + ) -> AsyncIterable[_models.EventDataCollection]: """Provides the list of records from the activity logs. :param filter: Reduces the set of data collected.:code:`
`This argument is required and it @@ -76,41 +73,56 @@ def list( *authorization*\ , *claims*\ , *correlationId*\ , *description*\ , *eventDataId*\ , *eventName*\ , *eventTimestamp*\ , *httpRequest*\ , *level*\ , *operationId*\ , *operationName*\ , *properties*\ , *resourceGroupName*\ , *resourceProviderName*\ , - *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. + *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default + value is None. :type select: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, select=select, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, select=select, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,4 +154,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"} # type: ignore 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 0090b24ecd12..3c42ca8e8a12 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertRulesOperations: - """AlertRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -62,18 +60,25 @@ async def create_or_update( :type rule_name: str :param parameters: The parameters of the rule to create or update. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -81,14 +86,21 @@ async def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,11 +119,11 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -123,28 +135,43 @@ async def delete( :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -155,7 +182,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -164,35 +191,50 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,7 +249,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +257,9 @@ async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -227,18 +269,25 @@ async def update( :type rule_name: str :param alert_rules_resource: Parameters supplied to the operation. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -246,14 +295,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -272,7 +328,7 @@ async def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -280,11 +336,14 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -292,31 +351,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -330,7 +400,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,15 +418,18 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -360,29 +437,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -396,7 +484,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,4 +502,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"} # type: ignore 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 19844d7ade46..920885d30077 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,37 +25,38 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AutoscaleSettingsOperations: - """AutoscaleSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: + ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) @@ -63,31 +64,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +113,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,16 +131,16 @@ 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"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, - parameters: "_models.AutoscaleSettingResource", + parameters: _models.AutoscaleSettingResource, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -133,18 +149,25 @@ async def create_or_update( :type autoscale_setting_name: str :param parameters: Parameters supplied to the operation. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(parameters, 'AutoscaleSettingResource') @@ -152,14 +175,21 @@ async def create_or_update( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -178,11 +208,11 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, autoscale_setting_name: str, @@ -194,28 +224,43 @@ async def delete( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -226,7 +271,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -235,35 +280,50 @@ async def get( resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,7 +338,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -286,9 +346,9 @@ async def update( self, resource_group_name: str, autoscale_setting_name: str, - autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. @@ -299,18 +359,25 @@ async def update( :param autoscale_setting_resource: Parameters supplied to the operation. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') @@ -318,14 +385,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,16 +414,19 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: + ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a subscription. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) @@ -357,29 +434,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +481,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,4 +499,4 @@ 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"} # type: ignore 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 16baeea9aeca..2700dcfb9c68 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,36 +24,37 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EventCategoriesOperations: - """EventCategoriesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`event_categories` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.EventCategoryCollection"]: + ) -> AsyncIterable[_models.EventCategoryCollection]: """Get the list of available event categories supported in the Activity Logs Service.:code:`
`The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventCategoryCollection or the result of cls(response) @@ -62,27 +62,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventCategoryCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,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"} # type: ignore 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 2a7b6d9a147a..0f242211eeda 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,53 +23,66 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( self, **kwargs: Any - ) -> "_models.OperationListResult": + ) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.OperationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -83,5 +96,5 @@ async def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 e9a9c1f5aab2..b567f1c75f68 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TenantActivityLogsOperations: - """TenantActivityLogsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.aio.MonitorManagementClient`'s + :attr:`tenant_activity_logs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +49,7 @@ def list( filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventDataCollection"]: + ) -> AsyncIterable[_models.EventDataCollection]: """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at @@ -74,46 +71,61 @@ def list( api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq ':code:``'.:code:`
`\ **NOTE**\ : No other syntax is - allowed. + allowed. Default value is None. :type filter: str :param select: Used to fetch events with only the given properties.:code:`
`The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*\ , *claims*\ , *correlationId*\ , *description*\ , *eventDataId*\ , *eventName*\ , *eventTimestamp*\ , *httpRequest*\ , *level*\ , *operationId*\ , *operationName*\ , *properties*\ , *resourceGroupName*\ , *resourceProviderName*\ , - *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. + *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default + value is None. :type select: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, filter=filter, select=select, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, filter=filter, select=select, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,7 +139,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,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"} # type: ignore 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 8c2ce56ff580..f1a5ddd891b9 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 @@ -61,7 +61,9 @@ TimeAggregationOperator, TimeAggregationType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AlertRuleResource', 'AlertRuleResourceCollection', @@ -115,3 +117,5 @@ 'TimeAggregationOperator', 'TimeAggregationType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 56559fa4174d..73f6e817959a 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Resource(msrest.serialization.Model): @@ -140,12 +142,12 @@ def __init__( location: str, name_properties_name: str, is_enabled: bool, - condition: "RuleCondition", + condition: "_models.RuleCondition", tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, provisioning_state: Optional[str] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -196,7 +198,7 @@ class AlertRuleResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AlertRuleResource"]] = None, + value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs ): """ @@ -258,9 +260,9 @@ def __init__( description: Optional[str] = None, provisioning_state: Optional[str] = None, is_enabled: Optional[bool] = None, - condition: Optional["RuleCondition"] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + condition: Optional["_models.RuleCondition"] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -327,8 +329,8 @@ class AutoscaleNotification(msrest.serialization.Model): def __init__( self, *, - email: Optional["EmailNotification"] = None, - webhooks: Optional[List["WebhookNotification"]] = None, + email: Optional["_models.EmailNotification"] = None, + webhooks: Optional[List["_models.WebhookNotification"]] = None, **kwargs ): """ @@ -380,10 +382,10 @@ def __init__( self, *, name: str, - capacity: "ScaleCapacity", - rules: List["ScaleRule"], - fixed_date: Optional["TimeWindow"] = None, - recurrence: Optional["Recurrence"] = None, + capacity: "_models.ScaleCapacity", + rules: List["_models.ScaleRule"], + fixed_date: Optional["_models.TimeWindow"] = None, + recurrence: Optional["_models.Recurrence"] = None, **kwargs ): """ @@ -433,7 +435,7 @@ class AutoscaleSettingResource(Resource): :vartype notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :vartype enabled: bool :ivar name_properties_name: the name of the autoscale setting. :vartype name_properties_name: str @@ -471,10 +473,10 @@ def __init__( self, *, location: str, - profiles: List["AutoscaleProfile"], + profiles: List["_models.AutoscaleProfile"], tags: Optional[Dict[str, str]] = None, - notifications: Optional[List["AutoscaleNotification"]] = None, - enabled: Optional[bool] = True, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: Optional[bool] = False, name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, @@ -493,7 +495,7 @@ def __init__( :paramtype notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :paramtype enabled: bool :keyword name_properties_name: the name of the autoscale setting. :paramtype name_properties_name: str @@ -536,7 +538,7 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: List["AutoscaleSettingResource"], + value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs ): @@ -563,7 +565,7 @@ class AutoscaleSettingResourcePatch(msrest.serialization.Model): :vartype notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :vartype enabled: bool :ivar name: the name of the autoscale setting. :vartype name: str @@ -593,9 +595,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - profiles: Optional[List["AutoscaleProfile"]] = None, - notifications: Optional[List["AutoscaleNotification"]] = None, - enabled: Optional[bool] = True, + profiles: Optional[List["_models.AutoscaleProfile"]] = None, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: Optional[bool] = False, name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, @@ -611,7 +613,7 @@ def __init__( :paramtype notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :paramtype enabled: bool :keyword name: the name of the autoscale setting. :paramtype name: str @@ -729,7 +731,7 @@ class EventCategoryCollection(msrest.serialization.Model): def __init__( self, *, - value: List["LocalizableString"], + value: List["_models.LocalizableString"], **kwargs ): """ @@ -771,7 +773,7 @@ class EventData(msrest.serialization.Model): 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). :vartype http_request: ~$(python-base-namespace).v2015_04_01.models.HttpRequestInfo - :ivar level: the event level. Possible values include: "Critical", "Error", "Warning", + :ivar level: the event level. Known values are: "Critical", "Error", "Warning", "Informational", "Verbose". :vartype level: str or ~$(python-base-namespace).v2015_04_01.models.EventLevel :ivar resource_group_name: the resource group name of the impacted resource. @@ -925,7 +927,7 @@ class EventDataCollection(msrest.serialization.Model): def __init__( self, *, - value: List["EventData"], + value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs ): @@ -1058,7 +1060,7 @@ class RuleCondition(msrest.serialization.Model): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, **kwargs ): """ @@ -1109,7 +1111,7 @@ def __init__( self, *, failed_location_count: int, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): @@ -1134,8 +1136,8 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :ivar operator: the condition operator. Possible values include: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -1154,13 +1156,13 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): def __init__( self, *, - operator: Optional[Union[str, "ConditionOperator"]] = None, + operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): """ - :keyword operator: the condition operator. Possible values include: "GreaterThan", + :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. @@ -1209,8 +1211,8 @@ class ManagementEventRuleCondition(RuleCondition): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, - aggregation: Optional["ManagementEventAggregationCondition"] = None, + data_source: Optional["_models.RuleDataSource"] = None, + aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, **kwargs ): """ @@ -1246,19 +1248,19 @@ class MetricTrigger(msrest.serialization.Model): 1 minute. :vartype time_grain: ~datetime.timedelta :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances - are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". :vartype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType :ivar time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. :vartype time_window: ~datetime.timedelta :ivar time_aggregation: Required. time aggregation type. How the data that is collected should - be combined over time. The default value is Average. Possible values include: "Average", - "Minimum", "Maximum", "Total", "Count", "Last". + be combined over time. The default value is Average. Known values are: "Average", "Minimum", + "Maximum", "Total", "Count", "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType :ivar operator: Required. the operator that is used to compare the metric data and the - threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType :ivar threshold: Required. the threshold of the metric that triggers the scale action. @@ -1303,14 +1305,14 @@ def __init__( metric_name: str, metric_resource_uri: str, time_grain: datetime.timedelta, - statistic: Union[str, "MetricStatisticType"], + statistic: Union[str, "_models.MetricStatisticType"], time_window: datetime.timedelta, - time_aggregation: Union[str, "TimeAggregationType"], - operator: Union[str, "ComparisonOperationType"], + time_aggregation: Union[str, "_models.TimeAggregationType"], + operator: Union[str, "_models.ComparisonOperationType"], threshold: float, metric_namespace: Optional[str] = None, metric_resource_location: Optional[str] = None, - dimensions: Optional[List["ScaleRuleMetricDimension"]] = None, + dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, divide_per_instance: Optional[bool] = None, **kwargs ): @@ -1329,19 +1331,19 @@ def __init__( 1 minute. :paramtype time_grain: ~datetime.timedelta :keyword statistic: Required. the metric statistic type. How the metrics from multiple - instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + instances are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". :paramtype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType :keyword time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. :paramtype time_window: ~datetime.timedelta :keyword time_aggregation: Required. time aggregation type. How the data that is collected - should be combined over time. The default value is Average. Possible values include: "Average", + should be combined over time. The default value is Average. Known values are: "Average", "Minimum", "Maximum", "Total", "Count", "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType :keyword operator: Required. the operator that is used to compare the metric data and the - threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType @@ -1387,7 +1389,7 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -1457,7 +1459,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1480,8 +1482,8 @@ class Recurrence(msrest.serialization.Model): :ivar frequency: Required. 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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Possible values include: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", "Year". :vartype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency :ivar schedule: Required. the scheduling constraints for when the profile begins. :vartype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule @@ -1500,16 +1502,16 @@ class Recurrence(msrest.serialization.Model): def __init__( self, *, - frequency: Union[str, "RecurrenceFrequency"], - schedule: "RecurrentSchedule", + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", **kwargs ): """ :keyword frequency: Required. 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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Possible values include: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", "Year". :paramtype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency :keyword schedule: Required. the scheduling constraints for when the profile begins. :paramtype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule @@ -1888,7 +1890,7 @@ def __init__( resource_provider_name: Optional[str] = None, status: Optional[str] = None, sub_status: Optional[str] = None, - claims: Optional["RuleManagementEventClaimsDataSource"] = None, + claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, **kwargs ): """ @@ -2054,10 +2056,10 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + decreases the number of instances. Known values are: "None", "Increase", "Decrease". :vartype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :ivar type: Required. the type of action that should occur when the scale rule fires. Possible - values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :ivar type: Required. the type of action that should occur when the scale rule fires. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". :vartype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. @@ -2083,19 +2085,18 @@ class ScaleAction(msrest.serialization.Model): def __init__( self, *, - direction: Union[str, "ScaleDirection"], - type: Union[str, "ScaleType"], + direction: Union[str, "_models.ScaleDirection"], + type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, value: Optional[str] = "1", **kwargs ): """ :keyword direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + decreases the number of instances. Known values are: "None", "Increase", "Decrease". :paramtype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :keyword type: Required. the type of action that should occur when the scale rule fires. - Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", - "ServiceAllowedNextValue". + :keyword type: Required. the type of action that should occur when the scale rule fires. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". :paramtype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType :keyword value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. @@ -2188,8 +2189,8 @@ class ScaleRule(msrest.serialization.Model): def __init__( self, *, - metric_trigger: "MetricTrigger", - scale_action: "ScaleAction", + metric_trigger: "_models.MetricTrigger", + scale_action: "_models.ScaleAction", **kwargs ): """ @@ -2212,7 +2213,7 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): :vartype dimension_name: str :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. - Possible values include: "Equals", "NotEquals". + Known values are: "Equals", "NotEquals". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType :ivar values: Required. list of dimension values. For example: ["App1","App2"]. @@ -2235,7 +2236,7 @@ def __init__( self, *, dimension_name: str, - operator: Union[str, "ScaleRuleMetricDimensionOperationType"], + operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], values: List[str], **kwargs ): @@ -2244,7 +2245,7 @@ def __init__( :paramtype dimension_name: str :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the - values. Possible values include: "Equals", "NotEquals". + values. Known values are: "Equals", "NotEquals". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType :keyword values: Required. list of dimension values. For example: ["App1","App2"]. @@ -2308,8 +2309,8 @@ class ThresholdRuleCondition(RuleCondition): :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: Required. the operator used to compare the data and the threshold. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :ivar threshold: Required. the threshold value that activates the alert. :vartype threshold: float @@ -2318,8 +2319,8 @@ class ThresholdRuleCondition(RuleCondition): day. :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible - values include: "Average", "Minimum", "Maximum", "Total", "Last". + be combined over time. The default value is the PrimaryAggregationType of the Metric. Known + values are: "Average", "Minimum", "Maximum", "Total", "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ @@ -2342,19 +2343,19 @@ class ThresholdRuleCondition(RuleCondition): def __init__( self, *, - operator: Union[str, "ConditionOperator"], + operator: Union[str, "_models.ConditionOperator"], threshold: float, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, + time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, **kwargs ): """ :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 - :keyword operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: Required. the operator used to compare the data and the threshold. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator :keyword threshold: Required. the threshold value that activates the alert. :paramtype threshold: float @@ -2364,7 +2365,7 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py index 9b8ef5463b88..a0ae11b4bdc2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the operator that is used to compare the metric data and the threshold. """ @@ -22,7 +21,7 @@ class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operators allowed in the rule condition. """ @@ -31,7 +30,7 @@ class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class EventLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EventLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the event level """ @@ -41,7 +40,7 @@ class EventLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFORMATIONAL = "Informational" VERBOSE = "Verbose" -class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the metric statistic type. How the metrics from multiple instances are combined. """ @@ -51,7 +50,7 @@ class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUM = "Sum" COUNT = "Count" -class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the @@ -67,7 +66,7 @@ class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MONTH = "Month" YEAR = "Year" -class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the scale direction. Whether the scaling action increases or decreases the number of instances. """ @@ -75,7 +74,7 @@ class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREASE = "Increase" DECREASE = "Decrease" -class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values """ @@ -83,7 +82,7 @@ class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMe EQUALS = "Equals" NOT_EQUALS = "NotEquals" -class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the type of action that should occur when the scale rule fires. """ @@ -92,7 +91,7 @@ class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" -class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Aggregation operators allowed in a rule. """ @@ -102,7 +101,7 @@ class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) TOTAL = "Total" LAST = "Last" -class TimeAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 76293309fbf0..3f665d258d3a 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 @@ -13,6 +13,9 @@ from ._tenant_activity_logs_operations import TenantActivityLogsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogsOperations', 'AutoscaleSettingsOperations', @@ -21,3 +24,5 @@ 'TenantActivityLogsOperations', 'AlertRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 d84be1161790..6046f4eee0d3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,56 +34,56 @@ def build_list_request( select: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ActivityLogsOperations(object): - """ActivityLogsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`activity_logs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -90,7 +91,7 @@ def list( filter: str, select: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.EventDataCollection"]: + ) -> Iterable[_models.EventDataCollection]: """Provides the list of records from the activity logs. :param filter: Reduces the set of data collected.:code:`
`This argument is required and it @@ -114,41 +115,56 @@ def list( *authorization*\ , *claims*\ , *correlationId*\ , *description*\ , *eventDataId*\ , *eventName*\ , *eventTimestamp*\ , *httpRequest*\ , *level*\ , *operationId*\ , *operationName*\ , *properties*\ , *resourceGroupName*\ , *resourceProviderName*\ , - *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. + *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default + value is None. :type select: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, select=select, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, select=select, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -162,7 +178,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,4 +196,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"} # type: ignore 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 1a2dc61a2fa4..00c92ceae69d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( rule_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2014-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2014-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,30 +196,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -222,62 +230,62 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AlertRulesOperations(object): - """AlertRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -286,18 +294,25 @@ def create_or_update( :type rule_name: str :param parameters: The parameters of the rule to create or update. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -305,14 +320,21 @@ def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,11 +353,11 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -347,28 +369,43 @@ def delete( :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,7 +416,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -388,35 +425,50 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -431,7 +483,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -439,9 +491,9 @@ def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -451,18 +503,25 @@ def update( :type rule_name: str :param alert_rules_resource: Parameters supplied to the operation. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -470,14 +529,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -496,7 +562,7 @@ def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -504,11 +570,14 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -516,31 +585,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -554,7 +634,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,15 +652,18 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -584,29 +671,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -620,7 +718,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,4 +736,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"} # type: ignore 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 eefbcb61faac..249a2b772fa2 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,39 +67,40 @@ def build_create_or_update_request( autoscale_setting_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AutoscaleSettingResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2015-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -110,31 +113,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -145,31 +150,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -179,39 +186,40 @@ def build_update_request( resource_group_name: str, autoscale_setting_name: str, *, - json: JSONType = None, + json: Optional[_models.AutoscaleSettingResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2015-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # 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), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -222,64 +230,67 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AutoscaleSettingsOperations(object): - """AutoscaleSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AutoscaleSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: + ) -> Iterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) @@ -287,31 +298,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -325,7 +347,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,16 +365,16 @@ 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"} # type: ignore @distributed_trace def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, - parameters: "_models.AutoscaleSettingResource", + parameters: _models.AutoscaleSettingResource, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -357,18 +383,25 @@ def create_or_update( :type autoscale_setting_name: str :param parameters: Parameters supplied to the operation. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(parameters, 'AutoscaleSettingResource') @@ -376,14 +409,21 @@ def create_or_update( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -402,11 +442,11 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, autoscale_setting_name: str, @@ -418,28 +458,43 @@ def delete( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -450,7 +505,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -459,35 +514,50 @@ def get( resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,7 +572,7 @@ 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}"} # type: ignore @distributed_trace @@ -510,9 +580,9 @@ def update( self, resource_group_name: str, autoscale_setting_name: str, - autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. @@ -523,18 +593,25 @@ def update( :param autoscale_setting_resource: Parameters supplied to the operation. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') @@ -542,14 +619,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,16 +648,19 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: + ) -> Iterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a subscription. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) @@ -581,29 +668,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,7 +715,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,4 +733,4 @@ 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"} # type: ignore 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 2a56b97cd36d..96a6dbc52c0a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,58 +30,61 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Insights/eventcategories') + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventcategories") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EventCategoriesOperations(object): - """EventCategoriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EventCategoriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`event_categories` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.EventCategoryCollection"]: + ) -> Iterable[_models.EventCategoryCollection]: """Get the list of available event categories supported in the Activity Logs Service.:code:`
`The current list includes the following: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventCategoryCollection or the result of cls(response) @@ -88,27 +92,38 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventCategoryCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -122,7 +137,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -136,4 +155,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"} # type: ignore 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 becc93fb69e6..2fe3474a556c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -28,75 +29,90 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Insights/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> "_models.OperationListResult": + ) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.OperationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,5 +126,5 @@ def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 7d141717dc2a..588e78c70bd8 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -32,52 +33,52 @@ def build_list_request( select: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2015-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Insights/eventtypes/management/values') + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/eventtypes/management/values") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TenantActivityLogsOperations(object): - """TenantActivityLogsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TenantActivityLogsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_04_01.MonitorManagementClient`'s + :attr:`tenant_activity_logs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -85,7 +86,7 @@ def list( filter: Optional[str] = None, select: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.EventDataCollection"]: + ) -> Iterable[_models.EventDataCollection]: """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at @@ -107,46 +108,61 @@ def list( api-version=2014-04-01&$filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and correlationId eq ':code:``'.:code:`
`\ **NOTE**\ : No other syntax is - allowed. + allowed. Default value is None. :type filter: str :param select: Used to fetch events with only the given properties.:code:`
`The **$select** argument is a comma separated list of property names to be returned. Possible values are: *authorization*\ , *claims*\ , *correlationId*\ , *description*\ , *eventDataId*\ , *eventName*\ , *eventTimestamp*\ , *httpRequest*\ , *level*\ , *operationId*\ , *operationName*\ , *properties*\ , *resourceGroupName*\ , *resourceProviderName*\ , - *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. + *resourceId*\ , *status*\ , *submissionTimestamp*\ , *subStatus*\ , *subscriptionId*. Default + value is None. :type select: str + :keyword api_version: Api Version. Default value is "2015-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, filter=filter, select=select, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, filter=filter, select=select, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -160,7 +176,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,4 +194,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"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 e1f58c99be3f..b152f1a01ba7 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 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 d78934a87679..b25ebe057879 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 3e6ca5d03b38..4dbfdc9804a5 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -38,7 +39,7 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str """ @@ -56,15 +57,23 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py index 34bea0f7b202..fe42fc99d8d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 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 022345195cee..4527d7b5fc0c 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -38,7 +39,7 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str """ @@ -56,10 +57,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 28c5041be1cd..aedf5ce120e4 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 @@ -11,9 +11,14 @@ from ._alert_rules_operations import AlertRulesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ServiceDiagnosticSettingsOperations', 'MetricDefinitionsOperations', 'AlertRulesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 ab9addf70917..b5daf5520920 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertRulesOperations: - """AlertRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.aio.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -62,18 +60,25 @@ async def create_or_update( :type rule_name: str :param parameters: The parameters of the rule to create or update. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -81,14 +86,21 @@ async def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,11 +119,11 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -123,28 +135,43 @@ async def delete( :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -155,7 +182,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -164,35 +191,50 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,7 +249,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +257,9 @@ async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -227,18 +269,25 @@ async def update( :type rule_name: str :param alert_rules_resource: Parameters supplied to the operation. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -246,14 +295,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -272,7 +328,7 @@ async def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -280,11 +336,14 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -292,31 +351,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -330,7 +400,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,15 +418,18 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -360,29 +437,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -396,7 +484,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,4 +502,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"} # type: ignore 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 77529014142a..2f10780f7037 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricDefinitionsOperations: - """MetricDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.aio.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +49,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinitionCollection"]: + ) -> AsyncIterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -62,8 +59,11 @@ def list( definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. + other syntax is allowed. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) @@ -71,31 +71,42 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +120,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,4 +138,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"} # type: ignore 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 53bc049c9ba6..6338db60489a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,53 +23,66 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.aio.MonitorManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( self, **kwargs: Any - ) -> "_models.OperationListResult": + ) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.OperationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -84,5 +97,5 @@ async def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 314d1cc68768..e789ce45124e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,57 +23,70 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ServiceDiagnosticSettingsOperations: - """ServiceDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.aio.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( self, resource_uri: str, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. :type resource_uri: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -88,16 +101,16 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_uri: str, - parameters: "_models.ServiceDiagnosticSettingsResource", + parameters: _models.ServiceDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -105,31 +118,45 @@ async def create_or_update( :param parameters: Parameters supplied to the operation. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,5 +170,5 @@ 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"} # type: ignore 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 04b1680c0010..3043683a3028 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 @@ -49,7 +49,9 @@ TimeAggregationOperator, Unit, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AlertRuleResource', 'AlertRuleResourceCollection', @@ -91,3 +93,5 @@ 'TimeAggregationOperator', 'Unit', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 fd3490a9af69..035f5c22faf3 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Resource(msrest.serialization.Model): @@ -140,12 +142,12 @@ def __init__( location: str, name_properties_name: str, is_enabled: bool, - condition: "RuleCondition", + condition: "_models.RuleCondition", tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, provisioning_state: Optional[str] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -196,7 +198,7 @@ class AlertRuleResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AlertRuleResource"]] = None, + value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs ): """ @@ -258,9 +260,9 @@ def __init__( description: Optional[str] = None, provisioning_state: Optional[str] = None, is_enabled: Optional[bool] = None, - condition: Optional["RuleCondition"] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + condition: Optional["_models.RuleCondition"] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -367,7 +369,7 @@ class ErrorContract(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): """ @@ -482,7 +484,7 @@ class RuleCondition(msrest.serialization.Model): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, **kwargs ): """ @@ -533,7 +535,7 @@ def __init__( self, *, failed_location_count: int, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): @@ -585,7 +587,7 @@ def __init__( *, enabled: bool, category: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -646,8 +648,8 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :ivar operator: the condition operator. Possible values include: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -666,13 +668,13 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): def __init__( self, *, - operator: Optional[Union[str, "ConditionOperator"]] = None, + operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): """ - :keyword operator: the condition operator. Possible values include: "GreaterThan", + :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. @@ -721,8 +723,8 @@ class ManagementEventRuleCondition(RuleCondition): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, - aggregation: Optional["ManagementEventAggregationCondition"] = None, + data_source: Optional["_models.RuleDataSource"] = None, + aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, **kwargs ): """ @@ -764,7 +766,7 @@ def __init__( *, time_grain: Optional[datetime.timedelta] = None, retention: Optional[datetime.timedelta] = None, - location: Optional["MetricAvailabilityLocation"] = None, + location: Optional["_models.MetricAvailabilityLocation"] = None, **kwargs ): """ @@ -804,7 +806,7 @@ def __init__( self, *, table_endpoint: Optional[str] = None, - table_info: Optional[List["TableInfoEntry"]] = None, + table_info: Optional[List["_models.TableInfoEntry"]] = None, partition_key: Optional[str] = None, **kwargs ): @@ -834,7 +836,7 @@ class MetricDefinition(msrest.serialization.Model): :vartype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString :ivar category: The category of this metric. :vartype category: str - :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". :vartype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit :ivar start_time: Start time of the metadata request timespan. @@ -842,7 +844,7 @@ class MetricDefinition(msrest.serialization.Model): :ivar end_time: End time of the metadata request timespan. :vartype end_time: ~datetime.datetime :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType @@ -877,14 +879,14 @@ def __init__( *, resource_id: Optional[str] = None, resource_uri: Optional[str] = None, - name: Optional["LocalizableString"] = None, + name: Optional["_models.LocalizableString"] = None, category: Optional[str] = None, - unit: Optional[Union[str, "Unit"]] = None, + unit: Optional[Union[str, "_models.Unit"]] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - primary_aggregation_type: Optional[Union[str, "AggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "AggregationType"]]] = None, - metric_availabilities: Optional[List["MetricAvailability"]] = None, + primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, + metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, **kwargs ): @@ -897,7 +899,7 @@ def __init__( :paramtype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString :keyword category: The category of this metric. :paramtype category: str - :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". :paramtype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit :keyword start_time: Start time of the metadata request timespan. @@ -905,7 +907,7 @@ def __init__( :keyword end_time: End time of the metadata request timespan. :paramtype end_time: ~datetime.datetime :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType @@ -957,7 +959,7 @@ class MetricDefinitionCollection(msrest.serialization.Model): def __init__( self, *, - value: List["MetricDefinition"], + value: List["_models.MetricDefinition"], id: Optional[str] = None, **kwargs ): @@ -1001,7 +1003,7 @@ def __init__( *, time_grain: datetime.timedelta, enabled: bool, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -1080,7 +1082,7 @@ def __init__( availabilities: Optional[List[str]] = None, lock_aggregation_type: Optional[str] = None, category: Optional[str] = None, - dimensions: Optional[List["DimensionProperties"]] = None, + dimensions: Optional[List["_models.DimensionProperties"]] = None, fill_gap_with_zero: Optional[bool] = None, internal_metric_name: Optional[str] = None, **kwargs @@ -1157,8 +1159,8 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, - service_specification: Optional["ServiceSpecification"] = None, + display: Optional["_models.OperationDisplay"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -1249,7 +1251,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1557,7 +1559,7 @@ def __init__( resource_provider_name: Optional[str] = None, status: Optional[str] = None, sub_status: Optional[str] = None, - claims: Optional["RuleManagementEventClaimsDataSource"] = None, + claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, **kwargs ): """ @@ -1778,8 +1780,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, storage_account_id: Optional[str] = None, service_bus_rule_id: Optional[str] = None, - metrics: Optional[List["MetricSettings"]] = None, - logs: Optional[List["LogSettings"]] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, **kwargs ): @@ -1835,8 +1837,8 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, legacy_metric_specifications: Optional[Any] = None, **kwargs ): @@ -1923,8 +1925,8 @@ class ThresholdRuleCondition(RuleCondition): :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: Required. the operator used to compare the data and the threshold. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :ivar threshold: Required. the threshold value that activates the alert. :vartype threshold: float @@ -1933,8 +1935,8 @@ class ThresholdRuleCondition(RuleCondition): day. :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible - values include: "Average", "Minimum", "Maximum", "Total", "Last". + be combined over time. The default value is the PrimaryAggregationType of the Metric. Known + values are: "Average", "Minimum", "Maximum", "Total", "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ @@ -1957,19 +1959,19 @@ class ThresholdRuleCondition(RuleCondition): def __init__( self, *, - operator: Union[str, "ConditionOperator"], + operator: Union[str, "_models.ConditionOperator"], threshold: float, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, + time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, **kwargs ): """ :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 - :keyword operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: Required. the operator used to compare the data and the threshold. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator :keyword threshold: Required. the threshold value that activates the alert. :paramtype threshold: float @@ -1979,7 +1981,7 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py index 1404ed3e3916..90f2668aa444 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes how metric values are aggregated """ @@ -22,7 +21,7 @@ class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operators allowed in the rule condition. """ @@ -31,7 +30,7 @@ class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Aggregation operators allowed in a rule. """ @@ -41,7 +40,7 @@ class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) TOTAL = "Total" LAST = "Last" -class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 28c5041be1cd..aedf5ce120e4 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 @@ -11,9 +11,14 @@ from ._alert_rules_operations import AlertRulesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ServiceDiagnosticSettingsOperations', 'MetricDefinitionsOperations', 'AlertRulesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 c342da7320f6..dc434be726e7 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( rule_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2014-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2014-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,30 +196,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -222,62 +230,62 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2014-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AlertRulesOperations(object): - """AlertRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -286,18 +294,25 @@ def create_or_update( :type rule_name: str :param parameters: The parameters of the rule to create or update. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -305,14 +320,21 @@ def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,11 +353,11 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -347,28 +369,43 @@ def delete( :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2014-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,7 +416,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -388,35 +425,50 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -431,7 +483,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -439,9 +491,9 @@ def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -451,18 +503,25 @@ def update( :type rule_name: str :param alert_rules_resource: Parameters supplied to the operation. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -470,14 +529,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -496,7 +562,7 @@ def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -504,11 +570,14 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -516,31 +585,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -554,7 +634,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,15 +652,18 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. + :keyword api_version: Api Version. Default value is "2014-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) @@ -584,29 +671,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -620,7 +718,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,4 +736,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"} # type: ignore 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 7d7162b172aa..21816accc29e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2015-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricDefinitionsOperations(object): - """MetricDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,7 +89,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinitionCollection"]: + ) -> Iterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -98,8 +99,11 @@ def list( definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. + other syntax is allowed. Default value is None. :type filter: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) @@ -107,31 +111,42 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -145,7 +160,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,4 +178,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"} # type: ignore 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 40d3bd1ce1b5..828bd431cdff 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -28,75 +29,90 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2015-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Insights/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Insights/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.MonitorManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> "_models.OperationListResult": + ) -> _models.OperationListResult: """Lists all of the available operations from Microsoft.Insights provider. + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.OperationListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,5 +127,5 @@ def list( return deserialized - list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Insights/operations"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 d7ac22592e1b..18b59bf5b67e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -30,29 +30,31 @@ def build_get_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -60,94 +62,108 @@ def build_get_request( def build_create_or_update_request( resource_uri: str, *, - json: JSONType = None, + json: Optional[_models.ServiceDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2015-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ServiceDiagnosticSettingsOperations(object): - """ServiceDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ServiceDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2015_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2015_07_01.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( self, resource_uri: str, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. :type resource_uri: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,16 +178,16 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore @distributed_trace def create_or_update( self, resource_uri: str, - parameters: "_models.ServiceDiagnosticSettingsResource", + parameters: _models.ServiceDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -179,31 +195,45 @@ def create_or_update( :param parameters: Parameters supplied to the operation. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +247,5 @@ 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"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 3c5148998b74..e63c63a28c97 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-03-01" + 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) 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 8b98756e8957..0b1363b1cf1f 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 9c79236030cb..6698d1ccd66a 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -38,8 +39,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -56,15 +60,23 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.alert_rule_incidents = AlertRuleIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rule_incidents = AlertRuleIncidentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_profiles = LogProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 71d775201fb9..77ff113d679f 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-03-01" + 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) 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 acb5d7873254..903848c887db 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -39,8 +40,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -57,10 +61,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.alert_rule_incidents = AlertRuleIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rule_incidents = AlertRuleIncidentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alert_rules = AlertRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_profiles = LogProfilesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 ed7a68c9fa7e..1bd2ec16581f 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 @@ -11,9 +11,14 @@ from ._log_profiles_operations import LogProfilesOperations 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 patch_sdk as _patch_sdk __all__ = [ 'AlertRuleIncidentsOperations', 'AlertRulesOperations', 'LogProfilesOperations', 'MetricDefinitionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 898e4940c3f2..af9d2de4ac38 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertRuleIncidentsOperations: - """AlertRuleIncidentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.aio.MonitorManagementClient`'s + :attr:`alert_rule_incidents` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( rule_name: str, incident_name: str, **kwargs: Any - ) -> "_models.Incident": + ) -> _models.Incident: """Gets an incident associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,11 +65,16 @@ async def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.Incident :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Incident"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Incident] request = build_get_request( @@ -79,12 +82,19 @@ async def get( rule_name=rule_name, incident_name=incident_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,7 +109,7 @@ 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}"} # type: ignore @distributed_trace @@ -108,7 +118,7 @@ def list_by_alert_rule( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.IncidentListResult"]: + ) -> AsyncIterable[_models.IncidentListResult]: """Gets a list of incidents associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -121,11 +131,16 @@ def list_by_alert_rule( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IncidentListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -133,10 +148,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_alert_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -144,10 +162,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -161,7 +182,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,4 +199,4 @@ 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"} # type: ignore 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 5e191eff2dc5..4c296fb8706b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AlertRulesOperations: - """AlertRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.aio.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -81,14 +83,21 @@ async def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,11 +116,11 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -128,23 +137,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -155,7 +176,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -164,7 +185,7 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -176,23 +197,35 @@ async def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,7 +240,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -232,13 +265,17 @@ async def update( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -246,14 +283,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -272,7 +316,7 @@ async def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -280,7 +324,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -292,31 +336,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -330,7 +385,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,13 +403,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: + ) -> AsyncIterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -360,29 +419,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -396,7 +466,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,4 +484,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"} # type: ignore 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 6247251a07ec..48650b91bb7b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,29 +25,27 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogProfilesOperations: - """LogProfilesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.aio.MonitorManagementClient`'s + :attr:`log_profiles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, log_profile_name: str, **kwargs: Any @@ -61,22 +59,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,7 +96,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -94,7 +104,7 @@ async def get( self, log_profile_name: str, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Gets the log profile. :param log_profile_name: The name of the log profile. @@ -104,22 +114,34 @@ async def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] request = build_get_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,16 +156,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace_async async def create_or_update( self, log_profile_name: str, - parameters: "_models.LogProfileResource", + parameters: _models.LogProfileResource, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Create or update a log profile in Azure Monitoring REST API. :param log_profile_name: The name of the log profile. @@ -155,27 +177,38 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] _json = self._serialize.body(parameters, 'LogProfileResource') request = build_create_or_update_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,16 +222,16 @@ 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}"} # type: ignore @distributed_trace_async async def update( self, log_profile_name: str, - log_profiles_resource: "_models.LogProfileResourcePatch", + log_profiles_resource: _models.LogProfileResourcePatch, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. :param log_profile_name: The name of the log profile. @@ -211,27 +244,38 @@ async def update( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') request = build_update_request( subscription_id=self._config.subscription_id, log_profile_name=log_profile_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,14 +290,14 @@ 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.LogProfileCollection"]: + ) -> AsyncIterable[_models.LogProfileCollection]: """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response @@ -263,29 +307,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -299,7 +354,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,4 +371,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"} # type: ignore 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 f198e2f4c7b6..3a5abaff1ef4 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricDefinitionsOperations: - """MetricDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.aio.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +49,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinitionCollection"]: + ) -> AsyncIterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -62,7 +59,7 @@ def list( definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. + other syntax is allowed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of @@ -71,31 +68,42 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,4 +135,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 2b9edd288653..0b5ef4df0790 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 @@ -41,7 +41,9 @@ TimeAggregationOperator, Unit, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AlertRuleResource', 'AlertRuleResourceCollection', @@ -75,3 +77,5 @@ 'TimeAggregationOperator', 'Unit', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 abb472b8f34a..253a1f6d33eb 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Resource(msrest.serialization.Model): @@ -140,12 +142,12 @@ def __init__( location: str, name_properties_name: str, is_enabled: bool, - condition: "RuleCondition", + condition: "_models.RuleCondition", tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, provisioning_state: Optional[str] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -196,7 +198,7 @@ class AlertRuleResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["AlertRuleResource"]] = None, + value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs ): """ @@ -258,9 +260,9 @@ def __init__( description: Optional[str] = None, provisioning_state: Optional[str] = None, is_enabled: Optional[bool] = None, - condition: Optional["RuleCondition"] = None, - action: Optional["RuleAction"] = None, - actions: Optional[List["RuleAction"]] = None, + condition: Optional["_models.RuleCondition"] = None, + action: Optional["_models.RuleAction"] = None, + actions: Optional[List["_models.RuleAction"]] = None, **kwargs ): """ @@ -390,7 +392,7 @@ class IncidentListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Incident"]] = None, + value: Optional[List["_models.Incident"]] = None, **kwargs ): """ @@ -473,7 +475,7 @@ class RuleCondition(msrest.serialization.Model): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, **kwargs ): """ @@ -524,7 +526,7 @@ def __init__( self, *, failed_location_count: int, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): @@ -566,7 +568,7 @@ class LogProfileCollection(msrest.serialization.Model): def __init__( self, *, - value: List["LogProfileResource"], + value: List["_models.LogProfileResource"], **kwargs ): """ @@ -640,7 +642,7 @@ def __init__( location: str, locations: List[str], categories: List[str], - retention_policy: "RetentionPolicy", + retention_policy: "_models.RetentionPolicy", tags: Optional[Dict[str, str]] = None, storage_account_id: Optional[str] = None, service_bus_rule_id: Optional[str] = None, @@ -714,7 +716,7 @@ def __init__( service_bus_rule_id: Optional[str] = None, locations: Optional[List[str]] = None, categories: Optional[List[str]] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -748,8 +750,8 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :ivar operator: the condition operator. Possible values include: "GreaterThan", - "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :ivar threshold: The threshold value that activates the alert. :vartype threshold: float @@ -768,13 +770,13 @@ class ManagementEventAggregationCondition(msrest.serialization.Model): def __init__( self, *, - operator: Optional[Union[str, "ConditionOperator"]] = None, + operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, **kwargs ): """ - :keyword operator: the condition operator. Possible values include: "GreaterThan", + :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :keyword threshold: The threshold value that activates the alert. @@ -823,8 +825,8 @@ class ManagementEventRuleCondition(RuleCondition): def __init__( self, *, - data_source: Optional["RuleDataSource"] = None, - aggregation: Optional["ManagementEventAggregationCondition"] = None, + data_source: Optional["_models.RuleDataSource"] = None, + aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, **kwargs ): """ @@ -885,12 +887,12 @@ class MetricDefinition(msrest.serialization.Model): :vartype resource_id: str :ivar name: the name and the display name of the metric, i.e. it is a localizable string. :vartype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString - :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType @@ -915,10 +917,10 @@ def __init__( self, *, resource_id: Optional[str] = None, - name: Optional["LocalizableString"] = None, - unit: Optional[Union[str, "Unit"]] = None, - primary_aggregation_type: Optional[Union[str, "AggregationType"]] = None, - metric_availabilities: Optional[List["MetricAvailability"]] = None, + name: Optional["_models.LocalizableString"] = None, + unit: Optional[Union[str, "_models.Unit"]] = None, + primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, + metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, **kwargs ): @@ -927,12 +929,12 @@ def __init__( :paramtype resource_id: str :keyword name: the name and the display name of the metric, i.e. it is a localizable string. :paramtype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString - :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType @@ -972,7 +974,7 @@ class MetricDefinitionCollection(msrest.serialization.Model): def __init__( self, *, - value: List["MetricDefinition"], + value: List["_models.MetricDefinition"], **kwargs ): """ @@ -1276,7 +1278,7 @@ def __init__( resource_provider_name: Optional[str] = None, status: Optional[str] = None, sub_status: Optional[str] = None, - claims: Optional["RuleManagementEventClaimsDataSource"] = None, + claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, **kwargs ): """ @@ -1449,8 +1451,8 @@ class ThresholdRuleCondition(RuleCondition): :ivar data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :ivar operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: Required. the operator used to compare the data and the threshold. Known values + are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :ivar threshold: Required. the threshold value that activates the alert. :vartype threshold: float @@ -1459,8 +1461,8 @@ class ThresholdRuleCondition(RuleCondition): day. :vartype window_size: ~datetime.timedelta :ivar time_aggregation: the time aggregation operator. How the data that are collected should - be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible - values include: "Average", "Minimum", "Maximum", "Total", "Last". + be combined over time. The default value is the PrimaryAggregationType of the Metric. Known + values are: "Average", "Minimum", "Maximum", "Total", "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ @@ -1483,19 +1485,19 @@ class ThresholdRuleCondition(RuleCondition): def __init__( self, *, - operator: Union[str, "ConditionOperator"], + operator: Union[str, "_models.ConditionOperator"], threshold: float, - data_source: Optional["RuleDataSource"] = None, + data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, + time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, **kwargs ): """ :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 - :keyword operator: Required. the operator used to compare the data and the threshold. Possible - values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: Required. the operator used to compare the data and the threshold. Known + values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator :keyword threshold: Required. the threshold value that activates the alert. :paramtype threshold: float @@ -1505,7 +1507,7 @@ def __init__( :paramtype window_size: ~datetime.timedelta :keyword time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. - Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + Known values are: "Average", "Minimum", "Maximum", "Total", "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py index 46f418eaac30..41465c545753 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the primary aggregation type value defining how to use the values for display. """ @@ -22,7 +21,7 @@ class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operators allowed in the rule condition. """ @@ -31,7 +30,7 @@ class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Aggregation operators allowed in a rule. """ @@ -41,7 +40,7 @@ class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) TOTAL = "Total" LAST = "Last" -class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ed7a68c9fa7e..1bd2ec16581f 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 @@ -11,9 +11,14 @@ from ._log_profiles_operations import LogProfilesOperations 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 patch_sdk as _patch_sdk __all__ = [ 'AlertRuleIncidentsOperations', 'AlertRulesOperations', 'LogProfilesOperations', 'MetricDefinitionsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 cc3a151814d4..6c5a77ea1afe 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), @@ -44,21 +49,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,55 +72,55 @@ def build_list_by_alert_rule_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AlertRuleIncidentsOperations(object): - """AlertRuleIncidentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertRuleIncidentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.MonitorManagementClient`'s + :attr:`alert_rule_incidents` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -126,7 +129,7 @@ def get( rule_name: str, incident_name: str, **kwargs: Any - ) -> "_models.Incident": + ) -> _models.Incident: """Gets an incident associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -140,11 +143,16 @@ def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.Incident :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Incident"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Incident] request = build_get_request( @@ -152,12 +160,19 @@ def get( rule_name=rule_name, incident_name=incident_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,7 +187,7 @@ 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}"} # type: ignore @distributed_trace @@ -181,7 +196,7 @@ def list_by_alert_rule( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> Iterable["_models.IncidentListResult"]: + ) -> Iterable[_models.IncidentListResult]: """Gets a list of incidents associated to an alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -194,11 +209,16 @@ def list_by_alert_rule( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IncidentListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -206,10 +226,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_alert_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -217,10 +240,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, rule_name=rule_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -234,7 +260,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,4 +277,4 @@ 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"} # type: ignore 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 49c3be62dbb5..2dcb602b96d9 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( rule_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.AlertRuleResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,30 +196,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -222,62 +230,62 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AlertRulesOperations(object): - """AlertRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AlertRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.MonitorManagementClient`'s + :attr:`alert_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.AlertRuleResource", + parameters: _models.AlertRuleResource, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Creates or updates a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -291,13 +299,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(parameters, 'AlertRuleResource') @@ -305,14 +317,21 @@ def create_or_update( 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, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,11 +350,11 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -352,23 +371,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,7 +410,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -388,7 +419,7 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Gets a classic metric alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -400,23 +431,35 @@ def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -431,7 +474,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -439,9 +482,9 @@ def update( self, resource_group_name: str, rule_name: str, - alert_rules_resource: "_models.AlertRuleResourcePatch", + alert_rules_resource: _models.AlertRuleResourcePatch, **kwargs: Any - ) -> "_models.AlertRuleResource": + ) -> _models.AlertRuleResource: """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. @@ -456,13 +499,17 @@ def update( :rtype: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertRuleResource] _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') @@ -470,14 +517,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -496,7 +550,7 @@ def update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -504,7 +558,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -516,31 +570,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -554,7 +619,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -568,13 +637,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AlertRuleResourceCollection"]: + ) -> Iterable[_models.AlertRuleResourceCollection]: """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -584,29 +653,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -620,7 +700,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,4 +718,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"} # type: ignore 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 24b2cb6ff2ae..69225e50d950 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,24 +32,25 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long path_format_arguments = { "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -59,30 +60,32 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long path_format_arguments = { "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -91,38 +94,39 @@ def build_create_or_update_request( log_profile_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LogProfileResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long path_format_arguments = { "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,38 +137,39 @@ def build_update_request( subscription_id: str, log_profile_name: str, *, - json: JSONType = None, + json: Optional[_models.LogProfileResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,56 +180,56 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LogProfilesOperations(object): - """LogProfilesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.MonitorManagementClient`'s + :attr:`log_profiles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, log_profile_name: str, **kwargs: Any @@ -238,22 +243,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,7 +280,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -271,7 +288,7 @@ def get( self, log_profile_name: str, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Gets the log profile. :param log_profile_name: The name of the log profile. @@ -281,22 +298,34 @@ def get( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] request = build_get_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -311,16 +340,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore @distributed_trace def create_or_update( self, log_profile_name: str, - parameters: "_models.LogProfileResource", + parameters: _models.LogProfileResource, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Create or update a log profile in Azure Monitoring REST API. :param log_profile_name: The name of the log profile. @@ -332,27 +361,38 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] _json = self._serialize.body(parameters, 'LogProfileResource') request = build_create_or_update_request( log_profile_name=log_profile_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,16 +406,16 @@ 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}"} # type: ignore @distributed_trace def update( self, log_profile_name: str, - log_profiles_resource: "_models.LogProfileResourcePatch", + log_profiles_resource: _models.LogProfileResourcePatch, **kwargs: Any - ) -> "_models.LogProfileResource": + ) -> _models.LogProfileResource: """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. :param log_profile_name: The name of the log profile. @@ -388,27 +428,38 @@ def update( :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogProfileResource] _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') request = build_update_request( subscription_id=self._config.subscription_id, log_profile_name=log_profile_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -423,14 +474,14 @@ 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.LogProfileCollection"]: + ) -> Iterable[_models.LogProfileCollection]: """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response @@ -440,29 +491,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -476,7 +538,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -489,4 +555,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"} # type: ignore 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 0ff17e7e0de0..f37a7dec329b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2016-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricDefinitions') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricDefinitionsOperations(object): - """MetricDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_03_01.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,7 +89,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinitionCollection"]: + ) -> Iterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -98,7 +99,7 @@ def list( definition for the 'CPU percentage' counter: $filter=name.value eq '\Processor(_Total)\% Processor Time'.:code:`
`Multiple metrics can be retrieved by joining together *'name eq :code:``'* clauses separated by *or* logical operators.:code:`
`\ **NOTE**\ : No - other syntax is allowed. + other syntax is allowed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of @@ -107,31 +108,42 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -145,7 +157,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,4 +175,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 f5100df22e0e..3924ba7ecc21 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2016-09-01" + 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) 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 056ea76a8642..8445b275583e 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 fc61134de6fc..aafd3ed5e1ff 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: $(python-base-namespace).v2016_09_01.operations.ServiceDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -48,13 +52,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 e05030315578..459d9633f5bd 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2016-09-01" + 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) 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 fc77dcd16de0..13e3b6c545e9 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: $(python-base-namespace).v2016_09_01.aio.operations.ServiceDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -48,8 +52,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 5563e45b48c8..ac60aa87cb1b 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 @@ -9,7 +9,12 @@ from ._metrics_operations import MetricsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'MetricsOperations', 'ServiceDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f60892895603..af8931bc612c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricsOperations: - """MetricsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_09_01.aio.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +49,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricCollection"]: + ) -> AsyncIterable[_models.MetricCollection]: """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. @@ -74,7 +71,7 @@ def list( duration'PT1M'.:code:`
`:code:`
`\ **NOTE**\ : When a metrics query comes in with multiple metrics, but with no aggregation types defined, the service will pick the Primary aggregation type of the first metrics to be used as the default aggregation type for all the - metrics. + metrics. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricCollection or the result of cls(response) @@ -82,31 +79,42 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -120,7 +128,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -134,4 +146,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 39efc93f4a2c..a816976e3cfd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +23,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ServiceDiagnosticSettingsOperations: - """ServiceDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_09_01.aio.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( self, resource_uri: str, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. @@ -60,21 +58,33 @@ async def get( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -89,16 +99,16 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_uri: str, - parameters: "_models.ServiceDiagnosticSettingsResource", + parameters: _models.ServiceDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. @@ -112,26 +122,37 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,16 +166,16 @@ 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"} # type: ignore @distributed_trace_async async def update( self, resource_uri: str, - service_diagnostic_settings_resource: "_models.ServiceDiagnosticSettingsResourcePatch", + service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. @@ -168,26 +189,37 @@ async def update( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') request = build_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,5 +234,5 @@ 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"} # type: ignore 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 7e5d780d78e1..c4b18e16f22a 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 @@ -22,7 +22,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ErrorResponse', 'LocalizableString', @@ -37,3 +39,5 @@ 'ServiceDiagnosticSettingsResourcePatch', 'Unit', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 99a177ae114d..0a7ab91110d8 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorResponse(msrest.serialization.Model): @@ -115,7 +117,7 @@ def __init__( *, enabled: bool, category: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -146,9 +148,9 @@ class Metric(msrest.serialization.Model): :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. :vartype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :ivar unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit :ivar data: Required. Array of data points representing the metric values. :vartype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] @@ -171,9 +173,9 @@ class Metric(msrest.serialization.Model): def __init__( self, *, - name: "LocalizableString", - unit: Union[str, "Unit"], - data: List["MetricValue"], + name: "_models.LocalizableString", + unit: Union[str, "_models.Unit"], + data: List["_models.MetricValue"], id: Optional[str] = None, type: Optional[str] = None, **kwargs @@ -186,9 +188,9 @@ def __init__( :keyword name: Required. the name and the display name of the metric, i.e. it is localizable string. :paramtype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :keyword unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit :keyword data: Required. Array of data points representing the metric values. :paramtype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] @@ -221,7 +223,7 @@ class MetricCollection(msrest.serialization.Model): def __init__( self, *, - value: List["Metric"], + value: List["_models.Metric"], **kwargs ): """ @@ -261,7 +263,7 @@ def __init__( *, time_grain: datetime.timedelta, enabled: bool, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -508,8 +510,8 @@ def __init__( storage_account_id: Optional[str] = None, service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, - metrics: Optional[List["MetricSettings"]] = None, - logs: Optional[List["LogSettings"]] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, **kwargs ): @@ -588,8 +590,8 @@ def __init__( storage_account_id: Optional[str] = None, service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, - metrics: Optional[List["MetricSettings"]] = None, - logs: Optional[List["LogSettings"]] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, **kwargs ): diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py index 1b9cb5dfb067..25cb50eb3163 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 5563e45b48c8..ac60aa87cb1b 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 @@ -9,7 +9,12 @@ from ._metrics_operations import MetricsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'MetricsOperations', 'ServiceDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 1f7abb6576c3..5bbfe40cfb90 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2016-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metrics') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricsOperations(object): - """MetricsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_09_01.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,7 +89,7 @@ def list( resource_uri: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricCollection"]: + ) -> Iterable[_models.MetricCollection]: """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. @@ -110,7 +111,7 @@ def list( duration'PT1M'.:code:`
`:code:`
`\ **NOTE**\ : When a metrics query comes in with multiple metrics, but with no aggregation types defined, the service will pick the Primary aggregation type of the first metrics to be used as the default aggregation type for all the - metrics. + metrics. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricCollection or the result of cls(response) @@ -118,31 +119,42 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -156,7 +168,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 9c1f8097d6e3..a414a4865041 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -30,29 +30,31 @@ def build_get_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -60,37 +62,38 @@ def build_get_request( def build_create_or_update_request( resource_uri: str, *, - json: JSONType = None, + json: Optional[_models.ServiceDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -100,70 +103,69 @@ def build_create_or_update_request( def build_update_request( resource_uri: str, *, - json: JSONType = None, + json: Optional[_models.ServiceDiagnosticSettingsResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2016-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ServiceDiagnosticSettingsOperations(object): - """ServiceDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ServiceDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2016_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2016_09_01.MonitorManagementClient`'s + :attr:`service_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( self, resource_uri: str, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. @@ -174,21 +176,33 @@ def get( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,16 +217,16 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore @distributed_trace def create_or_update( self, resource_uri: str, - parameters: "_models.ServiceDiagnosticSettingsResource", + parameters: _models.ServiceDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. @@ -226,26 +240,37 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -259,16 +284,16 @@ 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"} # type: ignore @distributed_trace def update( self, resource_uri: str, - service_diagnostic_settings_resource: "_models.ServiceDiagnosticSettingsResourcePatch", + service_diagnostic_settings_resource: _models.ServiceDiagnosticSettingsResourcePatch, **kwargs: Any - ) -> "_models.ServiceDiagnosticSettingsResource": + ) -> _models.ServiceDiagnosticSettingsResource: """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. @@ -282,26 +307,37 @@ def update( :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') request = build_update_request( resource_uri=resource_uri, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -316,5 +352,5 @@ def update( return deserialized - update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 23b544c587c2..f80855d96408 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-03-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**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 877e90f7a5f9..0c766a2666c3 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 2fff9a7767ce..00f2d4308077 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,12 +53,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 79386b6bd350..93dde4d32098 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-03-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**kwargs) 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 ffe1322a32a4..f8e709eefadc 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 93b3b50f2d76..26aff77830bf 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 d040201f8eea..56c7341496ef 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActivityLogAlertsOperations: - """ActivityLogAlertsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_03_01_preview.aio.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: "_models.ActivityLogAlertResource", + activity_log_alert: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,13 +66,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') @@ -82,14 +84,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,7 +117,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -117,7 +126,7 @@ async def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,23 +138,35 @@ async def get( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,11 +181,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -181,23 +202,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -208,7 +241,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -216,9 +249,9 @@ async def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_patch: "_models.ActivityLogAlertResourcePatch", + activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. @@ -234,13 +267,17 @@ async def update( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') @@ -248,14 +285,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,14 +314,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertList"]: + ) -> AsyncIterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -287,29 +331,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -323,7 +378,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -337,14 +396,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertList"]: + ) -> AsyncIterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -356,31 +415,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -394,7 +464,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,4 +482,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 528346189f70..bce8f3aac60e 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,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogAlertActionGroup', 'ActivityLogAlertActionList', @@ -28,3 +30,5 @@ 'ErrorResponse', 'Resource', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 42196378038c..8f74a6dfbdfd 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ActivityLogAlertActionGroup(msrest.serialization.Model): """A pointer to an Azure Action Group. @@ -69,7 +73,7 @@ class ActivityLogAlertActionList(msrest.serialization.Model): def __init__( self, *, - action_groups: Optional[List["ActivityLogAlertActionGroup"]] = None, + action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs ): """ @@ -102,7 +106,7 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): def __init__( self, *, - all_of: List["ActivityLogAlertLeafCondition"], + all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs ): """ @@ -176,7 +180,7 @@ class ActivityLogAlertList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActivityLogAlertResource"]] = None, + value: Optional[List["_models.ActivityLogAlertResource"]] = None, **kwargs ): """ @@ -304,8 +308,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, enabled: Optional[bool] = True, - condition: Optional["ActivityLogAlertAllOfCondition"] = None, - actions: Optional["ActivityLogAlertActionList"] = None, + condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, + actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, **kwargs ): diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 93b3b50f2d76..26aff77830bf 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 70048fb8511e..f0171f2e62bc 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.ActivityLogAlertResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.ActivityLogAlertResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,63 +229,63 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ActivityLogAlertsOperations(object): - """ActivityLogAlertsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActivityLogAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_03_01_preview.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: "_models.ActivityLogAlertResource", + activity_log_alert: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -292,13 +300,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') @@ -306,14 +318,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +351,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -341,7 +360,7 @@ def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,23 +372,35 @@ def get( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,11 +415,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -405,23 +436,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -432,7 +475,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -440,9 +483,9 @@ def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_patch: "_models.ActivityLogAlertResourcePatch", + activity_log_alert_patch: _models.ActivityLogAlertResourcePatch, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. @@ -458,13 +501,17 @@ def update( :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') @@ -472,14 +519,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -494,14 +548,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertList"]: + ) -> Iterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -511,29 +565,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -547,7 +612,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -561,14 +630,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertList"]: + ) -> Iterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -580,31 +649,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -618,7 +698,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -632,4 +716,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 1723a0c2143e..8c6bdb7fc024 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + 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) 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 93b8dd8db876..52b385c18990 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 2a3235194c0f..0923ad540488 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -33,8 +34,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -51,13 +55,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 9d93745c9a82..fd655e4fe02e 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-04-01" + 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) 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 e74e70f31cff..4ae19e8ff5b1 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -34,8 +35,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -52,8 +56,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 f8d34639d441..a576a3f19772 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 @@ -9,7 +9,12 @@ from ._action_groups_operations import ActionGroupsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 6d47fbde7702..fb812882f0b6 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_04_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -81,14 +83,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -231,13 +264,17 @@ async def update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -245,14 +282,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,14 +311,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -283,29 +327,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,7 +374,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,14 +392,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -351,31 +410,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +459,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,14 +477,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -427,13 +501,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -441,14 +519,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -459,5 +544,5 @@ async def enable_receiver( 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"} # type: ignore 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 80e66fb77d49..5199b42061ee 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActivityLogAlertsOperations: - """ActivityLogAlertsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_04_01.aio.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: "_models.ActivityLogAlertResource", + activity_log_alert: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') @@ -81,14 +83,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_patch: "_models.ActivityLogAlertPatchBody", + activity_log_alert_patch: _models.ActivityLogAlertPatchBody, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. @@ -233,13 +266,17 @@ async def update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') @@ -247,14 +284,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -269,14 +313,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertList"]: + ) -> AsyncIterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -286,29 +330,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -322,7 +377,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,14 +395,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActivityLogAlertList"]: + ) -> AsyncIterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -355,31 +414,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +463,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,4 +481,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 52785b077363..e2685936e57c 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 @@ -30,7 +30,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupList', 'ActionGroupPatchBody', @@ -53,3 +55,5 @@ 'WebhookReceiver', 'ReceiverStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 92b25077d832..ef82554e4dce 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ActionGroupList(msrest.serialization.Model): """A list of action groups. @@ -29,7 +33,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -204,12 +208,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + 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 ): """ @@ -309,7 +313,7 @@ class ActivityLogAlertActionList(msrest.serialization.Model): def __init__( self, *, - action_groups: Optional[List["ActivityLogAlertActionGroup"]] = None, + action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs ): """ @@ -342,7 +346,7 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): def __init__( self, *, - all_of: List["ActivityLogAlertLeafCondition"], + all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs ): """ @@ -418,7 +422,7 @@ class ActivityLogAlertList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActivityLogAlertResource"]] = None, + value: Optional[List["_models.ActivityLogAlertResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -526,8 +530,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, enabled: Optional[bool] = True, - condition: Optional["ActivityLogAlertAllOfCondition"] = None, - actions: Optional["ActivityLogAlertActionList"] = None, + condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, + actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, **kwargs ): @@ -683,8 +687,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype name: str :ivar email_address: Required. The email address of this receiver. :vartype email_address: str - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus """ @@ -868,7 +872,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py index 5e8a759db49c..2502d854d186 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 f8d34639d441..a576a3f19772 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 @@ -9,7 +9,12 @@ from ._action_groups_operations import ActionGroupsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 2b3f1dc57e9f..15f309343ff3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,30 +229,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -254,74 +264,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_04_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -335,13 +344,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -349,14 +362,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -375,7 +395,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -384,7 +404,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -396,23 +416,35 @@ def get( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +459,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -448,23 +480,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,7 +519,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -483,9 +527,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -499,13 +543,17 @@ def update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -513,14 +561,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,14 +590,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -551,29 +606,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,7 +653,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,14 +671,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -619,31 +689,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -657,7 +738,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -671,14 +756,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -695,13 +780,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -709,14 +798,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -727,5 +823,5 @@ def enable_receiver( 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"} # type: ignore 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 d465ef64e4bd..db14becba5f9 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.ActivityLogAlertResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.ActivityLogAlertPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,63 +229,63 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ActivityLogAlertsOperations(object): - """ActivityLogAlertsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActivityLogAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_04_01.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert: "_models.ActivityLogAlertResource", + activity_log_alert: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new activity log alert or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -291,13 +299,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') @@ -305,14 +317,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -331,7 +350,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -340,7 +359,7 @@ def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an activity log alert. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -352,23 +371,35 @@ def get( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -383,11 +414,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -404,23 +435,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -431,7 +474,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -439,9 +482,9 @@ def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_patch: "_models.ActivityLogAlertPatchBody", + activity_log_alert_patch: _models.ActivityLogAlertPatchBody, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. @@ -457,13 +500,17 @@ def update( :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') @@ -471,14 +518,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -493,14 +547,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertList"]: + ) -> Iterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -510,29 +564,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +611,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -560,14 +629,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActivityLogAlertList"]: + ) -> Iterable[_models.ActivityLogAlertList]: """Get a list of all activity log alerts in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -579,31 +648,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,7 +697,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,4 +715,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 adb04d3afc9e..f0b9640c35c9 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-05-01-preview" + 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) 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 0f3d571414fa..02a0a3071b81 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 747a5873d2a3..40064fbf7070 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -42,8 +43,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -60,16 +64,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 ac5e4fab2ece..2ffbaa6983ff 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-05-01-preview" + 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) 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 e5c199e8f47c..bae3402af43e 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -42,8 +43,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -60,11 +64,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 615dffaaf0a7..01b52d1d4e00 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 @@ -12,6 +12,9 @@ from ._metrics_operations import MetricsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DiagnosticSettingsCategoryOperations', 'DiagnosticSettingsOperations', @@ -19,3 +22,5 @@ 'MetricsOperations', 'SubscriptionDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 cafab6b4b88b..32070cbc9f19 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiagnosticSettingsCategoryOperations: - """DiagnosticSettingsCategoryOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -50,7 +48,7 @@ async def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResource": + ) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -62,22 +60,34 @@ async def get( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,7 +102,7 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace_async @@ -100,7 +110,7 @@ async def list( self, resource_uri: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResourceCollection": + ) -> _models.DiagnosticSettingsCategoryResourceCollection: """Lists the diagnostic settings categories for the specified resource. :param resource_uri: The identifier of the resource. @@ -111,21 +121,33 @@ async def list( ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,5 +162,5 @@ async def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore 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 f57b4c4dd0a9..89ad8c46ef42 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiagnosticSettingsOperations: - """DiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -50,7 +48,7 @@ async def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -62,22 +60,34 @@ async def get( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,7 +102,7 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async @@ -100,9 +110,9 @@ async def create_or_update( self, resource_uri: str, name: str, - parameters: "_models.DiagnosticSettingsResource", + parameters: _models.DiagnosticSettingsResource, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -117,27 +127,38 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,11 +173,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, name: str, @@ -173,22 +194,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -199,7 +232,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -207,7 +240,7 @@ async def list( self, resource_uri: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResourceCollection": + ) -> _models.DiagnosticSettingsResourceCollection: """Gets the active diagnostic settings list for the specified resource. :param resource_uri: The identifier of the resource. @@ -218,21 +251,33 @@ async def list( ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,5 +292,5 @@ async def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore 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 ca5ce67eba08..0b5422b19f9f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricDefinitionsOperations: - """MetricDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.aio.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinitionCollection"]: + ) -> AsyncIterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -63,29 +60,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -99,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,4 +125,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"} # type: ignore 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 7e03d1199249..266c872fc49b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,15 +7,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -24,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricsOperations: - """MetricsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.aio.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -58,27 +56,28 @@ async def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> "_models.Response": + ) -> _models.Response: """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta - :param metric: The name of the metric to retrieve. + :param metric: The name of the metric to retrieve. Default value is None. :type metric: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str :param top: The maximum number of records to retrieve. Valid only if $filter is specified. - Defaults to 10. + Defaults to 10. Default value is None. :type top: int :param orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. - Examples: sum asc. + Examples: sum asc. Default value is None. :type orderby: str :param filter: The **$filter** is used to reduce the set of metric data returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- @@ -88,25 +87,31 @@ async def list( logical or operator cannot separate two different metadata names.:code:`
`- Return all time series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. + B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. + operation. See the operation's description for details. Default value is None. :type result_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response :return: Response, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.Response :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Response"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, timespan=timespan, interval=interval, metric=metric, @@ -116,11 +121,17 @@ async def list( filter=filter, result_type=result_type, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -135,5 +146,5 @@ async def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/metrics'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 4b0c9ac8f0f1..f7f3a3769072 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +23,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionDiagnosticSettingsOperations: - """SubscriptionDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.aio.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( self, name: str, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -60,22 +58,34 @@ async def get( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] request = build_get_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -90,16 +100,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def create_or_update( self, name: str, - parameters: "_models.SubscriptionDiagnosticSettingsResource", + parameters: _models.SubscriptionDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -113,27 +123,38 @@ async def create_or_update( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') request = build_create_or_update_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,11 +169,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, name: str, **kwargs: Any @@ -166,22 +187,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -192,14 +225,14 @@ async def delete( 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}"} # type: ignore @distributed_trace_async async def list( self, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResourceCollection": + ) -> _models.SubscriptionDiagnosticSettingsResourceCollection: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response @@ -208,21 +241,33 @@ async def list( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,5 +282,5 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore 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 e41ba32b99f7..a0d8d31ee25b 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 @@ -36,7 +36,9 @@ ResultType, Unit, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DiagnosticSettingsCategoryResource', 'DiagnosticSettingsCategoryResourceCollection', @@ -65,3 +67,5 @@ 'ResultType', 'Unit', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 5e7f0b6cacbc..7883498202d0 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ProxyOnlyResource(msrest.serialization.Model): @@ -63,8 +65,8 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar category_type: The type of the diagnostic settings category. Possible values include: - "Metrics", "Logs". + :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics", + "Logs". :vartype category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType """ @@ -85,11 +87,11 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): def __init__( self, *, - category_type: Optional[Union[str, "CategoryType"]] = None, + category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs ): """ - :keyword category_type: The type of the diagnostic settings category. Possible values include: + :keyword category_type: The type of the diagnostic settings category. Known values are: "Metrics", "Logs". :paramtype category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType @@ -113,7 +115,7 @@ class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DiagnosticSettingsCategoryResource"]] = None, + value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs ): """ @@ -189,8 +191,8 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - metrics: Optional[List["MetricSettings"]] = None, - logs: Optional[List["LogSettings"]] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, log_analytics_destination_type: Optional[str] = None, **kwargs @@ -247,7 +249,7 @@ class DiagnosticSettingsResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DiagnosticSettingsResource"]] = None, + value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs ): """ @@ -359,7 +361,7 @@ def __init__( *, enabled: bool, category: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -396,7 +398,7 @@ class MetadataValue(msrest.serialization.Model): def __init__( self, *, - name: Optional["LocalizableString"] = None, + name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs ): @@ -429,9 +431,9 @@ class Metric(msrest.serialization.Model): :vartype error_code: str :ivar error_message: Error message encountered querying this specific metric. :vartype error_message: str - :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :ivar unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :ivar timeseries: Required. the time series returned when a data query is performed. :vartype timeseries: @@ -462,9 +464,9 @@ def __init__( *, id: str, type: str, - name: "LocalizableString", - unit: Union[str, "Unit"], - timeseries: List["TimeSeriesElement"], + name: "_models.LocalizableString", + unit: Union[str, "_models.Unit"], + timeseries: List["_models.TimeSeriesElement"], display_description: Optional[str] = None, error_code: Optional[str] = None, error_message: Optional[str] = None, @@ -484,9 +486,9 @@ def __init__( :paramtype error_code: str :keyword error_message: Error message encountered querying this specific metric. :paramtype error_message: str - :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :keyword unit: Required. the unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :keyword timeseries: Required. the time series returned when a data query is performed. :paramtype timeseries: @@ -552,12 +554,12 @@ class MetricDefinition(msrest.serialization.Model): :vartype display_description: str :ivar category: Custom category name for this metric. :vartype category: str - :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType @@ -591,14 +593,14 @@ def __init__( *, is_dimension_required: Optional[bool] = None, resource_id: Optional[str] = None, - name: Optional["LocalizableString"] = None, + name: Optional["_models.LocalizableString"] = None, display_description: Optional[str] = None, category: Optional[str] = None, - unit: Optional[Union[str, "Unit"]] = None, - primary_aggregation_type: Optional[Union[str, "AggregationType"]] = None, - metric_availabilities: Optional[List["MetricAvailability"]] = None, + unit: Optional[Union[str, "_models.Unit"]] = None, + primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, + metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, - dimensions: Optional[List["LocalizableString"]] = None, + dimensions: Optional[List["_models.LocalizableString"]] = None, **kwargs ): """ @@ -612,12 +614,12 @@ def __init__( :paramtype display_description: str :keyword category: Custom category name for this metric. :paramtype category: str - :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :keyword unit: the unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType @@ -665,7 +667,7 @@ class MetricDefinitionCollection(msrest.serialization.Model): def __init__( self, *, - value: List["MetricDefinition"], + value: List["_models.MetricDefinition"], **kwargs ): """ @@ -710,7 +712,7 @@ def __init__( enabled: bool, time_grain: Optional[datetime.timedelta] = None, category: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -837,7 +839,7 @@ def __init__( self, *, timespan: str, - value: List["Metric"], + value: List["_models.Metric"], cost: Optional[int] = None, interval: Optional[datetime.timedelta] = None, **kwargs @@ -1009,7 +1011,7 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - logs: Optional[List["SubscriptionLogSettings"]] = None, + logs: Optional[List["_models.SubscriptionLogSettings"]] = None, workspace_id: Optional[str] = None, **kwargs ): @@ -1059,7 +1061,7 @@ class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Mode def __init__( self, *, - value: Optional[List["SubscriptionDiagnosticSettingsResource"]] = None, + value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs ): """ @@ -1130,8 +1132,8 @@ class TimeSeriesElement(msrest.serialization.Model): def __init__( self, *, - metadatavalues: Optional[List["MetadataValue"]] = None, - data: Optional[List["MetricValue"]] = None, + metadatavalues: Optional[List["_models.MetadataValue"]] = None, + data: Optional[List["_models.MetricValue"]] = None, **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py index 4e17f31bcd8c..e0b68ed9e799 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the primary aggregation type value defining how to use the values for display. """ @@ -22,19 +21,19 @@ class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the diagnostic settings category. """ METRICS = "Metrics" LOGS = "Logs" -class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DATA = "Data" METADATA = "Metadata" -class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Unit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 615dffaaf0a7..01b52d1d4e00 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 @@ -12,6 +12,9 @@ from ._metrics_operations import MetricsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DiagnosticSettingsCategoryOperations', 'DiagnosticSettingsOperations', @@ -19,3 +22,5 @@ 'MetricsOperations', 'SubscriptionDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 6a6819601998..7674e5ae9dfc 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,30 +31,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -62,53 +65,53 @@ def build_list_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DiagnosticSettingsCategoryOperations(object): - """DiagnosticSettingsCategoryOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticSettingsCategoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -116,7 +119,7 @@ def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResource": + ) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -128,22 +131,34 @@ def get( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -158,7 +173,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace @@ -166,7 +181,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResourceCollection": + ) -> _models.DiagnosticSettingsCategoryResourceCollection: """Lists the diagnostic settings categories for the specified resource. :param resource_uri: The identifier of the resource. @@ -177,21 +192,33 @@ def list( ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -206,5 +233,5 @@ def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore 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 537aa0d67b93..12a10c2c972b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,30 +31,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,38 +65,39 @@ def build_create_or_update_request( resource_uri: str, name: str, *, - json: JSONType = None, + json: Optional[_models.DiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -106,30 +109,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -138,53 +143,53 @@ def build_list_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DiagnosticSettingsOperations(object): - """DiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -192,7 +197,7 @@ def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -204,22 +209,34 @@ def get( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -234,7 +251,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace @@ -242,9 +259,9 @@ def create_or_update( self, resource_uri: str, name: str, - parameters: "_models.DiagnosticSettingsResource", + parameters: _models.DiagnosticSettingsResource, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -259,27 +276,38 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -294,11 +322,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, name: str, @@ -315,22 +343,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -341,7 +381,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -349,7 +389,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResourceCollection": + ) -> _models.DiagnosticSettingsResourceCollection: """Gets the active diagnostic settings list for the specified resource. :param resource_uri: The identifier of the resource. @@ -360,21 +400,33 @@ def list( ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,5 +441,5 @@ def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore 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 c836a6bd1441..0cb26dc2584a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,60 +31,60 @@ def build_list_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricDefinitions') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricDefinitions") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricDefinitionsOperations(object): - """MetricDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.MetricDefinitionCollection"]: + ) -> Iterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -95,29 +96,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +143,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,4 +161,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"} # type: ignore 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 6fe2455241b8..208a7bd5d1fe 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -39,69 +40,69 @@ def build_list_request( result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metrics') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metrics") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') if metric is not None: - query_parameters['metric'] = _SERIALIZER.query("metric", metric, 'str') + _params['metric'] = _SERIALIZER.query("metric", metric, 'str') if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricsOperations(object): - """MetricsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -116,27 +117,28 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> "_models.Response": + ) -> _models.Response: """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta - :param metric: The name of the metric to retrieve. + :param metric: The name of the metric to retrieve. Default value is None. :type metric: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str :param top: The maximum number of records to retrieve. Valid only if $filter is specified. - Defaults to 10. + Defaults to 10. Default value is None. :type top: int :param orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. - Examples: sum asc. + Examples: sum asc. Default value is None. :type orderby: str :param filter: The **$filter** is used to reduce the set of metric data returned.:code:`
`Example::code:`
`Metric contains metadata A, B and C.:code:`
`- @@ -146,25 +148,31 @@ def list( logical or operator cannot separate two different metadata names.:code:`
`- Return all time series where A = a1, B = b1 and C = c1::code:`
`\ **$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**\ :code:`
`- Return all time series where A = a1:code:`
`\ **$filter=A eq ‘a1’ and - B eq ‘\ *’ and C eq ‘*\ ’**. + B eq ‘\ *’ and C eq ‘*\ ’**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. + operation. See the operation's description for details. Default value is None. :type result_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response :return: Response, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.Response :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Response"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, timespan=timespan, interval=interval, metric=metric, @@ -174,11 +182,17 @@ def list( filter=filter, result_type=result_type, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -193,5 +207,5 @@ def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/metrics'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 89e7e61db03f..4ba47a5f7a2c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,30 +31,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,38 +65,39 @@ def build_create_or_update_request( subscription_id: str, name: str, *, - json: JSONType = None, + json: Optional[_models.SubscriptionDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2017-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -106,30 +109,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -138,60 +143,60 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionDiagnosticSettingsOperations(object): - """SubscriptionDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_05_01_preview.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( self, name: str, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -202,22 +207,34 @@ def get( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] request = build_get_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,16 +249,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def create_or_update( self, name: str, - parameters: "_models.SubscriptionDiagnosticSettingsResource", + parameters: _models.SubscriptionDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -255,27 +272,38 @@ def create_or_update( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') request = build_create_or_update_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -290,11 +318,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, name: str, **kwargs: Any @@ -308,22 +336,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -334,14 +374,14 @@ def delete( 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResourceCollection": + ) -> _models.SubscriptionDiagnosticSettingsResourceCollection: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response @@ -350,21 +390,33 @@ def list( ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,5 +431,5 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py deleted file mode 100644 index 74e48ecd07cf..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- - -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -def patch_sdk(): - pass \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py deleted file mode 100644 index 74e48ecd07cf..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py +++ /dev/null @@ -1,31 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- - -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -def patch_sdk(): - pass \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py deleted file mode 100644 index c8caf0224f93..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_baseline_operations import build_calculate_baseline_request, build_get_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MetricBaselineOperations: - """MetricBaselineOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace_async - async def get( - self, - resource_uri: str, - metric_name: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a specific metric**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metric_name: The name of the metric to retrieve the baseline for. - :type metric_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2017_11_01_preview.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metric_name=metric_name, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore - - - @distributed_trace_async - async def calculate_baseline( - self, - resource_uri: str, - time_series_information: "_models.TimeSeriesInformation", - **kwargs: Any - ) -> "_models.CalculateBaselineResponse": - """**Lists the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param time_series_information: Information that need to be specified to calculate a baseline - on a time series. - :type time_series_information: - ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CalculateBaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.CalculateBaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateBaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - - request = build_calculate_baseline_request( - resource_uri=resource_uri, - content_type=content_type, - json=_json, - template_url=self.calculate_baseline.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore - diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py deleted file mode 100644 index 5ed46c55c546..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._models_py3 import Baseline -from ._models_py3 import BaselineMetadataValue -from ._models_py3 import BaselineResponse -from ._models_py3 import CalculateBaselineResponse -from ._models_py3 import ErrorResponse -from ._models_py3 import LocalizableString -from ._models_py3 import TimeSeriesInformation - - -from ._monitor_management_client_enums import ( - ResultType, - Sensitivity, -) - -__all__ = [ - 'Baseline', - 'BaselineMetadataValue', - 'BaselineResponse', - 'CalculateBaselineResponse', - 'ErrorResponse', - 'LocalizableString', - 'TimeSeriesInformation', - 'ResultType', - 'Sensitivity', -] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py deleted file mode 100644 index ddf9d5c536cf..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py +++ /dev/null @@ -1,355 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import List, Optional, Union - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - -from ._monitor_management_client_enums import * - - -class Baseline(msrest.serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", - "Medium", "High". - :vartype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity - :ivar low_thresholds: Required. The low thresholds of the baseline. - :vartype low_thresholds: list[float] - :ivar high_thresholds: Required. The high thresholds of the baseline. - :vartype high_thresholds: list[float] - :ivar timestamps: the array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - """ - - _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, - } - - _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - *, - sensitivity: Union[str, "Sensitivity"], - low_thresholds: List[float], - high_thresholds: List[float], - timestamps: Optional[List[datetime.datetime]] = None, - **kwargs - ): - """ - :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: - "Low", "Medium", "High". - :paramtype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity - :keyword low_thresholds: Required. The low thresholds of the baseline. - :paramtype low_thresholds: list[float] - :keyword high_thresholds: Required. The high thresholds of the baseline. - :paramtype high_thresholds: list[float] - :keyword timestamps: the array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - """ - super(Baseline, self).__init__(**kwargs) - self.sensitivity = sensitivity - self.low_thresholds = low_thresholds - self.high_thresholds = high_thresholds - self.timestamps = timestamps - - -class BaselineMetadataValue(msrest.serialization.Model): - """Represents a baseline metadata value. - - :ivar name: the name of the metadata. - :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :ivar value: the value of the metadata. - :vartype value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional["LocalizableString"] = None, - value: Optional[str] = None, - **kwargs - ): - """ - :keyword name: the name of the metadata. - :paramtype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :keyword value: the value of the metadata. - :paramtype value: str - """ - super(BaselineMetadataValue, self).__init__(**kwargs) - self.name = name - self.value = value - - -class BaselineResponse(msrest.serialization.Model): - """The response to a baseline query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: the metric baseline Id. - :vartype id: str - :ivar type: the resource type of the baseline resource. - :vartype type: str - :ivar name: the name and the display name of the metric, i.e. it is localizable string. - :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :ivar 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 - from what was originally requested. - :vartype timespan: str - :ivar interval: The interval (window size) for which the metric data was returned in. This may - be adjusted in the future and returned back from what was originally requested. This is not - present if a metadata request was made. - :vartype interval: ~datetime.timedelta - :ivar aggregation: The aggregation type of the metric. - :vartype aggregation: str - :ivar timestamps: the array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - :ivar baseline: the baseline values for each sensitivity. - :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - :ivar metadata: the baseline metadata values. - :vartype metadata: - list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, - 'timestamps': {'key': 'properties.timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'properties.baseline', 'type': '[Baseline]'}, - 'metadata': {'key': 'properties.metadata', 'type': '[BaselineMetadataValue]'}, - } - - def __init__( - self, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - timestamps: Optional[List[datetime.datetime]] = None, - baseline: Optional[List["Baseline"]] = None, - metadata: Optional[List["BaselineMetadataValue"]] = None, - **kwargs - ): - """ - :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 - from what was originally requested. - :paramtype timespan: str - :keyword interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :paramtype interval: ~datetime.timedelta - :keyword aggregation: The aggregation type of the metric. - :paramtype aggregation: str - :keyword timestamps: the array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - :keyword baseline: the baseline values for each sensitivity. - :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - :keyword metadata: the baseline metadata values. - :paramtype metadata: - list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] - """ - super(BaselineResponse, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.timespan = timespan - self.interval = interval - self.aggregation = aggregation - self.timestamps = timestamps - self.baseline = baseline - self.metadata = metadata - - -class CalculateBaselineResponse(msrest.serialization.Model): - """The response to a calculate baseline call. - - All required parameters must be populated in order to send to Azure. - - :ivar type: Required. the resource type of the baseline resource. - :vartype type: str - :ivar timestamps: the array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - :ivar baseline: Required. the baseline values for each sensitivity. - :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - """ - - _validation = { - 'type': {'required': True}, - 'baseline': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, - } - - def __init__( - self, - *, - type: str, - baseline: List["Baseline"], - timestamps: Optional[List[datetime.datetime]] = None, - **kwargs - ): - """ - :keyword type: Required. the resource type of the baseline resource. - :paramtype type: str - :keyword timestamps: the array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - :keyword baseline: Required. the baseline values for each sensitivity. - :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - """ - super(CalculateBaselineResponse, self).__init__(**kwargs) - self.type = type - self.timestamps = timestamps - self.baseline = baseline - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ - super(ErrorResponse, self).__init__(**kwargs) - self.code = code - self.message = message - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: Required. the invariant value. - :vartype value: str - :ivar localized_value: the locale specific value. - :vartype localized_value: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): - """ - :keyword value: Required. the invariant value. - :paramtype value: str - :keyword localized_value: the locale specific value. - :paramtype localized_value: str - """ - super(LocalizableString, self).__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class TimeSeriesInformation(msrest.serialization.Model): - """The time series info needed for calculating the baseline. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivities: Required. the list of sensitivities for calculating the baseline. - :vartype sensitivities: list[str] - :ivar values: Required. The metric values to calculate the baseline. - :vartype values: list[float] - :ivar timestamps: the array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - """ - - _validation = { - 'sensitivities': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'sensitivities': {'key': 'sensitivities', 'type': '[str]'}, - 'values': {'key': 'values', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - *, - sensitivities: List[str], - values: List[float], - timestamps: Optional[List[datetime.datetime]] = None, - **kwargs - ): - """ - :keyword sensitivities: Required. the list of sensitivities for calculating the baseline. - :paramtype sensitivities: list[str] - :keyword values: Required. The metric values to calculate the baseline. - :paramtype values: list[float] - :keyword timestamps: the array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - """ - super(TimeSeriesInformation, self).__init__(**kwargs) - self.sensitivities = sensitivities - self.values = values - self.timestamps = timestamps diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py deleted file mode 100644 index 872dfcde5bca..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py +++ /dev/null @@ -1,274 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer - -from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - -def build_get_request( - resource_uri: str, - metric_name: str, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - **kwargs: Any -) -> HttpRequest: - api_version = "2017-11-01-preview" - accept = "application/json" - # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}') - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "metricName": _SERIALIZER.url("metric_name", metric_name, 'str'), - } - - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_calculate_baseline_request( - resource_uri: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - api_version = "2017-11-01-preview" - accept = "application/json" - # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline') - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class MetricBaselineOperations(object): - """MetricBaselineOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace - def get( - self, - resource_uri: str, - metric_name: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a specific metric**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metric_name: The name of the metric to retrieve the baseline for. - :type metric_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2017_11_01_preview.models.ResultType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metric_name=metric_name, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore - - - @distributed_trace - def calculate_baseline( - self, - resource_uri: str, - time_series_information: "_models.TimeSeriesInformation", - **kwargs: Any - ) -> "_models.CalculateBaselineResponse": - """**Lists the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param time_series_information: Information that need to be specified to calculate a baseline - on a time series. - :type time_series_information: - ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CalculateBaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.CalculateBaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateBaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - - request = build_calculate_baseline_request( - resource_uri=resource_uri, - content_type=content_type, - json=_json, - template_url=self.calculate_baseline.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore - 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 e6aeff663d71..c74500c3adc6 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-12-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2017-12-01-preview" + 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) 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 18bc077c7cd8..847e5716bee0 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 c477802680d4..dec4ac466f00 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -29,8 +30,11 @@ class MonitorManagementClient: $(python-base-namespace).v2017_12_01_preview.operations.MetricNamespacesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -46,12 +50,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metric_namespaces = MetricNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_namespaces = MetricNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 cf4b6135bb51..0298239a6810 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-12-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2017-12-01-preview" + 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) 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 da77ac77c9fa..e6fc42918449 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -29,8 +30,11 @@ class MonitorManagementClient: $(python-base-namespace).v2017_12_01_preview.aio.operations.MetricNamespacesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -46,7 +50,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metric_namespaces = MetricNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_namespaces = MetricNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 a4430969ab2b..680cb8018ae1 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'MetricNamespacesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f58ee93aa86d..d8a6db5a974d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricNamespacesOperations: - """MetricNamespacesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_12_01_preview.aio.MonitorManagementClient`'s + :attr:`metric_namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,13 +49,13 @@ def list( resource_uri: str, start_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricNamespaceCollection"]: + ) -> AsyncIterable[_models.MetricNamespaceCollection]: """Lists the metric namespaces for the resource. :param resource_uri: The identifier of the resource. :type resource_uri: str :param start_time: The ISO 8601 conform Date start time from which to query for metric - namespaces. + namespaces. Default value is None. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricNamespaceCollection or the result of @@ -67,31 +64,42 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricNamespaceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, start_time=start_time, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, start_time=start_time, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -105,7 +113,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,4 +131,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ba000c367032..76df247f92cd 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 @@ -15,7 +15,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ErrorResponse', 'MetricNamespace', @@ -23,3 +25,5 @@ 'MetricNamespaceName', 'NamespaceClassification', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 92439e54e50b..23c13532b1eb 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorResponse(msrest.serialization.Model): @@ -55,7 +57,7 @@ class MetricNamespace(msrest.serialization.Model): :vartype type: str :ivar name: The escaped name of the namespace. :vartype name: str - :ivar classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". + :ivar classification: Kind of namespace. Known values are: "Platform", "Custom", "Qos". :vartype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification :ivar properties: Properties which include the fully qualified namespace name. @@ -76,8 +78,8 @@ def __init__( id: Optional[str] = None, type: Optional[str] = None, name: Optional[str] = None, - classification: Optional[Union[str, "NamespaceClassification"]] = None, - properties: Optional["MetricNamespaceName"] = None, + classification: Optional[Union[str, "_models.NamespaceClassification"]] = None, + properties: Optional["_models.MetricNamespaceName"] = None, **kwargs ): """ @@ -87,8 +89,7 @@ def __init__( :paramtype type: str :keyword name: The escaped name of the namespace. :paramtype name: str - :keyword classification: Kind of namespace. Possible values include: "Platform", "Custom", - "Qos". + :keyword classification: Kind of namespace. Known values are: "Platform", "Custom", "Qos". :paramtype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification :keyword properties: Properties which include the fully qualified namespace name. @@ -122,7 +123,7 @@ class MetricNamespaceCollection(msrest.serialization.Model): def __init__( self, *, - value: List["MetricNamespace"], + value: List["_models.MetricNamespace"], **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py index 903fea1fdcca..e0c9e012e5aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class NamespaceClassification(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NamespaceClassification(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Kind of namespace """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 a4430969ab2b..680cb8018ae1 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'MetricNamespacesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 44f3cf0e9159..aa46fc3407cf 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( start_time: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2017-12-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricNamespaces') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/metricNamespaces") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if start_time is not None: - query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricNamespacesOperations(object): - """MetricNamespacesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricNamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2017_12_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2017_12_01_preview.MonitorManagementClient`'s + :attr:`metric_namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,13 +89,13 @@ def list( resource_uri: str, start_time: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricNamespaceCollection"]: + ) -> Iterable[_models.MetricNamespaceCollection]: """Lists the metric namespaces for the resource. :param resource_uri: The identifier of the resource. :type resource_uri: str :param start_time: The ISO 8601 conform Date start time from which to query for metric - namespaces. + namespaces. Default value is None. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricNamespaceCollection or the result of @@ -103,31 +104,42 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricNamespaceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, start_time=start_time, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, start_time=start_time, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -141,7 +153,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,4 +171,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 140c72aa1b0c..2b64ba9b08e4 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2018-01-01" + 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) 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 99fa18757f37..d26da9081753 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 a539766bbfaa..87aa11a4c710 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :vartype metrics: $(python-base-namespace).v2018_01_01.operations.MetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -48,13 +52,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 cffdc2d34b31..628dab438b99 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2018-01-01" + 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) 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 11c57b3a714a..c17fa4c37e5a 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :vartype metrics: $(python-base-namespace).v2018_01_01.aio.operations.MetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -48,8 +52,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metrics = MetricsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 79a3861ade2f..5cd38a6007e2 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 @@ -9,7 +9,12 @@ from ._metric_definitions_operations import MetricDefinitionsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'MetricDefinitionsOperations', 'MetricsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 fda3b5ccdbe2..56fdf7d07cdd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricDefinitionsOperations: - """MetricDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_01_01.aio.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,12 +49,13 @@ def list( resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricDefinitionCollection"]: + ) -> AsyncIterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. :type resource_uri: str - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of @@ -66,31 +64,42 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnamespace=metricnamespace, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnamespace=metricnamespace, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -104,7 +113,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,4 +131,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"} # type: ignore 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 bc650c2c02f1..792d4e4dcb54 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,15 +7,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -24,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricsOperations: - """MetricsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_01_01.aio.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -59,29 +57,30 @@ async def list( result_type: Optional[Union[str, "_models.ResultType"]] = None, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> "_models.Response": + ) -> _models.Response: """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Default value is None. :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str :param top: The maximum number of records to retrieve. Valid only if $filter is specified. - Defaults to 10. + Defaults to 10. Default value is None. :type top: int :param orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. - Examples: sum asc. + Examples: sum asc. Default value is None. :type orderby: str :param filter: The **$filter** is used to reduce the set of metric data returned. Example: Metric contains metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or @@ -94,27 +93,34 @@ async def list( Instead of using $filter= "dim (test) 1 eq '\ *' " use **$filter= "dim %2528test%2529 1 eq '*\ ' "\ ** When dimension name is **\ dim (test) 3\ ** and dimension value is **\ dim3 (test) val\ ** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " use **\ $filter= "dim - %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. + %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. + operation. See the operation's description for details. Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_01_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Response, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_01_01.models.Response :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Response"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, timespan=timespan, interval=interval, metricnames=metricnames, @@ -125,11 +131,17 @@ async def list( result_type=result_type, metricnamespace=metricnamespace, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,5 +156,5 @@ async def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/metrics'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 cb58f8a05df3..2f080e37bffa 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 @@ -24,7 +24,9 @@ MetricUnit, ResultType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ErrorResponse', 'LocalizableString', @@ -41,3 +43,5 @@ 'MetricUnit', 'ResultType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f7a0b02333a9..2db6bfe8590d 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ErrorResponse(msrest.serialization.Model): @@ -102,7 +104,7 @@ class MetadataValue(msrest.serialization.Model): def __init__( self, *, - name: Optional["LocalizableString"] = None, + name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs ): @@ -135,9 +137,9 @@ class Metric(msrest.serialization.Model): :vartype error_code: str :ivar error_message: Error message encountered querying this specific metric. :vartype error_message: str - :ivar unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :ivar unit: Required. The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :ivar timeseries: Required. the time series returned when a data query is performed. :vartype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] @@ -167,9 +169,9 @@ def __init__( *, id: str, type: str, - name: "LocalizableString", - unit: Union[str, "MetricUnit"], - timeseries: List["TimeSeriesElement"], + name: "_models.LocalizableString", + unit: Union[str, "_models.MetricUnit"], + timeseries: List["_models.TimeSeriesElement"], display_description: Optional[str] = None, error_code: Optional[str] = None, error_message: Optional[str] = None, @@ -189,9 +191,9 @@ def __init__( :paramtype error_code: str :keyword error_message: Error message encountered querying this specific metric. :paramtype error_message: str - :keyword unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", - "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", - "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :keyword unit: Required. The unit of the metric. Known values are: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :keyword timeseries: Required. the time series returned when a data query is performed. :paramtype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] @@ -258,15 +260,15 @@ class MetricDefinition(msrest.serialization.Model): :vartype display_description: str :ivar category: Custom category name for this metric. :vartype category: str - :ivar metric_class: The class of the metric. Possible values include: "Availability", - "Transactions", "Errors", "Latency", "Saturation". + :ivar metric_class: The class of the metric. Known values are: "Availability", "Transactions", + "Errors", "Latency", "Saturation". :vartype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass - :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :ivar primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType @@ -306,16 +308,16 @@ def __init__( is_dimension_required: Optional[bool] = None, resource_id: Optional[str] = None, namespace: Optional[str] = None, - name: Optional["LocalizableString"] = None, + name: Optional["_models.LocalizableString"] = None, display_description: Optional[str] = None, category: Optional[str] = None, - metric_class: Optional[Union[str, "MetricClass"]] = None, - unit: Optional[Union[str, "MetricUnit"]] = None, - primary_aggregation_type: Optional[Union[str, "AggregationType"]] = None, - supported_aggregation_types: Optional[List[Union[str, "AggregationType"]]] = None, - metric_availabilities: Optional[List["MetricAvailability"]] = None, + metric_class: Optional[Union[str, "_models.MetricClass"]] = None, + unit: Optional[Union[str, "_models.MetricUnit"]] = None, + primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, + supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, + metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, - dimensions: Optional[List["LocalizableString"]] = None, + dimensions: Optional[List["_models.LocalizableString"]] = None, **kwargs ): """ @@ -331,15 +333,15 @@ def __init__( :paramtype display_description: str :keyword category: Custom category name for this metric. :paramtype category: str - :keyword metric_class: The class of the metric. Possible values include: "Availability", + :keyword metric_class: The class of the metric. Known values are: "Availability", "Transactions", "Errors", "Latency", "Saturation". :paramtype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass - :keyword unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :keyword unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit :keyword primary_aggregation_type: the primary aggregation type value defining how to use the - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + values for display. Known values are: "None", "Average", "Count", "Minimum", "Maximum", "Total". :paramtype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType @@ -392,7 +394,7 @@ class MetricDefinitionCollection(msrest.serialization.Model): def __init__( self, *, - value: List["MetricDefinition"], + value: List["_models.MetricDefinition"], **kwargs ): """ @@ -513,7 +515,7 @@ def __init__( self, *, timespan: str, - value: List["Metric"], + value: List["_models.Metric"], cost: Optional[int] = None, interval: Optional[datetime.timedelta] = None, namespace: Optional[str] = None, @@ -565,8 +567,8 @@ class TimeSeriesElement(msrest.serialization.Model): def __init__( self, *, - metadatavalues: Optional[List["MetadataValue"]] = None, - data: Optional[List["MetricValue"]] = None, + metadatavalues: Optional[List["_models.MetadataValue"]] = None, + data: Optional[List["_models.MetricValue"]] = None, **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py index fd09dbefdcc6..2550683eb494 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the aggregation type of the metric. """ @@ -22,7 +21,7 @@ class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class MetricClass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MetricClass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The class of the metric. """ @@ -32,7 +31,7 @@ class MetricClass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LATENCY = "Latency" SATURATION = "Saturation" -class MetricUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of the metric. """ @@ -50,7 +49,7 @@ class MetricUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NANO_CORES = "NanoCores" BITS_PER_SECOND = "BitsPerSecond" -class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 79a3861ade2f..5cd38a6007e2 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 @@ -9,7 +9,12 @@ from ._metric_definitions_operations import MetricDefinitionsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'MetricDefinitionsOperations', 'MetricsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 d4fbf7397d34..ade5e1c22bf1 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,55 +33,55 @@ def build_list_request( metricnamespace: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if metricnamespace is not None: - query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricDefinitionsOperations(object): - """MetricDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricDefinitionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_01_01.MonitorManagementClient`'s + :attr:`metric_definitions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -88,12 +89,13 @@ def list( resource_uri: str, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.MetricDefinitionCollection"]: + ) -> Iterable[_models.MetricDefinitionCollection]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. :type resource_uri: str - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricDefinitionCollection or the result of @@ -102,31 +104,42 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnamespace=metricnamespace, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnamespace=metricnamespace, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -140,7 +153,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,4 +171,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"} # type: ignore 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 526a3d88304c..4ad8177fd803 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -40,71 +41,71 @@ def build_list_request( metricnamespace: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2018-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metrics') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metrics") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') if metricnames is not None: - query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + _params['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') if top is not None: - query_parameters['top'] = _SERIALIZER.query("top", top, 'int') + _params['top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - query_parameters['orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['orderby'] = _SERIALIZER.query("orderby", orderby, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if metricnamespace is not None: - query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricsOperations(object): - """MetricsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_01_01.MonitorManagementClient`'s + :attr:`metrics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -120,29 +121,30 @@ def list( result_type: Optional[Union[str, "_models.ResultType"]] = None, metricnamespace: Optional[str] = None, **kwargs: Any - ) -> "_models.Response": + ) -> _models.Response: """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Default value is None. :type metricnames: str - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str :param top: The maximum number of records to retrieve. Valid only if $filter is specified. - Defaults to 10. + Defaults to 10. Default value is None. :type top: int :param orderby: The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. - Examples: sum asc. + Examples: sum asc. Default value is None. :type orderby: str :param filter: The **$filter** is used to reduce the set of metric data returned. Example: Metric contains metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or @@ -155,27 +157,34 @@ def list( Instead of using $filter= "dim (test) 1 eq '\ *' " use **$filter= "dim %2528test%2529 1 eq '*\ ' "\ ** When dimension name is **\ dim (test) 3\ ** and dimension value is **\ dim3 (test) val\ ** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " use **\ $filter= "dim - %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. + %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Reduces the set of data collected. The syntax allowed depends on the - operation. See the operation's description for details. + operation. See the operation's description for details. Default value is None. :type result_type: str or ~$(python-base-namespace).v2018_01_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Response, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_01_01.models.Response :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Response"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Response] request = build_list_request( resource_uri=resource_uri, + api_version=api_version, timespan=timespan, interval=interval, metricnames=metricnames, @@ -186,11 +195,17 @@ def list( result_type=result_type, metricnamespace=metricnamespace, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -205,5 +220,5 @@ def list( return deserialized - list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/metrics'} # type: ignore + list.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 02f3bff47a57..d38615cce33f 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01" + 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) 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 29e4460a8b75..4b154548b576 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 0096c6fd0b18..6e477a41bc94 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -35,8 +36,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -53,14 +57,20 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_alerts = MetricAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_alerts_status = MetricAlertsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 f68f113b2fde..956d837ce56c 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01" + 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) 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 42cd3189dd06..d5fbcaa29189 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -37,8 +38,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -55,9 +59,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_alerts = MetricAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.metric_alerts_status = MetricAlertsStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 866bc341041b..abf34ef0b771 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 @@ -10,8 +10,13 @@ from ._metric_alerts_operations import MetricAlertsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'MetricAlertsOperations', 'MetricAlertsStatusOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 87b98768d8b0..217c01d64135 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -81,14 +83,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -231,13 +264,17 @@ async def update( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -245,14 +282,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,14 +311,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -283,29 +327,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,7 +374,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,14 +392,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -351,31 +410,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +459,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,14 +477,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -427,13 +501,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -441,14 +519,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -459,5 +544,5 @@ async def enable_receiver( 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"} # type: ignore 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 6b4ff7fc1c34..6ae5edc546e5 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricAlertsOperations: - """MetricAlertsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.aio.MonitorManagementClient`'s + :attr:`metric_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.MetricAlertResourceCollection"]: + ) -> AsyncIterable[_models.MetricAlertResourceCollection]: """Retrieve alert rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,14 +123,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.MetricAlertResourceCollection"]: + ) -> AsyncIterable[_models.MetricAlertResourceCollection]: """Retrieve alert rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,31 +142,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +191,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +209,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace_async async def get( @@ -189,7 +217,7 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Retrieve an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -201,23 +229,35 @@ async def get( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,7 +272,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -240,9 +280,9 @@ async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.MetricAlertResource", + parameters: _models.MetricAlertResource, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Create or update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -256,13 +296,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] _json = self._serialize.body(parameters, 'MetricAlertResource') @@ -270,14 +314,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -292,7 +343,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -300,9 +351,9 @@ async def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.MetricAlertResourcePatch", + parameters: _models.MetricAlertResourcePatch, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -316,13 +367,17 @@ async def update( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') @@ -330,14 +385,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -352,11 +414,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -373,23 +435,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -400,5 +474,5 @@ async def delete( 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}"} # type: ignore 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 8be671ebb385..25816eb63c32 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MetricAlertsStatusOperations: - """MetricAlertsStatusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.aio.MonitorManagementClient`'s + :attr:`metric_alerts_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.MetricAlertStatusCollection": + ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -62,23 +60,35 @@ async def list( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertStatusCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] request = build_list_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,7 +103,7 @@ 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"} # type: ignore @distributed_trace_async @@ -103,7 +113,7 @@ async def list_by_name( rule_name: str, status_name: str, **kwargs: Any - ) -> "_models.MetricAlertStatusCollection": + ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -117,11 +127,16 @@ async def list_by_name( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertStatusCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] request = build_list_by_name_request( @@ -129,12 +144,19 @@ async def list_by_name( resource_group_name=resource_group_name, rule_name=rule_name, status_name=status_name, + api_version=api_version, template_url=self.list_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -149,5 +171,5 @@ 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 83660d376814..469cf245f692 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 @@ -48,7 +48,9 @@ Operator, ReceiverStatus, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ActionGroupList', 'ActionGroupPatchBody', @@ -89,3 +91,5 @@ 'Operator', 'ReceiverStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 2c3669778fdb..24749f1dc7e0 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ActionGroupList(msrest.serialization.Model): @@ -32,7 +34,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -219,15 +221,15 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, **kwargs ): """ @@ -464,7 +466,7 @@ class MultiMetricCriteria(msrest.serialization.Model): collection. :vartype additional_properties: dict[str, any] :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType :ivar name: Required. Name of the criteria. :vartype name: str @@ -472,7 +474,7 @@ class MultiMetricCriteria(msrest.serialization.Model): :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: "Average", "Count", "Minimum", "Maximum", "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum @@ -510,10 +512,10 @@ def __init__( *, name: str, metric_name: str, - time_aggregation: Union[str, "AggregationTypeEnum"], + time_aggregation: Union[str, "_models.AggregationTypeEnum"], additional_properties: Optional[Dict[str, Any]] = None, metric_namespace: Optional[str] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, **kwargs ): @@ -527,8 +529,8 @@ def __init__( :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: + "Average", "Count", "Minimum", "Maximum", "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -557,7 +559,7 @@ class DynamicMetricCriteria(MultiMetricCriteria): collection. :vartype additional_properties: dict[str, any] :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType :ivar name: Required. Name of the criteria. :vartype name: str @@ -565,7 +567,7 @@ class DynamicMetricCriteria(MultiMetricCriteria): :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: "Average", "Count", "Minimum", "Maximum", "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum @@ -575,11 +577,11 @@ class DynamicMetricCriteria(MultiMetricCriteria): emitted, by causing the metric validation to be skipped. :vartype skip_metric_validation: bool :ivar operator: Required. The operator used to compare the metric value against the threshold. - Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". + Known values are: "GreaterThan", "LessThan", "GreaterOrLessThan". :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator :ivar alert_sensitivity: Required. The extent of deviation required to trigger an alert. This - will affect how tight the threshold is to the metric series pattern. Possible values include: - "Low", "Medium", "High". + will affect how tight the threshold is to the metric series pattern. Known values are: "Low", + "Medium", "High". :vartype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity :ivar failing_periods: Required. The minimum number of violations required within the selected @@ -621,13 +623,13 @@ def __init__( *, name: str, metric_name: str, - time_aggregation: Union[str, "AggregationTypeEnum"], - operator: Union[str, "DynamicThresholdOperator"], - alert_sensitivity: Union[str, "DynamicThresholdSensitivity"], - failing_periods: "DynamicThresholdFailingPeriods", + time_aggregation: Union[str, "_models.AggregationTypeEnum"], + operator: Union[str, "_models.DynamicThresholdOperator"], + alert_sensitivity: Union[str, "_models.DynamicThresholdSensitivity"], + failing_periods: "_models.DynamicThresholdFailingPeriods", additional_properties: Optional[Dict[str, Any]] = None, metric_namespace: Optional[str] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, ignore_data_before: Optional[datetime.datetime] = None, **kwargs @@ -642,8 +644,8 @@ def __init__( :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: + "Average", "Count", "Minimum", "Maximum", "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -652,12 +654,12 @@ def __init__( yet emitted, by causing the metric validation to be skipped. :paramtype skip_metric_validation: bool :keyword operator: Required. The operator used to compare the metric value against the - threshold. Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". + threshold. Known values are: "GreaterThan", "LessThan", "GreaterOrLessThan". :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator :keyword alert_sensitivity: Required. The extent of deviation required to trigger an alert. - This will affect how tight the threshold is to the metric series pattern. Possible values - include: "Low", "Medium", "High". + This will affect how tight the threshold is to the metric series pattern. Known values are: + "Low", "Medium", "High". :paramtype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity :keyword failing_periods: Required. The minimum number of violations required within the @@ -733,8 +735,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype name: str :ivar email_address: Required. The email address of this receiver. :vartype email_address: str - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus """ @@ -999,7 +1001,7 @@ class MetricAlertCriteria(msrest.serialization.Model): collection. :vartype additional_properties: dict[str, any] :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype @@ -1043,7 +1045,7 @@ class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): collection. :vartype additional_properties: dict[str, any] :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype @@ -1065,7 +1067,7 @@ def __init__( self, *, additional_properties: Optional[Dict[str, Any]] = None, - all_of: Optional[List["MultiMetricCriteria"]] = None, + all_of: Optional[List["_models.MultiMetricCriteria"]] = None, **kwargs ): """ @@ -1179,13 +1181,13 @@ def __init__( scopes: List[str], evaluation_frequency: datetime.timedelta, window_size: datetime.timedelta, - criteria: "MetricAlertCriteria", + criteria: "_models.MetricAlertCriteria", tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, target_resource_type: Optional[str] = None, target_resource_region: Optional[str] = None, auto_mitigate: Optional[bool] = None, - actions: Optional[List["MetricAlertAction"]] = None, + actions: Optional[List["_models.MetricAlertAction"]] = None, **kwargs ): """ @@ -1255,7 +1257,7 @@ class MetricAlertResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["MetricAlertResource"]] = None, + value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs ): """ @@ -1342,9 +1344,9 @@ def __init__( window_size: Optional[datetime.timedelta] = None, target_resource_type: Optional[str] = None, target_resource_region: Optional[str] = None, - criteria: Optional["MetricAlertCriteria"] = None, + criteria: Optional["_models.MetricAlertCriteria"] = None, auto_mitigate: Optional[bool] = None, - actions: Optional[List["MetricAlertAction"]] = None, + actions: Optional[List["_models.MetricAlertAction"]] = None, **kwargs ): """ @@ -1406,7 +1408,7 @@ class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): collection. :vartype additional_properties: dict[str, any] :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype @@ -1428,7 +1430,7 @@ def __init__( self, *, additional_properties: Optional[Dict[str, Any]] = None, - all_of: Optional[List["MetricCriteria"]] = None, + all_of: Optional[List["_models.MetricCriteria"]] = None, **kwargs ): """ @@ -1469,7 +1471,7 @@ def __init__( name: Optional[str] = None, id: Optional[str] = None, type: Optional[str] = None, - properties: Optional["MetricAlertStatusProperties"] = None, + properties: Optional["_models.MetricAlertStatusProperties"] = None, **kwargs ): """ @@ -1503,7 +1505,7 @@ class MetricAlertStatusCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["MetricAlertStatus"]] = None, + value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs ): """ @@ -1562,7 +1564,7 @@ class MetricCriteria(MultiMetricCriteria): collection. :vartype additional_properties: dict[str, any] :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + server. Known values are: "StaticThresholdCriterion", "DynamicThresholdCriterion". :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType :ivar name: Required. Name of the criteria. :vartype name: str @@ -1570,7 +1572,7 @@ class MetricCriteria(MultiMetricCriteria): :vartype metric_name: str :ivar metric_namespace: Namespace of the metric. :vartype metric_namespace: str - :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + :ivar time_aggregation: Required. the criteria time aggregation types. Known values are: "Average", "Count", "Minimum", "Maximum", "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum @@ -1579,8 +1581,8 @@ class MetricCriteria(MultiMetricCriteria): :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :vartype skip_metric_validation: bool - :ivar operator: Required. the criteria operator. Possible values include: "Equals", - "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: Required. the criteria operator. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator :ivar threshold: Required. the criteria threshold value that activates the alert. :vartype threshold: float @@ -1613,12 +1615,12 @@ def __init__( *, name: str, metric_name: str, - time_aggregation: Union[str, "AggregationTypeEnum"], - operator: Union[str, "Operator"], + time_aggregation: Union[str, "_models.AggregationTypeEnum"], + operator: Union[str, "_models.Operator"], threshold: float, additional_properties: Optional[Dict[str, Any]] = None, metric_namespace: Optional[str] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, **kwargs ): @@ -1632,8 +1634,8 @@ def __init__( :paramtype metric_name: str :keyword metric_namespace: Namespace of the metric. :paramtype metric_namespace: str - :keyword time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". + :keyword time_aggregation: Required. the criteria time aggregation types. Known values are: + "Average", "Count", "Minimum", "Maximum", "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum :keyword dimensions: List of dimension conditions. @@ -1641,8 +1643,8 @@ def __init__( :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. :paramtype skip_metric_validation: bool - :keyword operator: Required. the criteria operator. Possible values include: "Equals", - "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: Required. the criteria operator. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator :keyword threshold: Required. the criteria threshold value that activates the alert. :paramtype threshold: float @@ -1715,7 +1717,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus """ @@ -1857,7 +1859,7 @@ class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): collection. :vartype additional_properties: dict[str, any] :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. - Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + Known values are: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py index 66dfce38fc14..91f4c47b665b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregationTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregationTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the criteria time aggregation types. """ @@ -21,14 +20,14 @@ class AggregationTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class CriterionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CriterionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of threshold criteria """ STATIC_THRESHOLD_CRITERION = "StaticThresholdCriterion" DYNAMIC_THRESHOLD_CRITERION = "DynamicThresholdCriterion" -class DynamicThresholdOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DynamicThresholdOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operator used to compare the metric value against the threshold. """ @@ -36,7 +35,7 @@ class DynamicThresholdOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum LESS_THAN = "LessThan" GREATER_OR_LESS_THAN = "GreaterOrLessThan" -class DynamicThresholdSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DynamicThresholdSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. """ @@ -45,7 +44,7 @@ class DynamicThresholdSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, E MEDIUM = "Medium" HIGH = "High" -class Odatatype(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Odatatype(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the type of the alert criteria. """ @@ -53,7 +52,7 @@ class Odatatype(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" -class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the criteria operator. """ @@ -63,7 +62,7 @@ class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 866bc341041b..abf34ef0b771 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 @@ -10,8 +10,13 @@ from ._metric_alerts_operations import MetricAlertsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'MetricAlertsOperations', 'MetricAlertsStatusOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 414a2fd90471..97eee198d4fb 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,30 +229,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -254,74 +264,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -335,13 +344,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -349,14 +362,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -375,7 +395,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -384,7 +404,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -396,23 +416,35 @@ def get( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +459,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -448,23 +480,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,7 +519,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -483,9 +527,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -499,13 +543,17 @@ def update( :rtype: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -513,14 +561,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,14 +590,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -551,29 +606,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,7 +653,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,14 +671,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -619,31 +689,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -657,7 +738,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -671,14 +756,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -695,13 +780,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -709,14 +798,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -727,5 +823,5 @@ def enable_receiver( 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"} # type: ignore 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 4fa32fef790b..3c7864c95469 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,30 +65,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_or_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.MetricAlertResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.MetricAlertResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,61 +228,61 @@ def build_delete_request( rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricAlertsOperations(object): - """MetricAlertsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.MonitorManagementClient`'s + :attr:`metric_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.MetricAlertResourceCollection"]: + ) -> Iterable[_models.MetricAlertResourceCollection]: """Retrieve alert rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -284,29 +292,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -320,7 +339,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,14 +357,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.MetricAlertResourceCollection"]: + ) -> Iterable[_models.MetricAlertResourceCollection]: """Retrieve alert rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,31 +376,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +425,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,7 +443,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore @distributed_trace def get( @@ -413,7 +451,7 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Retrieve an alert rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -425,23 +463,35 @@ def get( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -456,7 +506,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -464,9 +514,9 @@ def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.MetricAlertResource", + parameters: _models.MetricAlertResource, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Create or update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -480,13 +530,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] _json = self._serialize.body(parameters, 'MetricAlertResource') @@ -494,14 +548,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -516,7 +577,7 @@ 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}"} # type: ignore @distributed_trace @@ -524,9 +585,9 @@ def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.MetricAlertResourcePatch", + parameters: _models.MetricAlertResourcePatch, **kwargs: Any - ) -> "_models.MetricAlertResource": + ) -> _models.MetricAlertResource: """Update an metric alert definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -540,13 +601,17 @@ def update( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertResource] _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') @@ -554,14 +619,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -576,11 +648,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -597,23 +669,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -624,5 +708,5 @@ def delete( 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}"} # type: ignore 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 05b7c8f94d81..23ea26c0b8a0 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,31 +32,33 @@ def build_list_request( rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,10 +70,14 @@ def build_list_by_name_request( status_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}") # 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), @@ -78,45 +85,41 @@ def build_list_by_name_request( "statusName": _SERIALIZER.url("status_name", status_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class MetricAlertsStatusOperations(object): - """MetricAlertsStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MetricAlertsStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_03_01.MonitorManagementClient`'s + :attr:`metric_alerts_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -124,7 +127,7 @@ def list( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.MetricAlertStatusCollection": + ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -136,23 +139,35 @@ def list( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertStatusCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] request = build_list_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -167,7 +182,7 @@ 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"} # type: ignore @distributed_trace @@ -177,7 +192,7 @@ def list_by_name( rule_name: str, status_name: str, **kwargs: Any - ) -> "_models.MetricAlertStatusCollection": + ) -> _models.MetricAlertStatusCollection: """Retrieve an alert rule status. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -191,11 +206,16 @@ def list_by_name( :rtype: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertStatusCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricAlertStatusCollection] request = build_list_by_name_request( @@ -203,12 +223,19 @@ def list_by_name( resource_group_name=resource_group_name, rule_name=rule_name, status_name=status_name, + api_version=api_version, template_url=self.list_by_name.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,5 +250,5 @@ 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 6fb25c5332d8..4553ba117c46 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-04-16") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-04-16" + 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) 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 14e0dd203124..1e742490f1c0 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 e41f47416657..9846f53b6f80 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,12 +53,14 @@ def __init__( 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) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 8af9a49138cd..a851ec39e387 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-04-16") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-04-16" + 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) 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 c73fd5d4fc0e..b5bb1503a278 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-04-16". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,7 +53,9 @@ def __init__( 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) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 f677702ed3df..a33ab10efeb3 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ScheduledQueryRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 e85418a0b030..9aacec878a06 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScheduledQueryRulesOperations: - """ScheduledQueryRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_04_16.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_04_16.aio.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.LogSearchRuleResource", + parameters: _models.LogSearchRuleResource, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Creates or updates an log search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] _json = self._serialize.body(parameters, 'LogSearchRuleResource') @@ -81,14 +83,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Gets an Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +180,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -167,9 +188,9 @@ async def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.LogSearchRuleResourcePatch", + parameters: _models.LogSearchRuleResourcePatch, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Update log search Rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -183,13 +204,17 @@ async def update( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') @@ -197,14 +222,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -219,11 +251,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -240,23 +272,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,7 +311,7 @@ async def delete( 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}"} # type: ignore @distributed_trace @@ -275,11 +319,11 @@ def list_by_subscription( self, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogSearchRuleResourceCollection"]: + ) -> AsyncIterable[_models.LogSearchRuleResourceCollection]: """List the Log Search rules within a subscription group. :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of @@ -288,31 +332,42 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,7 +381,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,7 +399,7 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( @@ -348,13 +407,13 @@ def list_by_resource_group( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.LogSearchRuleResourceCollection"]: + ) -> AsyncIterable[_models.LogSearchRuleResourceCollection]: """List the Log Search rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of @@ -363,33 +422,44 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -403,7 +473,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -417,4 +491,4 @@ 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"} # type: ignore 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 7e948df4f724..7f48070171b5 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 @@ -33,7 +33,9 @@ ProvisioningState, QueryType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Action', 'AlertingAction', @@ -59,3 +61,5 @@ 'ProvisioningState', 'QueryType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f4941e6938ed..797409021318 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Action(msrest.serialization.Model): @@ -57,8 +59,7 @@ class AlertingAction(Action): :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. :vartype odata_type: str - :ivar severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", - "4". + :ivar severity: Required. Severity of the alert. Known values are: "0", "1", "2", "3", "4". :vartype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity :ivar azns_action: Azure action group reference. :vartype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup @@ -85,15 +86,14 @@ class AlertingAction(Action): def __init__( self, *, - severity: Union[str, "AlertSeverity"], - trigger: "TriggerCondition", - azns_action: Optional["AzNsActionGroup"] = None, + severity: Union[str, "_models.AlertSeverity"], + trigger: "_models.TriggerCondition", + azns_action: Optional["_models.AzNsActionGroup"] = None, throttling_in_min: Optional[int] = None, **kwargs ): """ - :keyword severity: Required. Severity of the alert. Possible values include: "0", "1", "2", - "3", "4". + :keyword severity: Required. Severity of the alert. Known values are: "0", "1", "2", "3", "4". :paramtype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity :keyword azns_action: Azure action group reference. :paramtype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup @@ -176,7 +176,7 @@ def __init__( self, *, metric_name: str, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, **kwargs ): """ @@ -197,7 +197,7 @@ class Dimension(msrest.serialization.Model): :ivar name: Required. Name of the dimension. :vartype name: str - :ivar operator: Required. Operator for dimension values. Possible values include: "Include". + :ivar operator: Required. Operator for dimension values. Known values are: "Include". :vartype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator :ivar values: Required. List of dimension values. :vartype values: list[str] @@ -219,14 +219,14 @@ def __init__( self, *, name: str, - operator: Union[str, "Operator"], + operator: Union[str, "_models.Operator"], values: List[str], **kwargs ): """ :keyword name: Required. Name of the dimension. :paramtype name: str - :keyword operator: Required. Operator for dimension values. Possible values include: "Include". + :keyword operator: Required. Operator for dimension values. Known values are: "Include". :paramtype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator :keyword values: Required. List of dimension values. :paramtype values: list[str] @@ -251,7 +251,7 @@ class ErrorContract(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): """ @@ -298,14 +298,14 @@ class LogMetricTrigger(msrest.serialization.Model): """A log metrics trigger descriptor. :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or - 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", - "LessThan", "Equal". Default value: "GreaterThanOrEqual". + 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + "Equal". Default value: "GreaterThanOrEqual". :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator :ivar threshold: The threshold of the metric trigger. :vartype threshold: float - :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values - include: "Consecutive", "Total". Default value: "Consecutive". + :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: + "Consecutive", "Total". Default value: "Consecutive". :vartype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType :ivar metric_column: Evaluation of metric on a particular column. @@ -322,22 +322,22 @@ class LogMetricTrigger(msrest.serialization.Model): def __init__( self, *, - threshold_operator: Optional[Union[str, "ConditionalOperator"]] = "GreaterThanOrEqual", + threshold_operator: Optional[Union[str, "_models.ConditionalOperator"]] = "GreaterThanOrEqual", threshold: Optional[float] = None, - metric_trigger_type: Optional[Union[str, "MetricTriggerType"]] = "Consecutive", + metric_trigger_type: Optional[Union[str, "_models.MetricTriggerType"]] = "Consecutive", metric_column: Optional[str] = None, **kwargs ): """ :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or - 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", - "LessThan", "Equal". Default value: "GreaterThanOrEqual". + 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + "Equal". Default value: "GreaterThanOrEqual". :paramtype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator :keyword threshold: The threshold of the metric trigger. :paramtype threshold: float - :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values - include: "Consecutive", "Total". Default value: "Consecutive". + :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Known values are: + "Consecutive", "Total". Default value: "Consecutive". :paramtype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType :keyword metric_column: Evaluation of metric on a particular column. @@ -460,12 +460,12 @@ class LogSearchRuleResource(Resource): or not. The default is false. :vartype auto_mitigate: bool :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Possible values include: "true", "false". + true or false. Known values are: "true", "false". :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled :ivar last_updated_time: Last time the rule was updated in IS08601 format. :vartype last_updated_time: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the scheduled query rule. Possible values - include: "Succeeded", "Deploying", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the scheduled query rule. Known values are: + "Succeeded", "Deploying", "Canceled", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2018_04_16.models.ProvisioningState :ivar source: Required. Data Source against which rule will Query Data. @@ -517,14 +517,14 @@ def __init__( self, *, location: str, - source: "Source", - action: "Action", + source: "_models.Source", + action: "_models.Action", tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, auto_mitigate: Optional[bool] = False, - enabled: Optional[Union[str, "Enabled"]] = None, - schedule: Optional["Schedule"] = None, + enabled: Optional[Union[str, "_models.Enabled"]] = None, + schedule: Optional["_models.Schedule"] = None, **kwargs ): """ @@ -540,7 +540,7 @@ def __init__( resolved or not. The default is false. :paramtype auto_mitigate: bool :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". + be true or false. Known values are: "true", "false". :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled :keyword source: Required. Data Source against which rule will Query Data. :paramtype source: ~$(python-base-namespace).v2018_04_16.models.Source @@ -578,7 +578,7 @@ class LogSearchRuleResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LogSearchRuleResource"]] = None, + value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs ): """ @@ -595,7 +595,7 @@ class LogSearchRuleResourcePatch(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be - true or false. Possible values include: "true", "false". + true or false. Known values are: "true", "false". :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ @@ -608,14 +608,14 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - enabled: Optional[Union[str, "Enabled"]] = None, + enabled: Optional[Union[str, "_models.Enabled"]] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". + be true or false. Known values are: "true", "false". :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ super(LogSearchRuleResourcePatch, self).__init__(**kwargs) @@ -648,7 +648,7 @@ class LogToMetricAction(Action): def __init__( self, *, - criteria: List["Criteria"], + criteria: List["_models.Criteria"], **kwargs ): """ @@ -714,7 +714,7 @@ class Source(msrest.serialization.Model): :vartype authorized_resources: list[str] :ivar data_source_id: Required. The resource uri over which log search query is to be run. :vartype data_source_id: str - :ivar query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :ivar query_type: Set value to 'ResultCount' . Known values are: "ResultCount". :vartype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ @@ -735,7 +735,7 @@ def __init__( data_source_id: str, query: Optional[str] = None, authorized_resources: Optional[List[str]] = None, - query_type: Optional[Union[str, "QueryType"]] = None, + query_type: Optional[Union[str, "_models.QueryType"]] = None, **kwargs ): """ @@ -745,7 +745,7 @@ def __init__( :paramtype authorized_resources: list[str] :keyword data_source_id: Required. The resource uri over which log search query is to be run. :paramtype data_source_id: str - :keyword query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :keyword query_type: Set value to 'ResultCount' . Known values are: "ResultCount". :paramtype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ super(Source, self).__init__(**kwargs) @@ -761,8 +761,8 @@ class TriggerCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or 'LessThan. - Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", - "Equal". Default value: "GreaterThanOrEqual". + Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal". + Default value: "GreaterThanOrEqual". :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator :ivar threshold: Required. Result or count threshold based on which rule should be triggered. @@ -785,14 +785,14 @@ class TriggerCondition(msrest.serialization.Model): def __init__( self, *, - threshold_operator: Union[str, "ConditionalOperator"] = "GreaterThanOrEqual", + threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", threshold: float, - metric_trigger: Optional["LogMetricTrigger"] = None, + metric_trigger: Optional["_models.LogMetricTrigger"] = None, **kwargs ): """ :keyword threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or - 'LessThan. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", + 'LessThan. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal". Default value: "GreaterThanOrEqual". :paramtype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py index d0d3448a6a6e..86c63bab3f9c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AlertSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Severity Level of Alert """ @@ -21,7 +20,7 @@ class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THREE = "3" FOUR = "4" -class ConditionalOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConditionalOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Result Condition Evaluation criteria. """ @@ -31,27 +30,27 @@ class ConditionalOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" EQUAL = "Equal" -class Enabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Enabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The flag which indicates whether the Log Search rule is enabled. Value should be true or false """ TRUE = "true" FALSE = "false" -class MetricTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MetricTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Metric Trigger Evaluation Type """ CONSECUTIVE = "Consecutive" TOTAL = "Total" -class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operator for dimension values """ INCLUDE = "Include" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the scheduled query rule """ @@ -60,7 +59,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CANCELED = "Canceled" FAILED = "Failed" -class QueryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class QueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set value to 'ResultAccount' """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 f677702ed3df..a33ab10efeb3 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ScheduledQueryRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 1c948e2cac15..668fd43bef7b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.LogSearchRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-04-16" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-16" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -111,39 +114,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.LogSearchRuleResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-04-16" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,31 +160,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-16" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -191,31 +197,33 @@ def build_list_by_subscription_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-16" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -227,65 +235,65 @@ def build_list_by_resource_group_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2018-04-16" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ScheduledQueryRulesOperations(object): - """ScheduledQueryRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_04_16.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_04_16.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.LogSearchRuleResource", + parameters: _models.LogSearchRuleResource, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Creates or updates an log search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -299,13 +307,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] _json = self._serialize.body(parameters, 'LogSearchRuleResource') @@ -313,14 +325,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -339,7 +358,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -348,7 +367,7 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Gets an Log Search rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -360,23 +379,35 @@ def get( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +422,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -399,9 +430,9 @@ def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.LogSearchRuleResourcePatch", + parameters: _models.LogSearchRuleResourcePatch, **kwargs: Any - ) -> "_models.LogSearchRuleResource": + ) -> _models.LogSearchRuleResource: """Update log search Rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -415,13 +446,17 @@ def update( :rtype: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogSearchRuleResource] _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') @@ -429,14 +464,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -451,11 +493,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -472,23 +514,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-16")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -499,7 +553,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -507,11 +561,11 @@ def list_by_subscription( self, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogSearchRuleResourceCollection"]: + ) -> Iterable[_models.LogSearchRuleResourceCollection]: """List the Log Search rules within a subscription group. :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of @@ -520,31 +574,42 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -558,7 +623,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -572,7 +641,7 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( @@ -580,13 +649,13 @@ def list_by_resource_group( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.LogSearchRuleResourceCollection"]: + ) -> Iterable[_models.LogSearchRuleResourceCollection]: """List the Log Search rules within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see - https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of @@ -595,33 +664,44 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -635,7 +715,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -649,4 +733,4 @@ 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"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 cc2cd2e5d57c..676df20cf337 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-06-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-06-01-preview" + 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) 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 5aeafd91a05d..21edf7fba84b 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 f0184e69c831..c158437568fd 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -35,8 +36,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -53,13 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations(self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 f4bfd2172596..2da71a16292c 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-06-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-06-01-preview" + 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) 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 6a2eb35ec8f3..ce6a0ab2f199 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -35,8 +36,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-06-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -53,8 +57,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations(self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 3ba5f92c180a..8d3c00241fa2 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 @@ -9,7 +9,12 @@ from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations 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 patch_sdk as _patch_sdk __all__ = [ 'GuestDiagnosticsSettingsAssociationOperations', 'GuestDiagnosticsSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 80d6e126d47d..52f133d1266f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestDiagnosticsSettingsAssociationOperations: - """GuestDiagnosticsSettingsAssociationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_06_01_preview.aio.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings_association` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_uri: str, association_name: str, - diagnostic_settings_association: "_models.GuestDiagnosticSettingsAssociationResource", + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Creates or updates guest diagnostics settings association. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -71,27 +69,38 @@ async def create_or_update( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') request = build_create_or_update_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -110,7 +119,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace_async @@ -119,7 +128,7 @@ async def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Gets guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -133,22 +142,34 @@ async def get( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,11 +184,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -185,22 +206,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -211,7 +244,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -219,9 +252,9 @@ async def update( self, resource_uri: str, association_name: str, - parameters: "_models.GuestDiagnosticSettingsAssociationResourcePatch", + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use the CreateOrUpdate method. @@ -239,27 +272,38 @@ async def update( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') request = build_update_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,14 +318,14 @@ 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationList"]: + ) -> AsyncIterable[_models.GuestDiagnosticSettingsAssociationList]: """Get a list of all guest diagnostic settings association in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -291,29 +335,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +382,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,14 +400,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationList"]: + ) -> AsyncIterable[_models.GuestDiagnosticSettingsAssociationList]: """Get a list of all guest diagnostic settings association in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -360,31 +419,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -398,7 +468,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,4 +486,4 @@ 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"} # type: ignore 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 2caa8649a889..d48a25f7ac73 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GuestDiagnosticsSettingsOperations: - """GuestDiagnosticsSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_06_01_preview.aio.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, diagnostic_settings_name: str, - diagnostic_settings: "_models.GuestDiagnosticSettingsResource", + diagnostic_settings: _models.GuestDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Creates or updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,13 +66,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') @@ -82,14 +84,21 @@ async def create_or_update( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,7 +117,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -117,7 +126,7 @@ async def get( resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Gets guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,23 +138,35 @@ async def get( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] request = build_get_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,7 +181,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -168,9 +189,9 @@ async def update( self, resource_group_name: str, diagnostic_settings_name: str, - parameters: "_models.GuestDiagnosticSettingsPatchResource", + parameters: _models.GuestDiagnosticSettingsPatchResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -185,13 +206,17 @@ async def update( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') @@ -199,14 +224,21 @@ async def update( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -225,11 +257,11 @@ async def update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, diagnostic_settings_name: str, @@ -246,23 +278,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -273,14 +317,14 @@ async def delete( 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsList"]: + ) -> AsyncIterable[_models.GuestDiagnosticSettingsList]: """Get a list of all guest diagnostic settings in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -290,29 +334,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,7 +381,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,14 +399,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GuestDiagnosticSettingsList"]: + ) -> AsyncIterable[_models.GuestDiagnosticSettingsList]: """Get a list of all guest diagnostic settings in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -359,31 +418,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +467,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,4 +485,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 fc0647fb2952..961aeba3487d 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 @@ -28,7 +28,9 @@ GuestDiagnosticSettingsOsType, SinkConfigurationKind, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DataSource', 'DataSourceConfiguration', @@ -49,3 +51,5 @@ 'GuestDiagnosticSettingsOsType', 'SinkConfigurationKind', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 dffaff76a32f..2c50cb871cdc 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class DataSource(msrest.serialization.Model): @@ -19,8 +21,8 @@ class DataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar kind: Required. Datasource kind. Possible values include: "PerformanceCounter", - "ETWProviders", "WindowsEventLogs". + :ivar kind: Required. Datasource kind. Known values are: "PerformanceCounter", "ETWProviders", + "WindowsEventLogs". :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind :ivar configuration: Required. :vartype configuration: @@ -44,13 +46,13 @@ class DataSource(msrest.serialization.Model): def __init__( self, *, - kind: Union[str, "DataSourceKind"], - configuration: "DataSourceConfiguration", - sinks: List["SinkConfiguration"], + kind: Union[str, "_models.DataSourceKind"], + configuration: "_models.DataSourceConfiguration", + sinks: List["_models.SinkConfiguration"], **kwargs ): """ - :keyword kind: Required. Datasource kind. Possible values include: "PerformanceCounter", + :keyword kind: Required. Datasource kind. Known values are: "PerformanceCounter", "ETWProviders", "WindowsEventLogs". :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind :keyword configuration: Required. @@ -88,9 +90,9 @@ class DataSourceConfiguration(msrest.serialization.Model): def __init__( self, *, - providers: Optional[List["EtwProviderConfiguration"]] = None, - perf_counters: Optional[List["PerformanceCounterConfiguration"]] = None, - event_logs: Optional[List["EventLogConfiguration"]] = None, + providers: Optional[List["_models.EtwProviderConfiguration"]] = None, + perf_counters: Optional[List["_models.PerformanceCounterConfiguration"]] = None, + event_logs: Optional[List["_models.EventLogConfiguration"]] = None, **kwargs ): """ @@ -214,7 +216,7 @@ def __init__( self, *, id: str, - events: List["EtwEventConfiguration"], + events: List["_models.EtwEventConfiguration"], **kwargs ): """ @@ -285,7 +287,7 @@ class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GuestDiagnosticSettingsAssociationResource"]] = None, + value: Optional[List["_models.GuestDiagnosticSettingsAssociationResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -464,7 +466,7 @@ class GuestDiagnosticSettingsList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GuestDiagnosticSettingsResource"]] = None, + value: Optional[List["_models.GuestDiagnosticSettingsResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -485,7 +487,7 @@ class GuestDiagnosticSettingsPatchResource(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + :ivar os_type: Operating system type for the configuration. Known values are: "Windows", "Linux". :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -507,16 +509,16 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - os_type: Optional[Union[str, "GuestDiagnosticSettingsOsType"]] = None, - data_sources: Optional[List["DataSource"]] = None, + os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, + data_sources: Optional[List["_models.DataSource"]] = None, proxy_setting: Optional[str] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". + :keyword os_type: Operating system type for the configuration. Known values are: "Windows", + "Linux". :paramtype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType :keyword data_sources: the array of data source object which are configured to collect and send @@ -549,7 +551,7 @@ class GuestDiagnosticSettingsResource(Resource): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + :ivar os_type: Operating system type for the configuration. Known values are: "Windows", "Linux". :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType @@ -583,8 +585,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - os_type: Optional[Union[str, "GuestDiagnosticSettingsOsType"]] = None, - data_sources: Optional[List["DataSource"]] = None, + os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, + data_sources: Optional[List["_models.DataSource"]] = None, proxy_setting: Optional[str] = None, **kwargs ): @@ -593,8 +595,8 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". + :keyword os_type: Operating system type for the configuration. Known values are: "Windows", + "Linux". :paramtype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType :keyword data_sources: the array of data source object which are configured to collect and send @@ -660,8 +662,7 @@ class SinkConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar kind: Required. Possible values include: "EventHub", "ApplicationInsights", - "LogAnalytics". + :ivar kind: Required. Known values are: "EventHub", "ApplicationInsights", "LogAnalytics". :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ @@ -677,12 +678,11 @@ class SinkConfiguration(msrest.serialization.Model): def __init__( self, *, - kind: Union[str, "SinkConfigurationKind"], + kind: Union[str, "_models.SinkConfigurationKind"], **kwargs ): """ - :keyword kind: Required. Possible values include: "EventHub", "ApplicationInsights", - "LogAnalytics". + :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", "LogAnalytics". :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py index c0cdf7ff95e6..45fd9455475b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DataSourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataSourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Datasource kind """ @@ -19,14 +18,14 @@ class DataSourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ETW_PROVIDERS = "ETWProviders" WINDOWS_EVENT_LOGS = "WindowsEventLogs" -class GuestDiagnosticSettingsOsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GuestDiagnosticSettingsOsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operating system type for the configuration """ WINDOWS = "Windows" LINUX = "Linux" -class SinkConfigurationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SinkConfigurationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): EVENT_HUB = "EventHub" APPLICATION_INSIGHTS = "ApplicationInsights" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 3ba5f92c180a..8d3c00241fa2 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 @@ -9,7 +9,12 @@ from ._guest_diagnostics_settings_association_operations import GuestDiagnosticsSettingsAssociationOperations 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 patch_sdk as _patch_sdk __all__ = [ 'GuestDiagnosticsSettingsAssociationOperations', 'GuestDiagnosticsSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f0b56e14d6de..54edeb08084d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,38 +31,39 @@ def build_create_or_update_request( resource_uri: str, association_name: str, *, - json: JSONType = None, + json: Optional[_models.GuestDiagnosticSettingsAssociationResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-06-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,30 +75,32 @@ def build_get_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,30 +110,32 @@ def build_delete_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -139,38 +144,39 @@ def build_update_request( resource_uri: str, association_name: str, *, - json: JSONType = None, + json: Optional[_models.GuestDiagnosticSettingsAssociationResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-06-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -181,29 +187,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -213,63 +221,63 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GuestDiagnosticsSettingsAssociationOperations(object): - """GuestDiagnosticsSettingsAssociationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GuestDiagnosticsSettingsAssociationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_06_01_preview.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings_association` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_uri: str, association_name: str, - diagnostic_settings_association: "_models.GuestDiagnosticSettingsAssociationResource", + diagnostic_settings_association: _models.GuestDiagnosticSettingsAssociationResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Creates or updates guest diagnostics settings association. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -287,27 +295,38 @@ def create_or_update( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') request = build_create_or_update_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -326,7 +345,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + create_or_update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace @@ -335,7 +354,7 @@ def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Gets guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -349,22 +368,34 @@ def get( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,11 +410,11 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -401,22 +432,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,7 +470,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -435,9 +478,9 @@ def update( self, resource_uri: str, association_name: str, - parameters: "_models.GuestDiagnosticSettingsAssociationResourcePatch", + parameters: _models.GuestDiagnosticSettingsAssociationResourcePatch, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsAssociationResource": + ) -> _models.GuestDiagnosticSettingsAssociationResource: """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use the CreateOrUpdate method. @@ -455,27 +498,38 @@ def update( ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') request = build_update_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,14 +544,14 @@ def update( return deserialized - update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + update.metadata = {'url': "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"]: + ) -> Iterable[_models.GuestDiagnosticSettingsAssociationList]: """Get a list of all guest diagnostic settings association in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -507,29 +561,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -543,7 +608,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -557,14 +626,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"]: + ) -> Iterable[_models.GuestDiagnosticSettingsAssociationList]: """Get a list of all guest diagnostic settings association in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -576,31 +645,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -614,7 +694,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -628,4 +712,4 @@ 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"} # type: ignore 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 ec1a75a48f6b..c51c0ce26110 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( diagnostic_settings_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GuestDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-06-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -111,39 +114,40 @@ def build_update_request( diagnostic_settings_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.GuestDiagnosticSettingsPatchResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-06-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,31 +160,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -189,29 +195,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,63 +229,63 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class GuestDiagnosticsSettingsOperations(object): - """GuestDiagnosticsSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GuestDiagnosticsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_06_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_06_01_preview.MonitorManagementClient`'s + :attr:`guest_diagnostics_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, diagnostic_settings_name: str, - diagnostic_settings: "_models.GuestDiagnosticSettingsResource", + diagnostic_settings: _models.GuestDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Creates or updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -292,13 +300,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') @@ -306,14 +318,21 @@ def create_or_update( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +351,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -341,7 +360,7 @@ def get( resource_group_name: str, diagnostic_settings_name: str, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Gets guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,23 +372,35 @@ def get( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] request = build_get_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,7 +415,7 @@ 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}"} # type: ignore @distributed_trace @@ -392,9 +423,9 @@ def update( self, resource_group_name: str, diagnostic_settings_name: str, - parameters: "_models.GuestDiagnosticSettingsPatchResource", + parameters: _models.GuestDiagnosticSettingsPatchResource, **kwargs: Any - ) -> "_models.GuestDiagnosticSettingsResource": + ) -> _models.GuestDiagnosticSettingsResource: """Updates guest diagnostics settings. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -409,13 +440,17 @@ def update( :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') @@ -423,14 +458,21 @@ def update( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -449,11 +491,11 @@ def update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, diagnostic_settings_name: str, @@ -470,23 +512,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, diagnostic_settings_name=diagnostic_settings_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -497,14 +551,14 @@ def delete( 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsList"]: + ) -> Iterable[_models.GuestDiagnosticSettingsList]: """Get a list of all guest diagnostic settings in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -514,29 +568,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +615,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,14 +633,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GuestDiagnosticSettingsList"]: + ) -> Iterable[_models.GuestDiagnosticSettingsList]: """Get a list of all guest diagnostic settings in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -583,31 +652,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -621,7 +701,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -635,4 +719,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 58852411de43..a8eb4584c7e8 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-09-01" + 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) 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 55a9c50840f2..e2a8dbb9ee3d 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -97,8 +97,6 @@ "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": { - "action_groups": "ActionGroupsOperations", - "metric_baseline": "MetricBaselineOperations", - "baseline": "BaselineOperations" + "action_groups": "ActionGroupsOperations" } } \ 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 ac4a74437887..1f6b95eb2d8e 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 @@ -7,15 +7,16 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselineOperations, MetricBaselineOperations +from .operations import ActionGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -26,17 +27,15 @@ class MonitorManagementClient: :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2018_09_01.operations.ActionGroupsOperations - :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: - $(python-base-namespace).v2018_09_01.operations.MetricBaselineOperations - :ivar baseline: BaselineOperations operations - :vartype baseline: $(python-base-namespace).v2018_09_01.operations.BaselineOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -53,14 +52,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.baseline = BaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 3149ad11a362..6eba1f68a2b8 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-09-01" + 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) 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 13df9dc4d055..d9d12c4647a1 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 @@ -7,15 +7,16 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations, BaselineOperations, MetricBaselineOperations +from .operations import ActionGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -27,17 +28,15 @@ class MonitorManagementClient: :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2018_09_01.aio.operations.ActionGroupsOperations - :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: - $(python-base-namespace).v2018_09_01.aio.operations.MetricBaselineOperations - :ivar baseline: BaselineOperations operations - :vartype baseline: $(python-base-namespace).v2018_09_01.aio.operations.BaselineOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -54,9 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.baseline = BaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 636f48f0362a..60f9d62f0ead 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from ._action_groups_operations import ActionGroupsOperations -from ._metric_baseline_operations import MetricBaselineOperations -from ._baseline_operations import BaselineOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', - 'MetricBaselineOperations', - 'BaselineOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 0ba01330e7c1..5d4ec502c39a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_09_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -81,14 +83,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -231,13 +264,17 @@ async def update( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -245,14 +282,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,14 +311,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -283,29 +327,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,7 +374,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,14 +392,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -351,31 +410,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +459,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,14 +477,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -427,13 +501,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -441,14 +519,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -459,5 +544,5 @@ async def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py deleted file mode 100644 index 13ea4d73c051..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._baseline_operations import build_get_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class BaselineOperations: - """BaselineOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace_async - async def get( - self, - resource_uri: str, - metricnames: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a - metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. - :type metricnames: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. - :type metricnamespace: str - :param filter: The **$filter** is used to describe a set of dimensions with their concrete - values which produce a specific metric's time series, in which a baseline is requested for. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metricnames=metricnames, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - metricnamespace=metricnamespace, - filter=filter, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline'} # type: ignore - diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py deleted file mode 100644 index 2837800f421e..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._metric_baseline_operations import build_calculate_baseline_request, build_get_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MetricBaselineOperations: - """MetricBaselineOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace_async - async def get( - self, - resource_uri: str, - metric_name: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a specific metric**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metric_name: The name of the metric to retrieve the baseline for. - :type metric_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. - :type metricnamespace: str - :param filter: The **$filter** is used to describe a set of dimensions with their concrete - values which produce a specific metric's time series, in which a baseline is requested for. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metric_name=metric_name, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - metricnamespace=metricnamespace, - filter=filter, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore - - - @distributed_trace_async - async def calculate_baseline( - self, - resource_uri: str, - time_series_information: "_models.TimeSeriesInformation", - **kwargs: Any - ) -> "_models.CalculateBaselineResponse": - """**Lists the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param time_series_information: Information that need to be specified to calculate a baseline - on a time series. - :type time_series_information: - ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CalculateBaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateBaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - - request = build_calculate_baseline_request( - resource_uri=resource_uri, - content_type=content_type, - json=_json, - template_url=self.calculate_baseline.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore - diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ea8c1f240a93..72f3b0ed20c0 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 @@ -13,32 +13,23 @@ from ._models_py3 import AutomationRunbookReceiver from ._models_py3 import AzureAppPushReceiver from ._models_py3 import AzureFunctionReceiver -from ._models_py3 import Baseline -from ._models_py3 import BaselineMetadataValue -from ._models_py3 import BaselineResponse -from ._models_py3 import CalculateBaselineResponse -from ._models_py3 import CalculateBaselineResponseStatistics from ._models_py3 import EmailReceiver from ._models_py3 import EnableRequest from ._models_py3 import ErrorResponse from ._models_py3 import ItsmReceiver -from ._models_py3 import LocalizableString from ._models_py3 import LogicAppReceiver from ._models_py3 import Resource from ._models_py3 import SmsReceiver -from ._models_py3 import TimeSeriesInformation from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver from ._monitor_management_client_enums import ( - ErrorType, - PredictionResultType, ReceiverStatus, - ResultType, - Sensitivity, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ActionGroupList', 'ActionGroupPatchBody', @@ -47,25 +38,16 @@ 'AutomationRunbookReceiver', 'AzureAppPushReceiver', 'AzureFunctionReceiver', - 'Baseline', - 'BaselineMetadataValue', - 'BaselineResponse', - 'CalculateBaselineResponse', - 'CalculateBaselineResponseStatistics', 'EmailReceiver', 'EnableRequest', 'ErrorResponse', 'ItsmReceiver', - 'LocalizableString', 'LogicAppReceiver', 'Resource', 'SmsReceiver', - 'TimeSeriesInformation', 'VoiceReceiver', 'WebhookReceiver', - 'ErrorType', - 'PredictionResultType', 'ReceiverStatus', - 'ResultType', - 'Sensitivity', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 6f09b8bfb067..8f6c2c062132 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 @@ -6,13 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ActionGroupList(msrest.serialization.Model): @@ -32,7 +33,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -223,16 +224,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + 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 ): """ @@ -503,337 +504,6 @@ def __init__( self.http_trigger_url = http_trigger_url -class Baseline(msrest.serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivity: Required. The sensitivity of the baseline. Possible values include: "Low", - "Medium", "High". - :vartype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity - :ivar low_thresholds: Required. The low thresholds of the baseline. - :vartype low_thresholds: list[float] - :ivar high_thresholds: Required. The high thresholds of the baseline. - :vartype high_thresholds: list[float] - :ivar timestamps: the array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - :ivar prediction_result_type: The prediction result type of the baseline. Possible values - include: 0, 1, 2. - :vartype prediction_result_type: int or - ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, - 200. - :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - """ - - _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, - } - - _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'prediction_result_type': {'key': 'PredictionResultType', 'type': 'int'}, - 'error_type': {'key': 'ErrorType', 'type': 'int'}, - } - - def __init__( - self, - *, - sensitivity: Union[str, "Sensitivity"], - low_thresholds: List[float], - high_thresholds: List[float], - timestamps: Optional[List[datetime.datetime]] = None, - prediction_result_type: Optional[Union[int, "PredictionResultType"]] = None, - error_type: Optional[Union[int, "ErrorType"]] = None, - **kwargs - ): - """ - :keyword sensitivity: Required. The sensitivity of the baseline. Possible values include: - "Low", "Medium", "High". - :paramtype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity - :keyword low_thresholds: Required. The low thresholds of the baseline. - :paramtype low_thresholds: list[float] - :keyword high_thresholds: Required. The high thresholds of the baseline. - :paramtype high_thresholds: list[float] - :keyword timestamps: the array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - :keyword prediction_result_type: The prediction result type of the baseline. Possible values - include: 0, 1, 2. - :paramtype prediction_result_type: int or - ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, - 100, 200. - :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - """ - super(Baseline, self).__init__(**kwargs) - self.sensitivity = sensitivity - self.low_thresholds = low_thresholds - self.high_thresholds = high_thresholds - self.timestamps = timestamps - self.prediction_result_type = prediction_result_type - self.error_type = error_type - - -class BaselineMetadataValue(msrest.serialization.Model): - """Represents a baseline metadata value. - - :ivar name: The name of the metadata. - :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :ivar value: The value of the metadata. - :vartype value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional["LocalizableString"] = None, - value: Optional[str] = None, - **kwargs - ): - """ - :keyword name: The name of the metadata. - :paramtype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :keyword value: The value of the metadata. - :paramtype value: str - """ - super(BaselineMetadataValue, self).__init__(**kwargs) - self.name = name - self.value = value - - -class BaselineResponse(msrest.serialization.Model): - """The response to a baseline query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The metric baseline ID. - :vartype id: str - :ivar type: The resource type of the baseline resource. - :vartype type: str - :ivar name: The name and the display name of the metric, i.e. it is localizable string. - :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :ivar timestamps: The array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - :ivar baseline: The baseline values for each sensitivity. - :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :ivar metdata: The baseline metadata values. - :vartype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] - :ivar prediction_result_type: The prediction result type of the baseline. Possible values - include: 0, 1, 2. - :vartype prediction_result_type: int or - ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, - 200. - :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - :ivar 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 - from what was originally requested. - :vartype timespan: str - :ivar interval: The interval (window size) for which the metric data was returned in. This may - be adjusted in the future and returned back from what was originally requested. This is not - present if a metadata request was made. - :vartype interval: ~datetime.timedelta - :ivar aggregation: The aggregation type of the metric. - :vartype aggregation: str - :ivar internal_operation_id: internal operation id. - :vartype internal_operation_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'internal_operation_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, - 'metdata': {'key': 'metdata', 'type': '[BaselineMetadataValue]'}, - 'prediction_result_type': {'key': 'predictionResultType', 'type': 'int'}, - 'error_type': {'key': 'errorType', 'type': 'int'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, - 'internal_operation_id': {'key': 'properties.internalOperationId', 'type': 'str'}, - } - - def __init__( - self, - *, - timestamps: Optional[List[datetime.datetime]] = None, - baseline: Optional[List["Baseline"]] = None, - metdata: Optional[List["BaselineMetadataValue"]] = None, - prediction_result_type: Optional[Union[int, "PredictionResultType"]] = None, - error_type: Optional[Union[int, "ErrorType"]] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - **kwargs - ): - """ - :keyword timestamps: The array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - :keyword baseline: The baseline values for each sensitivity. - :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :keyword metdata: The baseline metadata values. - :paramtype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] - :keyword prediction_result_type: The prediction result type of the baseline. Possible values - include: 0, 1, 2. - :paramtype prediction_result_type: int or - ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, - 100, 200. - :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - :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 - from what was originally requested. - :paramtype timespan: str - :keyword interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :paramtype interval: ~datetime.timedelta - :keyword aggregation: The aggregation type of the metric. - :paramtype aggregation: str - """ - super(BaselineResponse, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.timestamps = timestamps - self.baseline = baseline - self.metdata = metdata - self.prediction_result_type = prediction_result_type - self.error_type = error_type - self.timespan = timespan - self.interval = interval - self.aggregation = aggregation - self.internal_operation_id = None - - -class CalculateBaselineResponse(msrest.serialization.Model): - """The response to a calculate baseline call. - - 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 type: Required. The resource type of the baseline resource. - :vartype type: str - :ivar timestamps: The array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - :ivar baseline: Required. The baseline values for each sensitivity. - :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :ivar statistics: The statistics. - :vartype statistics: - ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics - :ivar internal_operation_id: internal operation id. - :vartype internal_operation_id: str - :ivar error_type: The error type for calculating the baseline. Possible values include: 0, 1, - 2, 3, 4, 100, 200. - :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - """ - - _validation = { - 'type': {'required': True}, - 'baseline': {'required': True}, - 'internal_operation_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, - 'statistics': {'key': 'statistics', 'type': 'CalculateBaselineResponseStatistics'}, - 'internal_operation_id': {'key': 'internalOperationId', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'int'}, - } - - def __init__( - self, - *, - type: str, - baseline: List["Baseline"], - timestamps: Optional[List[datetime.datetime]] = None, - statistics: Optional["CalculateBaselineResponseStatistics"] = None, - error_type: Optional[Union[int, "ErrorType"]] = None, - **kwargs - ): - """ - :keyword type: Required. The resource type of the baseline resource. - :paramtype type: str - :keyword timestamps: The array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - :keyword baseline: Required. The baseline values for each sensitivity. - :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :keyword statistics: The statistics. - :paramtype statistics: - ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics - :keyword error_type: The error type for calculating the baseline. Possible values include: 0, - 1, 2, 3, 4, 100, 200. - :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType - """ - super(CalculateBaselineResponse, self).__init__(**kwargs) - self.type = type - self.timestamps = timestamps - self.baseline = baseline - self.statistics = statistics - self.internal_operation_id = None - self.error_type = error_type - - -class CalculateBaselineResponseStatistics(msrest.serialization.Model): - """The statistics. - - :ivar is_eligible: is series eligible for dynamic threshold analysis. - :vartype is_eligible: bool - :ivar status: The list of extended status for calculating the baseline. - :vartype status: list[str] - :ivar seasonality_period: The seasonality period for calculating the baseline. - :vartype seasonality_period: int - """ - - _attribute_map = { - 'is_eligible': {'key': 'isEligible', 'type': 'bool'}, - 'status': {'key': 'status', 'type': '[str]'}, - 'seasonality_period': {'key': 'seasonalityPeriod', 'type': 'int'}, - } - - def __init__( - self, - *, - is_eligible: Optional[bool] = None, - status: Optional[List[str]] = None, - seasonality_period: Optional[int] = None, - **kwargs - ): - """ - :keyword is_eligible: is series eligible for dynamic threshold analysis. - :paramtype is_eligible: bool - :keyword status: The list of extended status for calculating the baseline. - :paramtype status: list[str] - :keyword seasonality_period: The seasonality period for calculating the baseline. - :paramtype seasonality_period: int - """ - super(CalculateBaselineResponseStatistics, self).__init__(**kwargs) - self.is_eligible = is_eligible - self.status = status - self.seasonality_period = seasonality_period - - class EmailReceiver(msrest.serialization.Model): """An email receiver. @@ -846,8 +516,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype name: str :ivar email_address: Required. The email address of this receiver. :vartype email_address: str - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus """ @@ -1017,44 +687,6 @@ def __init__( self.region = region -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - All required parameters must be populated in order to send to Azure. - - :ivar value: Required. The invariant value. - :vartype value: str - :ivar localized_value: The locale specific value. - :vartype localized_value: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - *, - value: str, - localized_value: Optional[str] = None, - **kwargs - ): - """ - :keyword value: Required. The invariant value. - :paramtype value: str - :keyword localized_value: The locale specific value. - :paramtype localized_value: str - """ - super(LocalizableString, self).__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - class LogicAppReceiver(msrest.serialization.Model): """A logic app receiver. @@ -1118,7 +750,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus """ @@ -1161,52 +793,6 @@ def __init__( self.status = None -class TimeSeriesInformation(msrest.serialization.Model): - """The time series info needed for calculating the baseline. - - All required parameters must be populated in order to send to Azure. - - :ivar sensitivities: Required. The list of sensitivities for calculating the baseline. - :vartype sensitivities: list[str] - :ivar values: Required. The metric values to calculate the baseline. - :vartype values: list[float] - :ivar timestamps: The array of timestamps of the baselines. - :vartype timestamps: list[~datetime.datetime] - """ - - _validation = { - 'sensitivities': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'sensitivities': {'key': 'sensitivities', 'type': '[str]'}, - 'values': {'key': 'values', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - *, - sensitivities: List[str], - values: List[float], - timestamps: Optional[List[datetime.datetime]] = None, - **kwargs - ): - """ - :keyword sensitivities: Required. The list of sensitivities for calculating the baseline. - :paramtype sensitivities: list[str] - :keyword values: Required. The metric values to calculate the baseline. - :paramtype values: list[float] - :keyword timestamps: The array of timestamps of the baselines. - :paramtype timestamps: list[~datetime.datetime] - """ - super(TimeSeriesInformation, self).__init__(**kwargs) - self.sensitivities = sensitivities - self.values = values - self.timestamps = timestamps - - class VoiceReceiver(msrest.serialization.Model): """A voice receiver. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py index 200d8caf46bb..2502d854d186 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py @@ -7,31 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ErrorType(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): - """The error type of the baseline. - """ - - ZERO = 0 - ONE = 1 - TWO = 2 - THREE = 3 - FOUR = 4 - ONE_HUNDRED = 100 - TWO_HUNDRED = 200 - -class PredictionResultType(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): - """The prediction result type of the baseline. - """ - - ZERO = 0 - ONE = 1 - TWO = 2 - -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ @@ -39,16 +18,3 @@ class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOT_SPECIFIED = "NotSpecified" ENABLED = "Enabled" DISABLED = "Disabled" - -class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - - DATA = "Data" - METADATA = "Metadata" - -class Sensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The sensitivity of the baseline. - """ - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 636f48f0362a..60f9d62f0ead 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from ._action_groups_operations import ActionGroupsOperations -from ._metric_baseline_operations import MetricBaselineOperations -from ._baseline_operations import BaselineOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', - 'MetricBaselineOperations', - 'BaselineOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 56910bb93299..4ff55d45bc51 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,30 +229,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -254,74 +264,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_09_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -335,13 +344,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -349,14 +362,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -375,7 +395,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -384,7 +404,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -396,23 +416,35 @@ def get( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +459,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -448,23 +480,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,7 +519,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -483,9 +527,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -499,13 +543,17 @@ def update( :rtype: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -513,14 +561,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,14 +590,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -551,29 +606,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,7 +653,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,14 +671,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -619,31 +689,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -657,7 +738,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -671,14 +756,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -695,13 +780,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -709,14 +798,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -727,5 +823,5 @@ def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py deleted file mode 100644 index 991aea74f1e0..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py +++ /dev/null @@ -1,191 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer - -from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - -def build_get_request( - resource_uri: str, - *, - metricnames: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" - # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline') - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if metricnames is not None: - query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') - if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class BaselineOperations(object): - """BaselineOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace - def get( - self, - resource_uri: str, - metricnames: Optional[str] = None, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a - metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. - :type metricnames: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. - :type metricnamespace: str - :param filter: The **$filter** is used to describe a set of dimensions with their concrete - values which produce a specific metric's time series, in which a baseline is requested for. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metricnames=metricnames, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - metricnamespace=metricnamespace, - filter=filter, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline'} # type: ignore - diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py deleted file mode 100644 index 100616099a95..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py +++ /dev/null @@ -1,289 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer - -from .. import models as _models -from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - -def build_get_request( - resource_uri: str, - metric_name: str, - *, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - api_version = "2018-09-01" - accept = "application/json" - # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}') - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - "metricName": _SERIALIZER.url("metric_name", metric_name, 'str'), - } - - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_calculate_baseline_request( - resource_uri: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - - api_version = "2018-09-01" - accept = "application/json" - # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline') - path_format_arguments = { - "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class MetricBaselineOperations(object): - """MetricBaselineOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - @distributed_trace - def get( - self, - resource_uri: str, - metric_name: str, - timespan: Optional[str] = None, - interval: Optional[datetime.timedelta] = None, - aggregation: Optional[str] = None, - sensitivities: Optional[str] = None, - result_type: Optional[Union[str, "_models.ResultType"]] = None, - metricnamespace: Optional[str] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> "_models.BaselineResponse": - """**Gets the baseline values for a specific metric**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param metric_name: The name of the metric to retrieve the baseline for. - :type metric_name: str - :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. - :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric to retrieve the baseline for. - :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. - :type sensitivities: str - :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. - :type result_type: str or ~$(python-base-namespace).v2018_09_01.models.ResultType - :param metricnamespace: Metric namespace to query metric definitions for. - :type metricnamespace: str - :param filter: The **$filter** is used to describe a set of dimensions with their concrete - values which produce a specific metric's time series, in which a baseline is requested for. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: BaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.BaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - - request = build_get_request( - resource_uri=resource_uri, - metric_name=metric_name, - timespan=timespan, - interval=interval, - aggregation=aggregation, - sensitivities=sensitivities, - result_type=result_type, - metricnamespace=metricnamespace, - filter=filter, - template_url=self.get.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('BaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore - - - @distributed_trace - def calculate_baseline( - self, - resource_uri: str, - time_series_information: "_models.TimeSeriesInformation", - **kwargs: Any - ) -> "_models.CalculateBaselineResponse": - """**Lists the baseline values for a resource**. - - :param resource_uri: The identifier of the resource. It has the following structure: - subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. - For example: - subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1. - :type resource_uri: str - :param time_series_information: Information that need to be specified to calculate a baseline - on a time series. - :type time_series_information: - ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CalculateBaselineResponse, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateBaselineResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - - request = build_calculate_baseline_request( - resource_uri=resource_uri, - content_type=content_type, - json=_json, - template_url=self.calculate_baseline.metadata['url'], - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore - diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 97fb7d1dca33..3ae4f05c4eb6 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-27-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2018-11-27-preview" + 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) 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 f48dd5306487..4eda122cd5ec 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 a614ecab0d59..cfcad63da399 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -29,8 +30,11 @@ class MonitorManagementClient: $(python-base-namespace).v2018_11_27_preview.operations.VMInsightsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -46,12 +50,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.vm_insights = VMInsightsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 77ea6d2eeead..bb21c5db7403 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-27-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2018-11-27-preview" + 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) 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 d7e018bff1c2..b6d69e9d5b2c 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -29,8 +30,11 @@ class MonitorManagementClient: $(python-base-namespace).v2018_11_27_preview.aio.operations.VMInsightsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-27-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -46,7 +50,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.vm_insights = VMInsightsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 4cae115ca323..5e4c85044f19 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'VMInsightsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 19cbf3f37127..8c05069a0516 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +23,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VMInsightsOperations: - """VMInsightsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_11_27_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_11_27_preview.aio.MonitorManagementClient`'s + :attr:`vm_insights` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_onboarding_status( self, resource_uri: str, **kwargs: Any - ) -> "_models.VMInsightsOnboardingStatus": + ) -> _models.VMInsightsOnboardingStatus: """Retrieves the VM Insights onboarding status for the specified resource or resource scope. :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or @@ -60,21 +58,33 @@ async def get_onboarding_status( :rtype: ~$(python-base-namespace).v2018_11_27_preview.models.VMInsightsOnboardingStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VMInsightsOnboardingStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VMInsightsOnboardingStatus] request = build_get_onboarding_status_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get_onboarding_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -89,5 +99,5 @@ async def get_onboarding_status( 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"} # type: ignore 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 f574db4714d0..bee6c414166c 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 @@ -18,7 +18,9 @@ DataStatus, OnboardingStatus, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DataContainer', 'Error', @@ -29,3 +31,5 @@ 'DataStatus', 'OnboardingStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 c30e574ee7a6..a3cc7d54ec74 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class DataContainer(msrest.serialization.Model): @@ -34,7 +36,7 @@ class DataContainer(msrest.serialization.Model): def __init__( self, *, - workspace: "WorkspaceInfo", + workspace: "_models.WorkspaceInfo", **kwargs ): """ @@ -140,7 +142,7 @@ class ResponseWithError(msrest.serialization.Model): def __init__( self, *, - error: "Error", + error: "_models.Error", **kwargs ): """ @@ -167,12 +169,12 @@ class VMInsightsOnboardingStatus(ProxyResource): :vartype resource_id: str :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". + under it is onboarded. Known values are: "onboarded", "notOnboarded", "unknown". :vartype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus :ivar data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Possible values include: "present", "notPresent". + the specified resource is being routed. Known values are: "present", "notPresent". :vartype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus :ivar data: Containers that currently store VM Insights data for the specified resource. :vartype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] @@ -198,9 +200,9 @@ def __init__( self, *, resource_id: Optional[str] = None, - onboarding_status: Optional[Union[str, "OnboardingStatus"]] = None, - data_status: Optional[Union[str, "DataStatus"]] = None, - data: Optional[List["DataContainer"]] = None, + onboarding_status: Optional[Union[str, "_models.OnboardingStatus"]] = None, + data_status: Optional[Union[str, "_models.DataStatus"]] = None, + data: Optional[List["_models.DataContainer"]] = None, **kwargs ): """ @@ -209,12 +211,12 @@ def __init__( :paramtype resource_id: str :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource - under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". + under it is onboarded. Known values are: "onboarded", "notOnboarded", "unknown". :paramtype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus :keyword data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for - the specified resource is being routed. Possible values include: "present", "notPresent". + the specified resource is being routed. Known values are: "present", "notPresent". :paramtype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus :keyword data: Containers that currently store VM Insights data for the specified resource. :paramtype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py index b3c335135ef7..0dc94d4b599e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class DataStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for the specified resource is being routed. @@ -20,7 +19,7 @@ class DataStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRESENT = "present" NOT_PRESENT = "notPresent" -class OnboardingStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OnboardingStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 4cae115ca323..5e4c85044f19 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'VMInsightsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 e49f0661d35e..273157392acd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -29,60 +30,60 @@ def build_get_onboarding_status_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-27-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class VMInsightsOperations(object): - """VMInsightsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VMInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2018_11_27_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2018_11_27_preview.MonitorManagementClient`'s + :attr:`vm_insights` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get_onboarding_status( self, resource_uri: str, **kwargs: Any - ) -> "_models.VMInsightsOnboardingStatus": + ) -> _models.VMInsightsOnboardingStatus: """Retrieves the VM Insights onboarding status for the specified resource or resource scope. :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or @@ -93,21 +94,33 @@ def get_onboarding_status( :rtype: ~$(python-base-namespace).v2018_11_27_preview.models.VMInsightsOnboardingStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VMInsightsOnboardingStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-27-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VMInsightsOnboardingStatus] request = build_get_onboarding_status_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.get_onboarding_status.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,5 +135,5 @@ def get_onboarding_status( 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"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 104015108097..3911a9297d3d 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-01" + 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) 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 ec859da410c4..26b88ebb750e 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 6c955bb8086c..5a0b47ac2e83 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -32,8 +33,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -50,13 +54,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.baselines = BaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 1c02bc997da3..e20c8250f686 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-03-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-03-01" + 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) 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 a91a75c74e1c..4596f73b543e 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -33,8 +34,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-03-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -51,8 +55,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.baselines = BaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 1c9050bc3370..62e8fdde212b 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 @@ -9,7 +9,12 @@ from ._action_groups_operations import ActionGroupsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'BaselinesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 676c2e368db1..b0e110f90588 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_03_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -81,14 +83,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -231,13 +264,17 @@ async def update( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -245,14 +282,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,14 +311,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -283,29 +327,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,7 +374,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,14 +392,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -351,31 +410,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +459,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,14 +477,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -427,13 +501,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -441,14 +519,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -459,5 +544,5 @@ async def enable_receiver( 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"} # type: ignore 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 d785c4ebe121..6e677f3f862b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,7 +15,7 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -26,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BaselinesOperations: - """BaselinesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_03_01.aio.MonitorManagementClient`'s + :attr:`baselines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -60,25 +57,28 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.MetricBaselinesResponse"]: + ) -> AsyncIterable[_models.MetricBaselinesResponse]: """**Lists the metric baseline values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Default value is None. :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. + :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is + None. :type sensitivities: str :param filter: The **$filter** is used to reduce the set of metric data returned. Example: Metric contains metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or @@ -91,10 +91,10 @@ def list( Instead of using $filter= "dim (test) 1 eq '\ *' " use **$filter= "dim %2528test%2529 1 eq '*\ ' "\ ** When dimension name is **\ dim (test) 3\ ** and dimension value is **\ dim3 (test) val\ ** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " use **\ $filter= "dim - %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. + %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. + information is retrieved. Default value is None. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricBaselinesResponse or the result of @@ -103,16 +103,22 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricBaselinesResponse"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -122,14 +128,17 @@ def prepare_request(next_link=None): filter=filter, result_type=result_type, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -139,9 +148,11 @@ def prepare_request(next_link=None): filter=filter, result_type=result_type, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -155,7 +166,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,4 +184,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 10b07dab50dc..c66b69ce31cd 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 @@ -35,7 +35,9 @@ ReceiverStatus, ResultType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ActionGroupList', 'ActionGroupPatchBody', @@ -63,3 +65,5 @@ 'ReceiverStatus', 'ResultType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 2d8ad2bb5632..f7ca10c5a949 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ActionGroupList(msrest.serialization.Model): @@ -32,7 +34,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -94,10 +96,6 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -108,8 +106,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, } @@ -117,8 +113,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } @@ -140,8 +134,6 @@ def __init__( self.id = None self.name = None self.type = None - self.kind = None - self.identity = None self.location = location self.tags = tags @@ -159,10 +151,6 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -206,8 +194,6 @@ class ActionGroupResource(AzureResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, 'group_short_name': {'max_length': 12, 'min_length': 0}, } @@ -216,8 +202,6 @@ class ActionGroupResource(AzureResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, @@ -241,16 +225,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + 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 ): """ @@ -595,8 +579,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus """ @@ -841,7 +825,7 @@ class MetricBaselinesResponse(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SingleMetricBaseline"]] = None, + value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs ): """ @@ -896,7 +880,7 @@ class SingleBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", "Medium", "High". :vartype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity :ivar low_thresholds: Required. The low thresholds of the baseline. @@ -920,14 +904,14 @@ class SingleBaseline(msrest.serialization.Model): def __init__( self, *, - sensitivity: Union[str, "BaselineSensitivity"], + sensitivity: Union[str, "_models.BaselineSensitivity"], low_thresholds: List[float], high_thresholds: List[float], **kwargs ): """ - :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: - "Low", "Medium", "High". + :keyword sensitivity: Required. the sensitivity of the baseline. Known values are: "Low", + "Medium", "High". :paramtype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity :keyword low_thresholds: Required. The low thresholds of the baseline. :paramtype low_thresholds: list[float] @@ -992,7 +976,7 @@ def __init__( name: str, timespan: str, interval: datetime.timedelta, - baselines: List["TimeSeriesBaseline"], + baselines: List["_models.TimeSeriesBaseline"], namespace: Optional[str] = None, **kwargs ): @@ -1040,7 +1024,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus """ @@ -1119,9 +1103,9 @@ def __init__( *, aggregation: str, timestamps: List[datetime.datetime], - data: List["SingleBaseline"], - dimensions: Optional[List["MetricSingleDimension"]] = None, - metadata_values: Optional[List["BaselineMetadata"]] = None, + data: List["_models.SingleBaseline"], + dimensions: Optional[List["_models.MetricSingleDimension"]] = None, + metadata_values: Optional[List["_models.BaselineMetadata"]] = None, **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py index 1bae2278d5d3..c68a974106d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class BaselineSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BaselineSensitivity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the sensitivity of the baseline. """ @@ -19,7 +18,7 @@ class BaselineSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MEDIUM = "Medium" HIGH = "High" -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ @@ -28,7 +27,7 @@ class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 1c9050bc3370..62e8fdde212b 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 @@ -9,7 +9,12 @@ from ._action_groups_operations import ActionGroupsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', 'BaselinesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 6c31bafc5938..38736cc5f94f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,30 +229,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -254,74 +264,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-03-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_03_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -335,13 +344,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -349,14 +362,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -375,7 +395,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -384,7 +404,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -396,23 +416,35 @@ def get( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +459,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -448,23 +480,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,7 +519,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -483,9 +527,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -499,13 +543,17 @@ def update( :rtype: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -513,14 +561,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,14 +590,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -551,29 +606,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,7 +653,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,14 +671,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -619,31 +689,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -657,7 +738,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -671,14 +756,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -695,13 +780,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -709,14 +798,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -727,5 +823,5 @@ def enable_receiver( 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"} # type: ignore 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 acdd6b3620b6..c0a20ce41777 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,8 +17,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -40,69 +41,69 @@ def build_list_request( result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-03-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricBaselines') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/metricBaselines") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if metricnames is not None: - query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + _params['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') if metricnamespace is not None: - query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + _params['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') if timespan is not None: - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') if interval is not None: - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') if aggregation is not None: - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') if sensitivities is not None: - query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + _params['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if result_type is not None: - query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BaselinesOperations(object): - """BaselinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BaselinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_03_01.MonitorManagementClient`'s + :attr:`baselines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -117,25 +118,28 @@ def list( filter: Optional[str] = None, result_type: Optional[Union[str, "_models.ResultType"]] = None, **kwargs: Any - ) -> Iterable["_models.MetricBaselinesResponse"]: + ) -> Iterable[_models.MetricBaselinesResponse]: """**Lists the metric baseline values for a resource**. :param resource_uri: The identifier of the resource. :type resource_uri: str :param metricnames: The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be - **'Metric%2Name1'**. + **'Metric%2Name1'**. Default value is None. :type metricnames: str - :param metricnamespace: Metric namespace to query metric definitions for. + :param metricnamespace: Metric namespace to query metric definitions for. Default value is + None. :type metricnamespace: str :param timespan: The timespan of the query. It is a string with the following format - 'startDateTime_ISO/endDateTime_ISO'. + 'startDateTime_ISO/endDateTime_ISO'. Default value is None. :type timespan: str - :param interval: The interval (i.e. timegrain) of the query. + :param interval: The interval (i.e. timegrain) of the query. Default value is None. :type interval: ~datetime.timedelta - :param aggregation: The list of aggregation types (comma separated) to retrieve. + :param aggregation: The list of aggregation types (comma separated) to retrieve. Default value + is None. :type aggregation: str - :param sensitivities: The list of sensitivities (comma separated) to retrieve. + :param sensitivities: The list of sensitivities (comma separated) to retrieve. Default value is + None. :type sensitivities: str :param filter: The **$filter** is used to reduce the set of metric data returned. Example: Metric contains metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or @@ -148,10 +152,10 @@ def list( Instead of using $filter= "dim (test) 1 eq '\ *' " use **$filter= "dim %2528test%2529 1 eq '*\ ' "\ ** When dimension name is **\ dim (test) 3\ ** and dimension value is **\ dim3 (test) val\ ** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " use **\ $filter= "dim - %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. + %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. Default value is None. :type filter: str :param result_type: Allows retrieving only metadata of the baseline. On data request all - information is retrieved. + information is retrieved. Default value is None. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricBaselinesResponse or the result of @@ -160,16 +164,22 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricBaselinesResponse"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -179,14 +189,17 @@ def prepare_request(next_link=None): filter=filter, result_type=result_type, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, metricnames=metricnames, metricnamespace=metricnamespace, timespan=timespan, @@ -196,9 +209,11 @@ def prepare_request(next_link=None): filter=filter, result_type=result_type, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -212,7 +227,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -226,4 +245,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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 fd3c7aceb873..a6860e42c01c 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**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 86800ff33772..775abfe44986 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 07d73bf58d4a..0abbc303fec8 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -30,8 +31,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -48,12 +52,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 bbcc96275adc..10763f771226 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**kwargs) 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 49caf9f19a61..20b4c2ce65c2 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 dc488c51fcad..60f9d62f0ead 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 8c4ea9623876..ba945ecce720 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_06_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -67,13 +65,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -81,14 +83,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -107,7 +116,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -116,7 +125,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -128,23 +137,35 @@ async def get( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,11 +180,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -180,23 +201,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -207,7 +240,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -215,9 +248,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -231,13 +264,17 @@ async def update( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -245,14 +282,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,14 +311,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -283,29 +327,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,7 +374,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,14 +392,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -351,31 +410,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +459,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,14 +477,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -427,13 +501,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -441,14 +519,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -459,5 +544,5 @@ async def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 74d7521ff191..cb5205fe1cc8 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 @@ -27,7 +27,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupList', 'ActionGroupPatchBody', @@ -47,3 +49,5 @@ 'WebhookReceiver', 'ReceiverStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 5e0a25f65ada..f76679d09e44 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ActionGroupList(msrest.serialization.Model): """A list of action groups. @@ -29,7 +33,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -91,10 +95,6 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -105,8 +105,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, } @@ -114,8 +112,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } @@ -137,8 +133,6 @@ def __init__( self.id = None self.name = None self.type = None - self.kind = None - self.identity = None self.location = location self.tags = tags @@ -156,10 +150,6 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -203,8 +193,6 @@ class ActionGroupResource(AzureResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, 'group_short_name': {'max_length': 12, 'min_length': 0}, } @@ -213,8 +201,6 @@ class ActionGroupResource(AzureResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, @@ -238,16 +224,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + 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 ): """ @@ -553,8 +539,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus """ @@ -799,7 +785,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py index 5e8a759db49c..2502d854d186 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 dc488c51fcad..60f9d62f0ead 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 95eedacf8e7c..dfe57fbbf0e3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,30 +229,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -254,74 +264,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_06_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -335,13 +344,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -349,14 +362,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -375,7 +395,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -384,7 +404,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -396,23 +416,35 @@ def get( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -427,11 +459,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -448,23 +480,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -475,7 +519,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -483,9 +527,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -499,13 +543,17 @@ def update( :rtype: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -513,14 +561,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,14 +590,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -551,29 +606,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -587,7 +653,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -601,14 +671,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -619,31 +689,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -657,7 +738,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -671,14 +756,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -695,13 +780,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -709,14 +798,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 409]: @@ -727,5 +823,5 @@ def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 ba079fc9b32a..2df221ca96ff 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-10-17-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-10-17-preview" + 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) 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 c1ab58204142..a393daf1dc40 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 7ec772089c38..1246473842cd 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -43,8 +44,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -63,16 +67,26 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 26c8b9416b5d..c41ed063f867 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-10-17-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-10-17-preview" + 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) 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 33dce3625e85..860be3f92221 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -43,8 +44,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-10-17-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -63,11 +67,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.private_link_scopes = PrivateLinkScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scopes = PrivateLinkScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 2d05e3becea9..0a36c7d8c015 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 @@ -12,6 +12,9 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'PrivateLinkScopesOperations', 'PrivateLinkScopeOperationStatusOperations', @@ -19,3 +22,5 @@ 'PrivateEndpointConnectionsOperations', 'PrivateLinkScopedResourcesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 33fca8708f69..17aac92d991d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.aio.MonitorManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -55,7 +53,7 @@ async def get( scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,11 +67,16 @@ async def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -81,12 +84,19 @@ async def get( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +110,7 @@ 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}"} # type: ignore async def _create_or_update_initial( @@ -108,16 +118,20 @@ async def _create_or_update_initial( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(parameters, 'PrivateEndpointConnection') @@ -126,14 +140,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -149,7 +170,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -158,9 +179,9 @@ async def begin_create_or_update( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -185,36 +206,48 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -223,23 +256,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_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}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -247,12 +284,19 @@ async def _delete_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -262,11 +306,11 @@ async def _delete_initial( 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}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -293,19 +337,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -315,8 +366,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -325,10 +382,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace def list_by_private_link_scope( @@ -336,7 +392,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -350,11 +406,16 @@ def list_by_private_link_scope( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -362,10 +423,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -373,10 +437,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -390,7 +457,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -403,4 +474,4 @@ 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"} # type: ignore 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 4883f725b439..b97aa058300e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.aio.MonitorManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_private_link_scope( @@ -52,7 +50,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -66,11 +64,16 @@ def list_by_private_link_scope( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -78,10 +81,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -89,10 +95,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +115,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,7 +132,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -128,7 +141,7 @@ async def get( scope_name: str, group_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -142,11 +155,16 @@ async def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_request( @@ -154,12 +172,19 @@ async def get( resource_group_name=resource_group_name, scope_name=scope_name, group_name=group_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,5 +198,5 @@ 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}"} # type: ignore 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 722da8748b6b..3fb9a2df6a9c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkScopeOperationStatusOperations: - """PrivateLinkScopeOperationStatusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.aio.MonitorManagementClient`'s + :attr:`private_link_scope_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -50,7 +48,7 @@ async def get( async_operation_id: str, resource_group_name: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Get the status of an azure asynchronous operation associated with a private link scope operation. @@ -63,23 +61,35 @@ async def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( async_operation_id=async_operation_id, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -93,5 +103,5 @@ async def get( 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}"} # type: ignore 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 b7a1d087b441..f221cf86894c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkScopedResourcesOperations: - """PrivateLinkScopedResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.aio.MonitorManagementClient`'s + :attr:`private_link_scoped_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -55,7 +53,7 @@ async def get( scope_name: str, name: str, **kwargs: Any - ) -> "_models.ScopedResource": + ) -> _models.ScopedResource: """Gets a scoped resource in a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,11 +67,16 @@ async def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.ScopedResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] request = build_get_request( @@ -81,12 +84,19 @@ async def get( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -100,7 +110,7 @@ async def get( 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}"} # type: ignore async def _create_or_update_initial( @@ -108,16 +118,20 @@ async def _create_or_update_initial( resource_group_name: str, scope_name: str, name: str, - parameters: "_models.ScopedResource", + parameters: _models.ScopedResource, **kwargs: Any - ) -> Optional["_models.ScopedResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ScopedResource"]] + ) -> Optional[_models.ScopedResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ScopedResource]] _json = self._serialize.body(parameters, 'ScopedResource') @@ -126,14 +140,21 @@ async def _create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -152,7 +173,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -161,9 +182,9 @@ async def begin_create_or_update( resource_group_name: str, scope_name: str, name: str, - parameters: "_models.ScopedResource", + parameters: _models.ScopedResource, **kwargs: Any - ) -> AsyncLROPoller["_models.ScopedResource"]: + ) -> AsyncLROPoller[_models.ScopedResource]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -188,36 +209,48 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ScopedResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -226,23 +259,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_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}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -250,12 +287,19 @@ async def _delete_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -265,11 +309,11 @@ async def _delete_initial( 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}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -296,19 +340,26 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -318,8 +369,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -328,10 +385,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace def list_by_private_link_scope( @@ -339,7 +395,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScopedResourceListResult"]: + ) -> AsyncIterable[_models.ScopedResourceListResult]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,11 +409,16 @@ def list_by_private_link_scope( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -365,10 +426,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -376,10 +440,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +460,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,4 +477,4 @@ 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"} # type: ignore 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 e0e17418bd24..81cbd406ca19 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -27,32 +27,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkScopesOperations: - """PrivateLinkScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.aio.MonitorManagementClient`'s + :attr:`private_link_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScopeListResult"]: + ) -> AsyncIterable[_models.AzureMonitorPrivateLinkScopeListResult]: """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,29 +60,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,14 +124,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScopeListResult"]: + ) -> AsyncIterable[_models.AzureMonitorPrivateLinkScopeListResult]: """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -130,31 +143,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -168,7 +192,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,31 +209,43 @@ 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"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -215,11 +255,11 @@ async def _delete_initial( 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}"} # type: ignore @distributed_trace_async - async def begin_delete( + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -243,18 +283,25 @@ async def begin_delete( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +311,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -274,10 +327,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace_async async def get( @@ -285,7 +337,7 @@ async def get( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Returns a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -297,23 +349,35 @@ async def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] request = build_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -327,7 +391,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -335,9 +399,9 @@ async def create_or_update( self, resource_group_name: str, scope_name: str, - azure_monitor_private_link_scope_payload: "_models.AzureMonitorPrivateLinkScope", + azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -354,13 +418,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') @@ -368,14 +436,21 @@ async def create_or_update( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -393,7 +468,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -401,9 +476,9 @@ async def update_tags( self, resource_group_name: str, scope_name: str, - private_link_scope_tags: "_models.TagsResource", + private_link_scope_tags: _models.TagsResource, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. @@ -419,13 +494,17 @@ async def update_tags( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] _json = self._serialize.body(private_link_scope_tags, 'TagsResource') @@ -433,14 +512,21 @@ async def update_tags( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -454,5 +540,5 @@ 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}"} # type: ignore 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 420b31912035..dfe6a71d3fa4 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,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'AzureMonitorPrivateLinkScope', 'AzureMonitorPrivateLinkScopeListResult', @@ -44,3 +46,5 @@ 'ScopedResourceListResult', 'TagsResource', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 58910cffafcd..bb315d2873d0 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 @@ -7,10 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class PrivateLinkScopesResource(msrest.serialization.Model): """An azure resource object. @@ -154,7 +158,7 @@ class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AzureMonitorPrivateLinkScope"], + value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs ): @@ -315,7 +319,7 @@ def __init__( start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, status: Optional[str] = None, - error: Optional["ErrorResponseCommon"] = None, + error: Optional["_models.ErrorResponseCommon"] = None, **kwargs ): """ @@ -418,8 +422,8 @@ class PrivateEndpointConnection(ProxyResource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpointProperty"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, + private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 2d05e3becea9..0a36c7d8c015 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 @@ -12,6 +12,9 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'PrivateLinkScopesOperations', 'PrivateLinkScopeOperationStatusOperations', @@ -19,3 +22,5 @@ 'PrivateEndpointConnectionsOperations', 'PrivateLinkScopedResourcesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 564be0f4fcd0..812ba1173e5f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -36,10 +36,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # 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), @@ -47,21 +51,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -72,16 +74,19 @@ def build_create_or_update_request_initial( scope_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-10-17-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # 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), @@ -89,23 +94,21 @@ def build_create_or_update_request_initial( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,9 +122,11 @@ def build_delete_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}") # 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), @@ -129,16 +134,15 @@ def build_delete_request_initial( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -149,55 +153,55 @@ def build_list_by_private_link_scope_request( scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections") # 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), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.MonitorManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -206,7 +210,7 @@ def get( scope_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -220,11 +224,16 @@ def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -232,12 +241,19 @@ def get( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,7 +267,7 @@ 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}"} # type: ignore def _create_or_update_initial( @@ -259,16 +275,20 @@ def _create_or_update_initial( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(parameters, 'PrivateEndpointConnection') @@ -277,14 +297,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -300,7 +327,7 @@ 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}"} # type: ignore @distributed_trace @@ -309,9 +336,9 @@ def begin_create_or_update( resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -336,36 +363,48 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -374,23 +413,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_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}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -398,12 +441,19 @@ def _delete_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -413,11 +463,11 @@ def _delete_initial( 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}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -444,19 +494,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -466,8 +523,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -476,10 +539,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace def list_by_private_link_scope( @@ -487,7 +549,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -501,11 +563,16 @@ def list_by_private_link_scope( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -513,10 +580,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -524,10 +594,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -541,7 +614,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -554,4 +631,4 @@ 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"} # type: ignore 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 d24fddbe4013..70ad22a21db2 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,31 +33,33 @@ def build_list_by_private_link_scope_request( scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources") # 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), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -68,10 +71,14 @@ def build_get_request( group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}") # 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), @@ -79,45 +86,41 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.MonitorManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_private_link_scope( @@ -125,7 +128,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + ) -> Iterable[_models.PrivateLinkResourceListResult]: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -139,11 +142,16 @@ def list_by_private_link_scope( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -151,10 +159,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -162,10 +173,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -179,7 +193,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,7 +210,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -201,7 +219,7 @@ def get( scope_name: str, group_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -215,11 +233,16 @@ def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_request( @@ -227,12 +250,19 @@ def get( resource_group_name=resource_group_name, scope_name=scope_name, group_name=group_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,5 +276,5 @@ 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}"} # type: ignore 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 10d19919d2a1..b9fbfa8996eb 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}") # pylint: disable=line-too-long path_format_arguments = { "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, 'str'), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkScopeOperationStatusOperations(object): - """PrivateLinkScopeOperationStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkScopeOperationStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.MonitorManagementClient`'s + :attr:`private_link_scope_operation_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -87,7 +88,7 @@ def get( async_operation_id: str, resource_group_name: str, **kwargs: Any - ) -> "_models.OperationStatus": + ) -> _models.OperationStatus: """Get the status of an azure asynchronous operation associated with a private link scope operation. @@ -100,23 +101,35 @@ def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.OperationStatus :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatus] request = build_get_request( async_operation_id=async_operation_id, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -130,5 +143,5 @@ def get( 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}"} # type: ignore 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 29ef35a608df..7fd92fdaa46f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -36,10 +36,14 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # 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), @@ -47,21 +51,19 @@ def build_get_request( "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -72,16 +74,19 @@ def build_create_or_update_request_initial( scope_name: str, name: str, *, - json: JSONType = None, + json: Optional[_models.ScopedResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-10-17-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # 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), @@ -89,23 +94,21 @@ def build_create_or_update_request_initial( "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,9 +122,11 @@ def build_delete_request_initial( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}") # 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), @@ -129,16 +134,15 @@ def build_delete_request_initial( "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -149,55 +153,55 @@ def build_list_by_private_link_scope_request( scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources") # 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), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkScopedResourcesOperations(object): - """PrivateLinkScopedResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkScopedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.MonitorManagementClient`'s + :attr:`private_link_scoped_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -206,7 +210,7 @@ def get( scope_name: str, name: str, **kwargs: Any - ) -> "_models.ScopedResource": + ) -> _models.ScopedResource: """Gets a scoped resource in a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -220,11 +224,16 @@ def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.ScopedResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] request = build_get_request( @@ -232,12 +241,19 @@ def get( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,7 +267,7 @@ def get( 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}"} # type: ignore def _create_or_update_initial( @@ -259,16 +275,20 @@ def _create_or_update_initial( resource_group_name: str, scope_name: str, name: str, - parameters: "_models.ScopedResource", + parameters: _models.ScopedResource, **kwargs: Any - ) -> Optional["_models.ScopedResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ScopedResource"]] + ) -> Optional[_models.ScopedResource]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ScopedResource]] _json = self._serialize.body(parameters, 'ScopedResource') @@ -277,14 +297,21 @@ def _create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -303,7 +330,7 @@ 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}"} # type: ignore @distributed_trace @@ -312,9 +339,9 @@ def begin_create_or_update( resource_group_name: str, scope_name: str, name: str, - parameters: "_models.ScopedResource", + parameters: _models.ScopedResource, **kwargs: Any - ) -> LROPoller["_models.ScopedResource"]: + ) -> LROPoller[_models.ScopedResource]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -339,36 +366,48 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScopedResource] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, parameters=parameters, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ScopedResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -377,23 +416,27 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_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}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -401,12 +444,19 @@ def _delete_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -416,11 +466,11 @@ def _delete_initial( 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}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -447,19 +497,26 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, name=name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -469,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -479,10 +542,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace def list_by_private_link_scope( @@ -490,7 +552,7 @@ def list_by_private_link_scope( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> Iterable["_models.ScopedResourceListResult"]: + ) -> Iterable[_models.ScopedResourceListResult]: """Gets all private endpoint connections on a private link scope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -504,11 +566,16 @@ def list_by_private_link_scope( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -516,10 +583,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=self.list_by_private_link_scope.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -527,10 +597,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -544,7 +617,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -557,4 +634,4 @@ 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"} # type: ignore 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 1679732ffcae..2dc4b7af814e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,29 +33,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,30 +67,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -99,25 +103,26 @@ def build_delete_request_initial( scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -128,31 +133,33 @@ def build_get_request( scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-10-17-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,39 +169,40 @@ def build_create_or_update_request( subscription_id: str, scope_name: str, *, - json: JSONType = None, + json: Optional[_models.AzureMonitorPrivateLinkScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-10-17-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,71 +214,70 @@ def build_update_tags_request( subscription_id: str, scope_name: str, *, - json: JSONType = None, + json: Optional[_models.TagsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-10-17-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class PrivateLinkScopesOperations(object): - """PrivateLinkScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_10_17.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_10_17.MonitorManagementClient`'s + :attr:`private_link_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"]: + ) -> Iterable[_models.AzureMonitorPrivateLinkScopeListResult]: """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -280,29 +287,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -316,7 +334,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -329,14 +351,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"]: + ) -> Iterable[_models.AzureMonitorPrivateLinkScopeListResult]: """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -348,31 +370,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -386,7 +419,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,31 +436,43 @@ 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"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -433,11 +482,11 @@ def _delete_initial( 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}"} # type: ignore @distributed_trace - def begin_delete( + def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, @@ -461,18 +510,25 @@ def begin_delete( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, scope_name=scope_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +538,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -492,10 +554,9 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_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}"} # type: ignore @distributed_trace def get( @@ -503,7 +564,7 @@ def get( resource_group_name: str, scope_name: str, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Returns a Azure Monitor PrivateLinkScope. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -515,23 +576,35 @@ def get( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-10-17-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] request = build_get_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -545,7 +618,7 @@ 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}"} # type: ignore @distributed_trace @@ -553,9 +626,9 @@ def create_or_update( self, resource_group_name: str, scope_name: str, - azure_monitor_private_link_scope_payload: "_models.AzureMonitorPrivateLinkScope", + azure_monitor_private_link_scope_payload: _models.AzureMonitorPrivateLinkScope, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. @@ -572,13 +645,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') @@ -586,14 +663,21 @@ def create_or_update( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -611,7 +695,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -619,9 +703,9 @@ def update_tags( self, resource_group_name: str, scope_name: str, - private_link_scope_tags: "_models.TagsResource", + private_link_scope_tags: _models.TagsResource, **kwargs: Any - ) -> "_models.AzureMonitorPrivateLinkScope": + ) -> _models.AzureMonitorPrivateLinkScope: """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. @@ -637,13 +721,17 @@ def update_tags( :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] _json = self._serialize.body(private_link_scope_tags, 'TagsResource') @@ -651,14 +739,21 @@ def update_tags( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, scope_name=scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update_tags.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -672,5 +767,5 @@ 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}"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 3976d687afde..df9da9ebbfee 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-01-preview" + 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) 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 34885a43497c..c230b21e7154 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 3c59bcc99068..87749cef2aca 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -34,8 +35,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -52,13 +56,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 2dc886a8a1f4..8e0896e554e0 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-01-preview" + 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) 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 ea9134b6ffef..a573acb57637 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -34,8 +35,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -52,8 +56,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 f755a04ab065..09d431fd767d 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 @@ -9,7 +9,12 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 d7bca3542c6d..011a286dca00 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRuleAssociationsOperations: - """DataCollectionRuleAssociationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_11_01_preview.aio.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -65,29 +63,40 @@ def list_by_resource( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +110,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +128,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"} # type: ignore @distributed_trace def list_by_rule( @@ -123,7 +136,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -140,11 +153,16 @@ def list_by_rule( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,10 +170,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -163,10 +184,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,7 +204,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,7 +222,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -202,7 +230,7 @@ async def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -217,22 +245,34 @@ async def get( ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,7 +287,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -255,9 +295,9 @@ async def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -266,7 +306,7 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -275,13 +315,17 @@ async def create( ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -291,14 +335,21 @@ async def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -317,11 +368,11 @@ async def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -340,22 +391,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -366,5 +429,5 @@ async def delete( 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}"} # type: ignore 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 c08041431504..0967200b2d1c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRulesOperations: - """DataCollectionRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_11_01_preview.aio.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -65,31 +63,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,13 +130,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -135,29 +148,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -171,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +213,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -193,7 +221,7 @@ async def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -208,23 +236,35 @@ async def get( :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +279,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -247,9 +287,9 @@ async def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -259,20 +299,24 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -283,14 +327,21 @@ async def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,7 +360,7 @@ async def create( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -317,9 +368,9 @@ async def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -329,20 +380,24 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -353,14 +408,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,11 +437,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -399,23 +461,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,5 +500,5 @@ async def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 fc90ea637b48..39e2ff5c6e8f 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 @@ -44,7 +44,9 @@ KnownSyslogDataSourceStreams, KnownWindowsEventLogDataSourceStreams, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AzureMonitorMetricsDestination', 'DataCollectionRule', @@ -81,3 +83,5 @@ 'KnownSyslogDataSourceStreams', 'KnownWindowsEventLogDataSourceStreams', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 7a0a0f36f511..51578214c398 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 @@ -6,12 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AzureMonitorMetricsDestination(msrest.serialization.Model): @@ -62,7 +64,7 @@ class DataCollectionRule(msrest.serialization.Model): ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -86,9 +88,9 @@ def __init__( self, *, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -124,7 +126,7 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -178,7 +180,7 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -250,7 +252,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat def __init__( self, *, - value: List["DataCollectionRuleAssociationProxyOnlyResource"], + value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, **kwargs ): @@ -276,7 +278,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. :vartype data_collection_rule_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -335,10 +337,10 @@ class DataSourcesSpec(msrest.serialization.Model): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, **kwargs ): """ @@ -388,10 +390,10 @@ class DataCollectionRuleDataSources(DataSourcesSpec): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, **kwargs ): """ @@ -429,8 +431,8 @@ class DestinationsSpec(msrest.serialization.Model): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -465,8 +467,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -491,7 +493,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". :vartype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -516,7 +518,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -553,11 +555,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "KnownDataCollectionRuleResourceKind"]] = None, + kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -565,7 +567,7 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". :paramtype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -621,7 +623,7 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DataCollectionRuleResource"], + value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs ): @@ -656,7 +658,7 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -680,9 +682,9 @@ def __init__( self, *, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -720,7 +722,7 @@ class DataFlow(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownDataFlowStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, destinations: Optional[List[str]] = None, **kwargs ): @@ -858,7 +860,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -909,7 +911,7 @@ def __init__( self, *, extension_name: str, - streams: Optional[List[Union[str, "KnownExtensionDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, extension_settings: Optional[Any] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, @@ -1020,7 +1022,7 @@ class PerfCounterDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownPerfCounterDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, @@ -1108,9 +1110,9 @@ class SyslogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "KnownSyslogDataSourceLogLevels"]]] = None, + streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, + facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, + log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, **kwargs ): @@ -1164,7 +1166,7 @@ class WindowsEventLogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownWindowsEventLogDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, **kwargs diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py index fe34d7947fb3..714dcb202e72 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -21,7 +20,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseIns SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -31,14 +30,14 @@ class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnu SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -46,7 +45,7 @@ class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -54,12 +53,12 @@ class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, st MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownPerfCounterDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" -class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): AUTH = "auth" AUTHPRIV = "authpriv" @@ -83,7 +82,7 @@ class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, LOCAL7 = "local7" ASTERISK = "*" -class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEBUG = "Debug" INFO = "Info" @@ -95,11 +94,11 @@ class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str EMERGENCY = "Emergency" ASTERISK = "*" -class KnownSyslogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" -class KnownWindowsEventLogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 f755a04ab065..09d431fd767d 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 @@ -9,7 +9,12 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 2a0854de768a..f1b3af5e4b65 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_by_resource_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,31 +66,33 @@ def build_list_by_rule_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -98,30 +102,32 @@ def build_get_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -130,38 +136,39 @@ def build_create_request( resource_uri: str, association_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,61 +180,61 @@ def build_delete_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRuleAssociationsOperations(object): - """DataCollectionRuleAssociationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRuleAssociationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_11_01_preview.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -241,29 +248,40 @@ def list_by_resource( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -277,7 +295,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,7 +313,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"} # type: ignore @distributed_trace def list_by_rule( @@ -299,7 +321,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -316,11 +338,16 @@ def list_by_rule( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -328,10 +355,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,10 +369,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -356,7 +389,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -370,7 +407,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -378,7 +415,7 @@ def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -393,22 +430,34 @@ def get( ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -423,7 +472,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace @@ -431,9 +480,9 @@ def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -442,7 +491,7 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -451,13 +500,17 @@ def create( ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -467,14 +520,21 @@ def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -493,11 +553,11 @@ def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -516,22 +576,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -542,5 +614,5 @@ def delete( 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}"} # type: ignore 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 e7390a164176..15f71cd7dabb 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,29 +66,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ResourceForUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-11-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,62 +228,62 @@ def build_delete_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-11-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRulesOperations(object): - """DataCollectionRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2019_11_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2019_11_01_preview.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -289,31 +297,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,13 +364,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -359,29 +382,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -395,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,7 +447,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -417,7 +455,7 @@ def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -432,23 +470,35 @@ def get( :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +513,7 @@ 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}"} # type: ignore @distributed_trace @@ -471,9 +521,9 @@ def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -483,20 +533,24 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -507,14 +561,21 @@ def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -533,7 +594,7 @@ def create( return deserialized - 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}"} # type: ignore @distributed_trace @@ -541,9 +602,9 @@ def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -553,20 +614,24 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -577,14 +642,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,11 +671,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -623,23 +695,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -650,5 +734,5 @@ def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 a3b6df71aadb..24ef9950ab69 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2020-01-01-preview" + 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) 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 378468ef8a93..b9c51d72cb60 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 c96780028635..e12bfe7cdd4f 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -30,8 +31,11 @@ class MonitorManagementClient: $(python-base-namespace).v2020_01_01_preview.operations.ManagementGroupDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -47,12 +51,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 cdef221ece0b..41d28e9db87f 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,6 +27,9 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -35,11 +38,13 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential - self.api_version = "2020-01-01-preview" + 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) 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 8c3c52b5455b..4613ac3ebaa7 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -30,8 +31,11 @@ class MonitorManagementClient: $(python-base-namespace).v2020_01_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -47,7 +51,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 c619e7568800..d9ec384c7ee2 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ManagementGroupDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 921396e02fe2..19972f3614d8 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupDiagnosticSettingsOperations: - """ManagementGroupDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_01_01_preview.aio.MonitorManagementClient`'s + :attr:`management_group_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -52,7 +50,7 @@ async def get( management_group_id: str, name: str, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -65,22 +63,34 @@ async def get( ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] request = build_get_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def 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}"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def create_or_update( self, management_group_id: str, name: str, - parameters: "_models.ManagementGroupDiagnosticSettingsResource", + parameters: _models.ManagementGroupDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -121,27 +131,38 @@ async def create_or_update( ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') request = build_create_or_update_request( management_group_id=management_group_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,11 +177,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, management_group_id: str, name: str, @@ -177,22 +198,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -203,7 +236,7 @@ async def delete( 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}"} # type: ignore @distributed_trace @@ -211,7 +244,7 @@ def list( self, management_group_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: + ) -> AsyncIterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: """Gets the active management group diagnostic settings list for the specified management group. :param management_group_id: The management group id. @@ -223,29 +256,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -259,7 +303,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -273,4 +321,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 51d05c1a18a8..104364b71e26 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,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ErrorResponse', 'ManagementGroupDiagnosticSettingsResource', @@ -20,3 +22,5 @@ 'ManagementGroupLogSettings', 'ManagementGroupProxyOnlyResource', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 e53b3a61d86c..b0cf692ec6a5 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. @@ -149,7 +153,7 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - logs: Optional[List["ManagementGroupLogSettings"]] = None, + logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, workspace_id: Optional[str] = None, **kwargs ): @@ -199,7 +203,7 @@ class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.M def __init__( self, *, - value: Optional[List["ManagementGroupDiagnosticSettingsResource"]] = None, + value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs ): """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 c619e7568800..d9ec384c7ee2 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ManagementGroupDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 9c127025109b..7f5cd7c26220 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,38 +66,39 @@ def build_create_or_update_request( management_group_id: str, name: str, *, - json: JSONType = None, + json: Optional[_models.ManagementGroupDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-01-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -107,30 +110,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -139,53 +144,53 @@ def build_list_request( management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-01-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ManagementGroupDiagnosticSettingsOperations(object): - """ManagementGroupDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementGroupDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_01_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_01_01_preview.MonitorManagementClient`'s + :attr:`management_group_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -193,7 +198,7 @@ def get( management_group_id: str, name: str, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -206,22 +211,34 @@ def get( ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] request = build_get_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -236,7 +253,7 @@ 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}"} # type: ignore @distributed_trace @@ -244,9 +261,9 @@ def create_or_update( self, management_group_id: str, name: str, - parameters: "_models.ManagementGroupDiagnosticSettingsResource", + parameters: _models.ManagementGroupDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -262,27 +279,38 @@ def create_or_update( ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') request = build_create_or_update_request( management_group_id=management_group_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -297,11 +325,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, management_group_id: str, name: str, @@ -318,22 +346,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -344,7 +384,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -352,7 +392,7 @@ def list( self, management_group_id: str, **kwargs: Any - ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: + ) -> Iterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: """Gets the active management group diagnostic settings list for the specified management group. :param management_group_id: The management group id. @@ -364,29 +404,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -400,7 +451,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,4 +469,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 5e7e4b72cc0a..ae668e8ace76 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-05-01-preview" + 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) 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 0518924e3fa3..7709ce6d006e 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 fa5afc6020a9..07abd9fb7f66 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,12 +53,14 @@ def __init__( 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) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 9542d1ff846f..e33b0619cb1c 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-05-01-preview" + 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) 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 62e082f8affd..3a7bde119e46 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,7 +53,9 @@ def __init__( 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) + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 f677702ed3df..a33ab10efeb3 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ScheduledQueryRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 8e128c253a04..35237519b83d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ScheduledQueryRulesOperations: - """ScheduledQueryRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_05_01_preview.aio.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.ScheduledQueryRuleResourceCollection"]: + ) -> AsyncIterable[_models.ScheduledQueryRuleResourceCollection]: """Retrieve a scheduled query rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,14 +123,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ScheduledQueryRuleResourceCollection"]: + ) -> AsyncIterable[_models.ScheduledQueryRuleResourceCollection]: """Retrieve scheduled query rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,31 +142,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +191,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +209,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace_async async def get( @@ -189,7 +217,7 @@ async def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Retrieve an scheduled query rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -201,23 +229,35 @@ async def get( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,7 +272,7 @@ async def get( 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}"} # type: ignore @distributed_trace_async @@ -240,9 +280,9 @@ async def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.ScheduledQueryRuleResource", + parameters: _models.ScheduledQueryRuleResource, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Creates or updates a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -257,13 +297,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') @@ -271,14 +315,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -297,7 +348,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -305,9 +356,9 @@ async def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.ScheduledQueryRuleResourcePatch", + parameters: _models.ScheduledQueryRuleResourcePatch, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Update a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -322,13 +373,17 @@ async def update( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') @@ -336,14 +391,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,11 +420,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -379,23 +441,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -406,5 +480,5 @@ async def delete( 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}"} # type: ignore 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 5c06ceb743ef..711c3a649649 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 @@ -27,7 +27,9 @@ DimensionOperator, TimeAggregation, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Action', 'Condition', @@ -47,3 +49,5 @@ 'DimensionOperator', 'TimeAggregation', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 76b08a05a895..bd48ab2b1fd0 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Action(msrest.serialization.Model): @@ -54,8 +56,8 @@ class Condition(msrest.serialization.Model): :ivar query: Log query alert. :vartype query: str - :ivar time_aggregation: Required. Aggregation type. Possible values include: "Count", - "Average", "Minimum", "Maximum", "Total". + :ivar time_aggregation: Required. Aggregation type. Known values are: "Count", "Average", + "Minimum", "Maximum", "Total". :vartype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation :ivar metric_measure_column: The column containing the metric measure number. @@ -65,8 +67,8 @@ class Condition(msrest.serialization.Model): :vartype resource_id_column: str :ivar dimensions: List of Dimensions conditions. :vartype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :ivar operator: Required. The criteria operator. Possible values include: "Equals", - "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :ivar operator: Required. The criteria operator. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator :ivar threshold: Required. the criteria threshold value that activates the alert. @@ -97,21 +99,21 @@ class Condition(msrest.serialization.Model): def __init__( self, *, - time_aggregation: Union[str, "TimeAggregation"], - operator: Union[str, "ConditionOperator"], + time_aggregation: Union[str, "_models.TimeAggregation"], + operator: Union[str, "_models.ConditionOperator"], threshold: float, query: Optional[str] = None, metric_measure_column: Optional[str] = None, resource_id_column: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, - failing_periods: Optional["ConditionFailingPeriods"] = None, + dimensions: Optional[List["_models.Dimension"]] = None, + failing_periods: Optional["_models.ConditionFailingPeriods"] = None, **kwargs ): """ :keyword query: Log query alert. :paramtype query: str - :keyword time_aggregation: Required. Aggregation type. Possible values include: "Count", - "Average", "Minimum", "Maximum", "Total". + :keyword time_aggregation: Required. Aggregation type. Known values are: "Count", "Average", + "Minimum", "Maximum", "Total". :paramtype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation :keyword metric_measure_column: The column containing the metric measure number. @@ -121,8 +123,8 @@ def __init__( :paramtype resource_id_column: str :keyword dimensions: List of Dimensions conditions. :paramtype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :keyword operator: Required. The criteria operator. Possible values include: "Equals", - "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :keyword operator: Required. The criteria operator. Known values are: "Equals", "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator :keyword threshold: Required. the criteria threshold value that activates the alert. @@ -188,7 +190,7 @@ class Dimension(msrest.serialization.Model): :ivar name: Required. Name of the dimension. :vartype name: str - :ivar operator: Required. Operator for dimension values. Possible values include: "Include", + :ivar operator: Required. Operator for dimension values. Known values are: "Include", "Exclude". :vartype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator @@ -212,14 +214,14 @@ def __init__( self, *, name: str, - operator: Union[str, "DimensionOperator"], + operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs ): """ :keyword name: Required. Name of the dimension. :paramtype name: str - :keyword operator: Required. Operator for dimension values. Possible values include: "Include", + :keyword operator: Required. Operator for dimension values. Known values are: "Include", "Exclude". :paramtype operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator @@ -278,7 +280,7 @@ class ErrorContract(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponse"] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs ): """ @@ -390,7 +392,7 @@ class ScheduledQueryRuleCriteria(msrest.serialization.Model): def __init__( self, *, - all_of: Optional[List["Condition"]] = None, + all_of: Optional[List["_models.Condition"]] = None, **kwargs ): """ @@ -493,7 +495,7 @@ class ScheduledQueryRuleResource(TrackedResource): :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. Possible values include: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, 4. :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. @@ -566,16 +568,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - severity: Optional[Union[float, "AlertSeverity"]] = None, + severity: Optional[Union[float, "_models.AlertSeverity"]] = None, enabled: Optional[bool] = None, 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["ScheduledQueryRuleCriteria"] = None, + criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional[List["Action"]] = None, + actions: Optional[List["_models.Action"]] = None, **kwargs ): """ @@ -588,7 +590,7 @@ def __init__( :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. Possible values include: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, 4. :paramtype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value @@ -653,7 +655,7 @@ class ScheduledQueryRuleResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ScheduledQueryRuleResource"]] = None, + value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs ): """ @@ -681,7 +683,7 @@ class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): :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. Possible values include: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, 4. :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. @@ -741,16 +743,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, display_name: Optional[str] = None, - severity: Optional[Union[float, "AlertSeverity"]] = None, + severity: Optional[Union[float, "_models.AlertSeverity"]] = None, enabled: Optional[bool] = None, 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["ScheduledQueryRuleCriteria"] = None, + criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, mute_actions_duration: Optional[datetime.timedelta] = None, - actions: Optional[List["Action"]] = None, + actions: Optional[List["_models.Action"]] = None, **kwargs ): """ @@ -761,7 +763,7 @@ def __init__( :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. Possible values include: 0, 1, 2, 3, 4. + severest. Known values are: 0, 1, 2, 3, 4. :paramtype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py index da2f1e015f96..8264f06f67a2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, float, Enum)): +class AlertSeverity(float, Enum, metaclass=CaseInsensitiveEnumMeta): """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest """ @@ -21,7 +20,7 @@ class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, float, Enum)): THREE = 3 FOUR = 4 -class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The criteria operator. """ @@ -31,14 +30,14 @@ class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class DimensionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DimensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operator for dimension values """ INCLUDE = "Include" EXCLUDE = "Exclude" -class TimeAggregation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregation(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Aggregation type """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 f677702ed3df..a33ab10efeb3 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ScheduledQueryRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 3da1f29e37d6..ad90b52bc0e4 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,30 +65,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_or_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ScheduledQueryRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ScheduledQueryRuleResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,61 +228,61 @@ def build_delete_request( rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + _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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ScheduledQueryRulesOperations(object): - """ScheduledQueryRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_05_01_preview.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.ScheduledQueryRuleResourceCollection"]: + ) -> Iterable[_models.ScheduledQueryRuleResourceCollection]: """Retrieve a scheduled query rule definitions in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -284,29 +292,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -320,7 +339,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -334,14 +357,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ScheduledQueryRuleResourceCollection"]: + ) -> Iterable[_models.ScheduledQueryRuleResourceCollection]: """Retrieve scheduled query rule definitions in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,31 +376,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +425,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,7 +443,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore @distributed_trace def get( @@ -413,7 +451,7 @@ def get( resource_group_name: str, rule_name: str, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Retrieve an scheduled query rule definition. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -425,23 +463,35 @@ def get( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -456,7 +506,7 @@ def get( 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}"} # type: ignore @distributed_trace @@ -464,9 +514,9 @@ def create_or_update( self, resource_group_name: str, rule_name: str, - parameters: "_models.ScheduledQueryRuleResource", + parameters: _models.ScheduledQueryRuleResource, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Creates or updates a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -481,13 +531,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') @@ -495,14 +549,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -521,7 +582,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -529,9 +590,9 @@ def update( self, resource_group_name: str, rule_name: str, - parameters: "_models.ScheduledQueryRuleResourcePatch", + parameters: _models.ScheduledQueryRuleResourcePatch, **kwargs: Any - ) -> "_models.ScheduledQueryRuleResource": + ) -> _models.ScheduledQueryRuleResource: """Update a scheduled query rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -546,13 +607,17 @@ def update( :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScheduledQueryRuleResource] _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') @@ -560,14 +625,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -582,11 +654,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rule_name: str, @@ -603,23 +675,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, rule_name=rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -630,5 +714,5 @@ def delete( 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}"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 14af96233033..22f6bfab9772 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01" + 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) 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 f1fae9dab958..84588921906b 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 694355cab028..cc2fe0d25248 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,12 +53,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 d463a021089f..55911295e09b 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01" + 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) 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 6f8d6651909b..57f9823ba9b7 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -49,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 93b3b50f2d76..26aff77830bf 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 08ed28f3b920..f4a6f22e218f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActivityLogAlertsOperations: - """ActivityLogAlertsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_10_01.aio.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_rule: "_models.ActivityLogAlertResource", + activity_log_alert_rule: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new Activity Log Alert rule or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -68,13 +66,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') @@ -82,14 +84,21 @@ async def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -108,7 +117,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -117,7 +126,7 @@ async def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,23 +138,35 @@ async def get( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,11 +181,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -181,23 +202,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -208,7 +241,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -216,9 +249,9 @@ async def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_rule_patch: "_models.AlertRulePatchObject", + activity_log_alert_rule_patch: _models.AlertRulePatchObject, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. @@ -235,13 +268,17 @@ async def update( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') @@ -249,14 +286,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,14 +315,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleList"]: + ) -> AsyncIterable[_models.AlertRuleList]: """Get a list of all Activity Log Alert rules in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -287,29 +331,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -323,7 +378,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -337,14 +396,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AlertRuleList"]: + ) -> AsyncIterable[_models.AlertRuleList]: """Get a list of all Activity Log Alert rules in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -355,31 +414,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +463,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,4 +481,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 d89d7755c60e..a1e8a4c73d50 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,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroup', 'ActionList', @@ -30,3 +32,5 @@ 'AzureResource', 'ErrorResponse', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f1101062bcca..f59200eb3161 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ActionGroup(msrest.serialization.Model): """A pointer to an Azure Action Group. @@ -68,7 +72,7 @@ class ActionList(msrest.serialization.Model): def __init__( self, *, - action_groups: Optional[List["ActionGroup"]] = None, + action_groups: Optional[List["_models.ActionGroup"]] = None, **kwargs ): """ @@ -189,8 +193,8 @@ def __init__( location: Optional[str] = "global", tags: Optional[Dict[str, str]] = None, scopes: Optional[List[str]] = None, - condition: Optional["AlertRuleAllOfCondition"] = None, - actions: Optional["ActionList"] = None, + condition: Optional["_models.AlertRuleAllOfCondition"] = None, + actions: Optional["_models.ActionList"] = None, enabled: Optional[bool] = True, description: Optional[str] = None, **kwargs @@ -244,7 +248,7 @@ class AlertRuleAllOfCondition(msrest.serialization.Model): def __init__( self, *, - all_of: List["AlertRuleAnyOfOrLeafCondition"], + all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **kwargs ): """ @@ -347,7 +351,7 @@ def __init__( field: Optional[str] = None, equals: Optional[str] = None, contains_any: Optional[List[str]] = None, - any_of: Optional[List["AlertRuleLeafCondition"]] = None, + any_of: Optional[List["_models.AlertRuleLeafCondition"]] = None, **kwargs ): """ @@ -387,7 +391,7 @@ class AlertRuleList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActivityLogAlertResource"]] = None, + value: Optional[List["_models.ActivityLogAlertResource"]] = None, next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 93b3b50f2d76..26aff77830bf 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActivityLogAlertsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 fc2181da2fc5..db7819267d1b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,39 +32,40 @@ def build_create_or_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.ActivityLogAlertResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,31 +78,33 @@ def build_get_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -112,31 +115,33 @@ def build_delete_request( activity_log_alert_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -146,39 +151,40 @@ def build_update_request( resource_group_name: str, activity_log_alert_name: str, *, - json: JSONType = None, + json: Optional[_models.AlertRulePatchObject] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-10-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}") # 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), "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -189,29 +195,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,63 +229,63 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-10-01" - accept = "application/json" + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ActivityLogAlertsOperations(object): - """ActivityLogAlertsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActivityLogAlertsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2020_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2020_10_01.MonitorManagementClient`'s + :attr:`activity_log_alerts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_rule: "_models.ActivityLogAlertResource", + activity_log_alert_rule: _models.ActivityLogAlertResource, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Create a new Activity Log Alert rule or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -292,13 +300,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') @@ -306,14 +318,21 @@ def create_or_update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -332,7 +351,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -341,7 +360,7 @@ def get( resource_group_name: str, activity_log_alert_name: str, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Get an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -353,23 +372,35 @@ def get( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,11 +415,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, activity_log_alert_name: str, @@ -405,23 +436,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -432,7 +475,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -440,9 +483,9 @@ def update( self, resource_group_name: str, activity_log_alert_name: str, - activity_log_alert_rule_patch: "_models.AlertRulePatchObject", + activity_log_alert_rule_patch: _models.AlertRulePatchObject, **kwargs: Any - ) -> "_models.ActivityLogAlertResource": + ) -> _models.ActivityLogAlertResource: """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. @@ -459,13 +502,17 @@ def update( :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActivityLogAlertResource] _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') @@ -473,14 +520,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, activity_log_alert_name=activity_log_alert_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -495,14 +549,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.AlertRuleList"]: + ) -> Iterable[_models.AlertRuleList]: """Get a list of all Activity Log Alert rules in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -511,29 +565,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -547,7 +612,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -561,14 +630,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AlertRuleList"]: + ) -> Iterable[_models.AlertRuleList]: """Get a list of all Activity Log Alert rules in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -579,31 +648,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,7 +697,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,4 +715,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 030a5ba894ea..984c88249141 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**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 b089e37d50b5..c36a245f3f25 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 84dc1ddcca18..703c12089c2b 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -37,8 +38,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -55,14 +59,20 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_endpoints = DataCollectionEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 457603f1e001..b4586432cdb2 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**kwargs) 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 cc25115a9967..2521839d04e5 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -37,8 +38,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -55,9 +59,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_endpoints = DataCollectionEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 86676ba92623..eea5749564d8 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 @@ -10,8 +10,13 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionEndpointsOperations', 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 dc284b81446b..0bb2999f5675 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionEndpointsOperations: - """DataCollectionEndpointsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.aio.MonitorManagementClient`'s + :attr:`data_collection_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. @@ -65,31 +63,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,13 +130,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. @@ -135,29 +148,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -171,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +213,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -193,7 +221,7 @@ async def get( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. @@ -208,23 +236,35 @@ async def get( :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +279,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -247,9 +287,9 @@ async def create( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.DataCollectionEndpointResource"] = None, + body: Optional[_models.DataCollectionEndpointResource] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. Creates or updates a data collection endpoint. @@ -259,20 +299,24 @@ async def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionEndpointResource') @@ -283,14 +327,21 @@ async def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,7 +360,7 @@ async def create( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -317,9 +368,9 @@ async def update( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. Updates part of a data collection endpoint. @@ -329,20 +380,24 @@ async def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -353,14 +408,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,11 +437,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_endpoint_name: str, @@ -399,23 +461,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,5 +500,5 @@ async def delete( 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}"} # type: ignore 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 3492b8a74d5d..3a8011712e06 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRuleAssociationsOperations: - """DataCollectionRuleAssociationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.aio.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -65,29 +63,40 @@ def list_by_resource( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +110,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +128,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"} # type: ignore @distributed_trace def list_by_rule( @@ -123,7 +136,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -140,11 +153,16 @@ def list_by_rule( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,10 +170,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -163,10 +184,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,7 +204,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,7 +222,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -202,7 +230,7 @@ async def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -217,22 +245,34 @@ async def get( ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -247,7 +287,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -255,9 +295,9 @@ async def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -266,7 +306,7 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -275,13 +315,17 @@ async def create( ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -291,14 +335,21 @@ async def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -317,11 +368,11 @@ async def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -340,22 +391,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -366,5 +429,5 @@ async def delete( 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}"} # type: ignore 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 f888346fcd12..1640b72faf75 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRulesOperations: - """DataCollectionRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.aio.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -65,31 +63,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,13 +130,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -135,29 +148,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -171,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +213,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -193,7 +221,7 @@ async def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -208,23 +236,35 @@ async def get( :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +279,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -247,9 +287,9 @@ async def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -259,20 +299,24 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -283,14 +327,21 @@ async def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,7 +360,7 @@ async def create( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -317,9 +368,9 @@ async def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -329,20 +380,24 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -353,14 +408,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,11 +437,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -399,23 +461,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,5 +500,5 @@ async def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 1884e0dca0c1..1ec1c4b6e771 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 @@ -62,7 +62,9 @@ KnownSyslogDataSourceStreams, KnownWindowsEventLogDataSourceStreams, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AzureMonitorMetricsDestination', 'ConfigurationAccessEndpointSpec', @@ -117,3 +119,5 @@ 'KnownSyslogDataSourceStreams', 'KnownWindowsEventLogDataSourceStreams', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 5fbd1e570899..19ee9462b543 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AzureMonitorMetricsDestination(msrest.serialization.Model): @@ -90,8 +92,8 @@ class DataCollectionEndpoint(msrest.serialization.Model): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ @@ -114,9 +116,9 @@ def __init__( *, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -227,7 +229,7 @@ class NetworkRuleSet(msrest.serialization.Model): """Definition of the network rules. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -239,12 +241,12 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -256,7 +258,7 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -268,12 +270,12 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): def __init__( self, *, - public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -291,7 +293,7 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. @@ -319,8 +321,8 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ @@ -357,12 +359,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "KnownDataCollectionEndpointResourceKind"]] = None, + kind: Optional[Union[str, "_models.KnownDataCollectionEndpointResourceKind"]] = None, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -370,7 +372,7 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". :paramtype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :keyword description: Description of the data collection endpoint. @@ -429,7 +431,7 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DataCollectionEndpointResource"], + value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs ): @@ -464,8 +466,8 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState """ @@ -488,9 +490,9 @@ def __init__( *, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -517,15 +519,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -545,25 +547,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -583,15 +585,15 @@ class DataCollectionEndpointResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -611,25 +613,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -657,7 +659,7 @@ class DataCollectionRule(msrest.serialization.Model): ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState @@ -681,9 +683,9 @@ def __init__( self, *, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -722,7 +724,7 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState @@ -788,7 +790,7 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState @@ -869,7 +871,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat def __init__( self, *, - value: List["DataCollectionRuleAssociationProxyOnlyResource"], + value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, **kwargs ): @@ -898,7 +900,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState @@ -941,15 +943,15 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -969,25 +971,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -1021,10 +1023,10 @@ class DataSourcesSpec(msrest.serialization.Model): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, **kwargs ): """ @@ -1072,10 +1074,10 @@ class DataCollectionRuleDataSources(DataSourcesSpec): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, **kwargs ): """ @@ -1112,8 +1114,8 @@ class DestinationsSpec(msrest.serialization.Model): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -1148,8 +1150,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -1174,7 +1176,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -1202,7 +1204,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState @@ -1241,11 +1243,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "KnownDataCollectionRuleResourceKind"]] = None, + kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -1253,7 +1255,7 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". :paramtype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -1309,7 +1311,7 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DataCollectionRuleResource"], + value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs ): @@ -1343,7 +1345,7 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState @@ -1367,9 +1369,9 @@ def __init__( self, *, description: Optional[str] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -1394,15 +1396,15 @@ class DataCollectionRuleResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1422,25 +1424,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -1467,7 +1469,7 @@ class DataFlow(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownDataFlowStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, destinations: Optional[List[str]] = None, **kwargs ): @@ -1605,7 +1607,7 @@ class ErrorResponseCommonV2(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -1656,7 +1658,7 @@ def __init__( self, *, extension_name: str, - streams: Optional[List[Union[str, "KnownExtensionDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, extension_settings: Optional[Any] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, @@ -1767,7 +1769,7 @@ class PerfCounterDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownPerfCounterDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, @@ -1855,9 +1857,9 @@ class SyslogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "KnownSyslogDataSourceLogLevels"]]] = None, + streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, + facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, + log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, **kwargs ): @@ -1911,7 +1913,7 @@ class WindowsEventLogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownWindowsEventLogDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, **kwargs diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py index 297a4c1f0059..b8366d4a41a1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -20,7 +19,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class KnownDataCollectionEndpointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. This property is READ-ONLY. """ @@ -30,14 +29,14 @@ class KnownDataCollectionEndpointProvisioningState(with_metaclass(CaseInsensitiv SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionEndpointResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -47,7 +46,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseIns SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -57,14 +56,14 @@ class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnu SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -72,7 +71,7 @@ class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -80,12 +79,12 @@ class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, st MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownPerfCounterDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" -class KnownPublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The configuration to set whether network access from public internet to the endpoints are allowed. """ @@ -93,7 +92,7 @@ class KnownPublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, st ENABLED = "Enabled" DISABLED = "Disabled" -class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): AUTH = "auth" AUTHPRIV = "authpriv" @@ -117,7 +116,7 @@ class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, LOCAL7 = "local7" ASTERISK = "*" -class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEBUG = "Debug" INFO = "Info" @@ -129,11 +128,11 @@ class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str EMERGENCY = "Emergency" ASTERISK = "*" -class KnownSyslogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" -class KnownWindowsEventLogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 86676ba92623..eea5749564d8 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 @@ -10,8 +10,13 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionEndpointsOperations', 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 e08e17d35616..347fc381c19e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,29 +66,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( data_collection_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_request( resource_group_name: str, data_collection_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionEndpointResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, data_collection_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.ResourceForUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,62 +228,62 @@ def build_delete_request( data_collection_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionEndpointsOperations(object): - """DataCollectionEndpointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.MonitorManagementClient`'s + :attr:`data_collection_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. @@ -289,31 +297,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,13 +364,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. @@ -359,29 +382,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -395,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,7 +447,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -417,7 +455,7 @@ def get( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. @@ -432,23 +470,35 @@ def get( :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +513,7 @@ 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}"} # type: ignore @distributed_trace @@ -471,9 +521,9 @@ def create( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.DataCollectionEndpointResource"] = None, + body: Optional[_models.DataCollectionEndpointResource] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. Creates or updates a data collection endpoint. @@ -483,20 +533,24 @@ def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionEndpointResource') @@ -507,14 +561,21 @@ def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -533,7 +594,7 @@ def create( return deserialized - 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}"} # type: ignore @distributed_trace @@ -541,9 +602,9 @@ def update( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. Updates part of a data collection endpoint. @@ -553,20 +614,24 @@ def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -577,14 +642,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,11 +671,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_endpoint_name: str, @@ -623,23 +695,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -650,5 +734,5 @@ def delete( 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}"} # type: ignore 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 9f0103c4e7f2..6219c8239c50 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_by_resource_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,31 +66,33 @@ def build_list_by_rule_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -98,30 +102,32 @@ def build_get_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -130,38 +136,39 @@ def build_create_request( resource_uri: str, association_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,61 +180,61 @@ def build_delete_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRuleAssociationsOperations(object): - """DataCollectionRuleAssociationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRuleAssociationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -241,29 +248,40 @@ def list_by_resource( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -277,7 +295,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,7 +313,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"} # type: ignore @distributed_trace def list_by_rule( @@ -299,7 +321,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -316,11 +338,16 @@ def list_by_rule( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -328,10 +355,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,10 +369,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -356,7 +389,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -370,7 +407,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -378,7 +415,7 @@ def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -393,22 +430,34 @@ def get( ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -423,7 +472,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace @@ -431,9 +480,9 @@ def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -442,7 +491,7 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -451,13 +500,17 @@ def create( ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -467,14 +520,21 @@ def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -493,11 +553,11 @@ def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -516,22 +576,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -542,5 +614,5 @@ def delete( 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}"} # type: ignore 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 f9ee7485f273..b4ad58840527 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,29 +66,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ResourceForUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,62 +228,62 @@ def build_delete_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRulesOperations(object): - """DataCollectionRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_04_01.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -289,31 +297,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,13 +364,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -359,29 +382,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -395,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,7 +447,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -417,7 +455,7 @@ def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -432,23 +470,35 @@ def get( :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +513,7 @@ 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}"} # type: ignore @distributed_trace @@ -471,9 +521,9 @@ def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -483,20 +533,24 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -507,14 +561,21 @@ def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -533,7 +594,7 @@ def create( return deserialized - 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}"} # type: ignore @distributed_trace @@ -541,9 +602,9 @@ def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -553,20 +614,24 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -577,14 +642,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,11 +671,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -623,23 +695,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -650,5 +734,5 @@ def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 daa1eaa37dbe..8762b312b134 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01-preview" + 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) 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 3feeaec00b53..fff521006964 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 519c5ba60fc2..38028c186519 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -47,8 +48,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -65,17 +69,29 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.predictive_metric = PredictiveMetricOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predictive_metric = PredictiveMetricOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 7da2da751912..11ff51a080fe 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-05-01-preview" + 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) 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 1024edbc3147..288c31769b43 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -47,8 +48,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -65,12 +69,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.predictive_metric = PredictiveMetricOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.autoscale_settings = AutoscaleSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.predictive_metric = PredictiveMetricOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings = DiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 7f5c0a1041dc..1d276a5b9094 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 @@ -13,6 +13,9 @@ from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'AutoscaleSettingsOperations', 'PredictiveMetricOperations', @@ -21,3 +24,5 @@ 'ManagementGroupDiagnosticSettingsOperations', 'SubscriptionDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 7aa783a2f713..813176a82244 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AutoscaleSettingsOperations: - """AutoscaleSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: + ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -63,31 +61,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +110,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,16 +128,16 @@ 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"} # type: ignore @distributed_trace_async async def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, - parameters: "_models.AutoscaleSettingResource", + parameters: _models.AutoscaleSettingResource, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -138,13 +151,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(parameters, 'AutoscaleSettingResource') @@ -152,14 +169,21 @@ async def create_or_update( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -178,11 +202,11 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, autoscale_setting_name: str, @@ -199,23 +223,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -226,7 +262,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -235,7 +271,7 @@ async def get( resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -247,23 +283,35 @@ async def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,7 +326,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -286,9 +334,9 @@ async def update( self, resource_group_name: str, autoscale_setting_name: str, - autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. @@ -304,13 +352,17 @@ async def update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') @@ -318,14 +370,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,14 +399,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: + ) -> AsyncIterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -357,29 +416,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -393,7 +463,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,4 +481,4 @@ 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"} # type: ignore 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 2caa5d0120dd..05573c513a18 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiagnosticSettingsCategoryOperations: - """DiagnosticSettingsCategoryOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -52,7 +50,7 @@ async def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResource": + ) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -64,22 +62,34 @@ async def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,7 +104,7 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace @@ -102,7 +112,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticSettingsCategoryResourceCollection"]: + ) -> AsyncIterable[_models.DiagnosticSettingsCategoryResourceCollection]: """Lists the diagnostic settings categories for the specified resource. :param resource_uri: The identifier of the resource. @@ -114,29 +124,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -150,7 +171,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -164,4 +189,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"} # type: ignore 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 3d65ad45bfed..914c28891bee 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiagnosticSettingsOperations: - """DiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -52,7 +50,7 @@ async def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -64,22 +62,34 @@ async def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,7 +104,7 @@ async def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async @@ -102,9 +112,9 @@ async def create_or_update( self, resource_uri: str, name: str, - parameters: "_models.DiagnosticSettingsResource", + parameters: _models.DiagnosticSettingsResource, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -119,27 +129,38 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -154,11 +175,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, name: str, @@ -175,22 +196,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -201,7 +234,7 @@ async def delete( 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}"} # type: ignore @distributed_trace @@ -209,7 +242,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DiagnosticSettingsResourceCollection"]: + ) -> AsyncIterable[_models.DiagnosticSettingsResourceCollection]: """Gets the active diagnostic settings list for the specified resource. :param resource_uri: The identifier of the resource. @@ -221,29 +254,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -257,7 +301,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,4 +319,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"} # type: ignore 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 bcbdf0107658..5ec94321acc7 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupDiagnosticSettingsOperations: - """ManagementGroupDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`management_group_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -52,7 +50,7 @@ async def get( management_group_id: str, name: str, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -65,22 +63,34 @@ async def get( ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def 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}"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def create_or_update( self, management_group_id: str, name: str, - parameters: "_models.ManagementGroupDiagnosticSettingsResource", + parameters: _models.ManagementGroupDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -121,27 +131,38 @@ async def create_or_update( ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') request = build_create_or_update_request( management_group_id=management_group_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,11 +177,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, management_group_id: str, name: str, @@ -177,22 +198,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -203,7 +236,7 @@ async def delete( 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}"} # type: ignore @distributed_trace @@ -211,7 +244,7 @@ def list( self, management_group_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: + ) -> AsyncIterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: """Gets the active management group diagnostic settings list for the specified management group. :param management_group_id: The management group id. @@ -223,29 +256,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -259,7 +303,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -273,4 +321,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 a3ad60180b57..6fd294645327 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,15 +7,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -24,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PredictiveMetricOperations: - """PredictiveMetricOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`predictive_metric` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -56,7 +54,7 @@ async def get( metric_name: str, aggregation: str, **kwargs: Any - ) -> "_models.PredictiveResponse": + ) -> _models.PredictiveResponse: """get predictive autoscale metric future data. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -81,28 +79,40 @@ async def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PredictiveResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, timespan=timespan, interval=interval, metric_namespace=metric_namespace, metric_name=metric_name, aggregation=aggregation, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,5 +127,5 @@ 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"} # type: ignore 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 8dff60bc58a4..31539242d922 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SubscriptionDiagnosticSettingsOperations: - """SubscriptionDiagnosticSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.aio.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( self, name: str, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -62,22 +60,34 @@ async def get( ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,16 +102,16 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace_async async def create_or_update( self, name: str, - parameters: "_models.SubscriptionDiagnosticSettingsResource", + parameters: _models.SubscriptionDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -115,27 +125,38 @@ async def create_or_update( ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') request = build_create_or_update_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -150,11 +171,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, name: str, **kwargs: Any @@ -168,22 +189,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -194,14 +227,14 @@ async def delete( 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionDiagnosticSettingsResourceCollection"]: + ) -> AsyncIterable[_models.SubscriptionDiagnosticSettingsResourceCollection]: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response @@ -211,29 +244,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -247,7 +291,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,4 +309,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"} # type: ignore 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 660f669f65c3..ac607879171c 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 @@ -56,7 +56,9 @@ ScaleType, TimeAggregationType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AutoscaleErrorResponse', 'AutoscaleErrorResponseError', @@ -105,3 +107,5 @@ 'ScaleType', 'TimeAggregationType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 d0019c4e672d..ff45da247f54 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AutoscaleErrorResponse(msrest.serialization.Model): @@ -39,7 +41,7 @@ class AutoscaleErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["AutoscaleErrorResponseError"] = None, + error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs ): """ @@ -130,8 +132,8 @@ class AutoscaleNotification(msrest.serialization.Model): def __init__( self, *, - email: Optional["EmailNotification"] = None, - webhooks: Optional[List["WebhookNotification"]] = None, + email: Optional["_models.EmailNotification"] = None, + webhooks: Optional[List["_models.WebhookNotification"]] = None, **kwargs ): """ @@ -184,10 +186,10 @@ def __init__( self, *, name: str, - capacity: "ScaleCapacity", - rules: List["ScaleRule"], - fixed_date: Optional["TimeWindow"] = None, - recurrence: Optional["Recurrence"] = None, + capacity: "_models.ScaleCapacity", + rules: List["_models.ScaleRule"], + fixed_date: Optional["_models.TimeWindow"] = None, + recurrence: Optional["_models.Recurrence"] = None, **kwargs ): """ @@ -242,7 +244,7 @@ class AutoscaleSettingResource(msrest.serialization.Model): :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :vartype enabled: bool :ivar predictive_autoscale_policy: the predictive autoscale policy mode. :vartype predictive_autoscale_policy: @@ -286,11 +288,11 @@ def __init__( self, *, location: str, - profiles: List["AutoscaleProfile"], + profiles: List["_models.AutoscaleProfile"], tags: Optional[Dict[str, str]] = None, - notifications: Optional[List["AutoscaleNotification"]] = None, - enabled: Optional[bool] = True, - predictive_autoscale_policy: Optional["PredictiveAutoscalePolicy"] = None, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: Optional[bool] = False, + predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, @@ -313,7 +315,7 @@ def __init__( :paramtype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :paramtype enabled: bool :keyword predictive_autoscale_policy: the predictive autoscale policy mode. :paramtype predictive_autoscale_policy: @@ -367,7 +369,7 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: List["AutoscaleSettingResource"], + value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs ): @@ -395,7 +397,7 @@ class AutoscaleSettingResourcePatch(msrest.serialization.Model): :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :vartype enabled: bool :ivar predictive_autoscale_policy: the predictive autoscale policy mode. :vartype predictive_autoscale_policy: @@ -429,10 +431,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - profiles: Optional[List["AutoscaleProfile"]] = None, - notifications: Optional[List["AutoscaleNotification"]] = None, - enabled: Optional[bool] = True, - predictive_autoscale_policy: Optional["PredictiveAutoscalePolicy"] = None, + profiles: Optional[List["_models.AutoscaleProfile"]] = None, + notifications: Optional[List["_models.AutoscaleNotification"]] = None, + enabled: Optional[bool] = False, + predictive_autoscale_policy: Optional["_models.PredictiveAutoscalePolicy"] = None, name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, @@ -449,7 +451,7 @@ def __init__( :paramtype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the - resource. The default value is 'true'. + resource. The default value is 'false'. :paramtype enabled: bool :keyword predictive_autoscale_policy: the predictive autoscale policy mode. :paramtype predictive_autoscale_policy: @@ -528,8 +530,8 @@ class DiagnosticSettingsCategoryResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :ivar category_type: The type of the diagnostic settings category. Possible values include: - "Metrics", "Logs". + :ivar category_type: The type of the diagnostic settings category. Known values are: "Metrics", + "Logs". :vartype category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType :ivar category_groups: the collection of what category groups are supported. @@ -555,12 +557,12 @@ class DiagnosticSettingsCategoryResource(Resource): def __init__( self, *, - category_type: Optional[Union[str, "CategoryType"]] = None, + category_type: Optional[Union[str, "_models.CategoryType"]] = None, category_groups: Optional[List[str]] = None, **kwargs ): """ - :keyword category_type: The type of the diagnostic settings category. Possible values include: + :keyword category_type: The type of the diagnostic settings category. Known values are: "Metrics", "Logs". :paramtype category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType @@ -588,7 +590,7 @@ class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DiagnosticSettingsCategoryResource"]] = None, + value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs ): """ @@ -674,8 +676,8 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - metrics: Optional[List["MetricSettings"]] = None, - logs: Optional[List["LogSettings"]] = None, + metrics: Optional[List["_models.MetricSettings"]] = None, + logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, log_analytics_destination_type: Optional[str] = None, @@ -738,7 +740,7 @@ class DiagnosticSettingsResourceCollection(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DiagnosticSettingsResource"]] = None, + value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs ): """ @@ -863,7 +865,7 @@ def __init__( enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -954,7 +956,7 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - logs: Optional[List["ManagementGroupLogSettings"]] = None, + logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, **kwargs @@ -1008,7 +1010,7 @@ class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.M def __init__( self, *, - value: Optional[List["ManagementGroupDiagnosticSettingsResource"]] = None, + value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs ): """ @@ -1103,7 +1105,7 @@ def __init__( enabled: bool, time_grain: Optional[datetime.timedelta] = None, category: Optional[str] = None, - retention_policy: Optional["RetentionPolicy"] = None, + retention_policy: Optional["_models.RetentionPolicy"] = None, **kwargs ): """ @@ -1144,7 +1146,7 @@ class MetricTrigger(msrest.serialization.Model): 1 minute. :vartype time_grain: ~datetime.timedelta :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances - are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". :vartype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType :ivar time_window: Required. the range of time in which instance data is collected. This value @@ -1152,12 +1154,12 @@ class MetricTrigger(msrest.serialization.Model): Must be between 12 hours and 5 minutes. :vartype time_window: ~datetime.timedelta :ivar time_aggregation: Required. time aggregation type. How the data that is collected should - be combined over time. The default value is Average. Possible values include: "Average", - "Minimum", "Maximum", "Total", "Count", "Last". + be combined over time. The default value is Average. Known values are: "Average", "Minimum", + "Maximum", "Total", "Count", "Last". :vartype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType :ivar operator: Required. the operator that is used to compare the metric data and the - threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType @@ -1203,14 +1205,14 @@ def __init__( metric_name: str, metric_resource_uri: str, time_grain: datetime.timedelta, - statistic: Union[str, "MetricStatisticType"], + statistic: Union[str, "_models.MetricStatisticType"], time_window: datetime.timedelta, - time_aggregation: Union[str, "TimeAggregationType"], - operator: Union[str, "ComparisonOperationType"], + time_aggregation: Union[str, "_models.TimeAggregationType"], + operator: Union[str, "_models.ComparisonOperationType"], threshold: float, metric_namespace: Optional[str] = None, metric_resource_location: Optional[str] = None, - dimensions: Optional[List["ScaleRuleMetricDimension"]] = None, + dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, divide_per_instance: Optional[bool] = None, **kwargs ): @@ -1229,7 +1231,7 @@ def __init__( 1 minute. :paramtype time_grain: ~datetime.timedelta :keyword statistic: Required. the metric statistic type. How the metrics from multiple - instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + instances are combined. Known values are: "Average", "Min", "Max", "Sum", "Count". :paramtype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType :keyword time_window: Required. the range of time in which instance data is collected. This @@ -1237,12 +1239,12 @@ def __init__( resource-to-resource. Must be between 12 hours and 5 minutes. :paramtype time_window: ~datetime.timedelta :keyword time_aggregation: Required. time aggregation type. How the data that is collected - should be combined over time. The default value is Average. Possible values include: "Average", + should be combined over time. The default value is Average. Known values are: "Average", "Minimum", "Maximum", "Total", "Count", "Last". :paramtype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType :keyword operator: Required. the operator that is used to compare the metric data and the - threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + threshold. Known values are: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". :paramtype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType @@ -1275,7 +1277,7 @@ class PredictiveAutoscalePolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar scale_mode: Required. the predictive autoscale mode. Possible values include: "Disabled", + :ivar scale_mode: Required. the predictive autoscale mode. Known values are: "Disabled", "ForecastOnly", "Enabled". :vartype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode @@ -1296,13 +1298,13 @@ class PredictiveAutoscalePolicy(msrest.serialization.Model): def __init__( self, *, - scale_mode: Union[str, "PredictiveAutoscalePolicyScaleMode"], + scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], scale_look_ahead_time: Optional[datetime.timedelta] = None, **kwargs ): """ - :keyword scale_mode: Required. the predictive autoscale mode. Possible values include: - "Disabled", "ForecastOnly", "Enabled". + :keyword scale_mode: Required. the predictive autoscale mode. Known values are: "Disabled", + "ForecastOnly", "Enabled". :paramtype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched @@ -1348,7 +1350,7 @@ def __init__( interval: Optional[datetime.timedelta] = None, metric_name: Optional[str] = None, target_resource_id: Optional[str] = None, - data: Optional[List["PredictiveValue"]] = None, + data: Optional[List["_models.PredictiveValue"]] = None, **kwargs ): """ @@ -1422,8 +1424,8 @@ class Recurrence(msrest.serialization.Model): :ivar frequency: Required. 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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Possible values include: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", "Year". :vartype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency :ivar schedule: Required. the scheduling constraints for when the profile begins. @@ -1443,16 +1445,16 @@ class Recurrence(msrest.serialization.Model): def __init__( self, *, - frequency: Union[str, "RecurrenceFrequency"], - schedule: "RecurrentSchedule", + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", **kwargs ): """ :keyword frequency: Required. 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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency - property specifies that the schedule is repeated weekly. Possible values include: "None", - "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + property specifies that the schedule is repeated weekly. Known values are: "None", "Second", + "Minute", "Hour", "Day", "Week", "Month", "Year". :paramtype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency :keyword schedule: Required. the scheduling constraints for when the profile begins. @@ -1627,10 +1629,10 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + decreases the number of instances. Known values are: "None", "Increase", "Decrease". :vartype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :ivar type: Required. the type of action that should occur when the scale rule fires. Possible - values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". + :ivar type: Required. the type of action that should occur when the scale rule fires. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". :vartype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. @@ -1656,20 +1658,19 @@ class ScaleAction(msrest.serialization.Model): def __init__( self, *, - direction: Union[str, "ScaleDirection"], - type: Union[str, "ScaleType"], + direction: Union[str, "_models.ScaleDirection"], + type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, value: Optional[str] = "1", **kwargs ): """ :keyword direction: Required. the scale direction. Whether the scaling action increases or - decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + decreases the number of instances. Known values are: "None", "Increase", "Decrease". :paramtype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :keyword type: Required. the type of action that should occur when the scale rule fires. - Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", - "ServiceAllowedNextValue". + :keyword type: Required. the type of action that should occur when the scale rule fires. Known + values are: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". :paramtype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType :keyword value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. @@ -1762,8 +1763,8 @@ class ScaleRule(msrest.serialization.Model): def __init__( self, *, - metric_trigger: "MetricTrigger", - scale_action: "ScaleAction", + metric_trigger: "_models.MetricTrigger", + scale_action: "_models.ScaleAction", **kwargs ): """ @@ -1786,7 +1787,7 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): :vartype dimension_name: str :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. - Possible values include: "Equals", "NotEquals". + Known values are: "Equals", "NotEquals". :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType :ivar values: Required. list of dimension values. For example: ["App1","App2"]. @@ -1809,7 +1810,7 @@ def __init__( self, *, dimension_name: str, - operator: Union[str, "ScaleRuleMetricDimensionOperationType"], + operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], values: List[str], **kwargs ): @@ -1818,7 +1819,7 @@ def __init__( :paramtype dimension_name: str :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the - values. Possible values include: "Equals", "NotEquals". + values. Known values are: "Equals", "NotEquals". :paramtype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType :keyword values: Required. list of dimension values. For example: ["App1","App2"]. @@ -1896,7 +1897,7 @@ def __init__( service_bus_rule_id: Optional[str] = None, event_hub_authorization_rule_id: Optional[str] = None, event_hub_name: Optional[str] = None, - logs: Optional[List["SubscriptionLogSettings"]] = None, + logs: Optional[List["_models.SubscriptionLogSettings"]] = None, workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, **kwargs @@ -1950,7 +1951,7 @@ class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Mode def __init__( self, *, - value: Optional[List["SubscriptionDiagnosticSettingsResource"]] = None, + value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs ): """ @@ -2016,7 +2017,7 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType @@ -2024,8 +2025,8 @@ class SystemData(msrest.serialization.Model): :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -2045,26 +2046,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py index 53feb41eb5e4..f3fce92da813 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the diagnostic settings category. """ METRICS = "Metrics" LOGS = "Logs" -class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ComparisonOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the operator that is used to compare the metric data and the threshold. """ @@ -29,7 +28,7 @@ class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -38,7 +37,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MetricStatisticType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the metric statistic type. How the metrics from multiple instances are combined. """ @@ -48,7 +47,7 @@ class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUM = "Sum" COUNT = "Count" -class PredictiveAutoscalePolicyScaleMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PredictiveAutoscalePolicyScaleMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the predictive autoscale mode """ @@ -56,7 +55,7 @@ class PredictiveAutoscalePolicyScaleMode(with_metaclass(CaseInsensitiveEnumMeta, FORECAST_ONLY = "ForecastOnly" ENABLED = "Enabled" -class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RecurrenceFrequency(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the @@ -72,7 +71,7 @@ class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MONTH = "Month" YEAR = "Year" -class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the scale direction. Whether the scaling action increases or decreases the number of instances. """ @@ -80,7 +79,7 @@ class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INCREASE = "Increase" DECREASE = "Decrease" -class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleRuleMetricDimensionOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values """ @@ -88,7 +87,7 @@ class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMe EQUALS = "Equals" NOT_EQUALS = "NotEquals" -class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """the type of action that should occur when the scale rule fires. """ @@ -97,7 +96,7 @@ class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" -class TimeAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 7f5c0a1041dc..1d276a5b9094 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 @@ -13,6 +13,9 @@ from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'AutoscaleSettingsOperations', 'PredictiveMetricOperations', @@ -21,3 +24,5 @@ 'ManagementGroupDiagnosticSettingsOperations', 'SubscriptionDiagnosticSettingsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 20f822ebc850..7c6fa0241412 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -65,39 +67,40 @@ def build_create_or_update_request( autoscale_setting_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AutoscaleSettingResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -110,31 +113,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -145,31 +150,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -179,39 +186,40 @@ def build_update_request( resource_group_name: str, autoscale_setting_name: str, *, - json: JSONType = None, + json: Optional[_models.AutoscaleSettingResourcePatch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}") # 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), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -222,60 +230,60 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class AutoscaleSettingsOperations(object): - """AutoscaleSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AutoscaleSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`autoscale_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: + ) -> Iterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -287,31 +295,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -325,7 +344,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,16 +362,16 @@ 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"} # type: ignore @distributed_trace def create_or_update( self, resource_group_name: str, autoscale_setting_name: str, - parameters: "_models.AutoscaleSettingResource", + parameters: _models.AutoscaleSettingResource, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Creates or updates an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -362,13 +385,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(parameters, 'AutoscaleSettingResource') @@ -376,14 +403,21 @@ def create_or_update( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -402,11 +436,11 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, autoscale_setting_name: str, @@ -423,23 +457,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -450,7 +496,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -459,7 +505,7 @@ def get( resource_group_name: str, autoscale_setting_name: str, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Gets an autoscale setting. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -471,23 +517,35 @@ def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,7 +560,7 @@ 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}"} # type: ignore @distributed_trace @@ -510,9 +568,9 @@ def update( self, resource_group_name: str, autoscale_setting_name: str, - autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + autoscale_setting_resource: _models.AutoscaleSettingResourcePatch, **kwargs: Any - ) -> "_models.AutoscaleSettingResource": + ) -> _models.AutoscaleSettingResource: """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. @@ -528,13 +586,17 @@ def update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoscaleSettingResource] _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') @@ -542,14 +604,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -564,14 +633,14 @@ 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}"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: + ) -> Iterable[_models.AutoscaleSettingResourceCollection]: """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -581,29 +650,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -617,7 +697,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -631,4 +715,4 @@ 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"} # type: ignore 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 ffd2e9c2338f..f7d7207ef837 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,30 +32,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,53 +66,53 @@ def build_list_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DiagnosticSettingsCategoryOperations(object): - """DiagnosticSettingsCategoryOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticSettingsCategoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`diagnostic_settings_category` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -117,7 +120,7 @@ def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsCategoryResource": + ) -> _models.DiagnosticSettingsCategoryResource: """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -129,22 +132,34 @@ def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +174,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore @distributed_trace @@ -167,7 +182,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DiagnosticSettingsCategoryResourceCollection"]: + ) -> Iterable[_models.DiagnosticSettingsCategoryResourceCollection]: """Lists the diagnostic settings categories for the specified resource. :param resource_uri: The identifier of the resource. @@ -179,29 +194,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -215,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -229,4 +259,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"} # type: ignore 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 999327ae2c82..14c72955c428 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,38 +66,39 @@ def build_create_or_update_request( resource_uri: str, name: str, *, - json: JSONType = None, + json: Optional[_models.DiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -107,30 +110,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -139,53 +144,53 @@ def build_list_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DiagnosticSettingsOperations(object): - """DiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -193,7 +198,7 @@ def get( resource_uri: str, name: str, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -205,22 +210,34 @@ def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -235,7 +252,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace @@ -243,9 +260,9 @@ def create_or_update( self, resource_uri: str, name: str, - parameters: "_models.DiagnosticSettingsResource", + parameters: _models.DiagnosticSettingsResource, **kwargs: Any - ) -> "_models.DiagnosticSettingsResource": + ) -> _models.DiagnosticSettingsResource: """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -260,27 +277,38 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiagnosticSettingsResource] _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') request = build_create_or_update_request( resource_uri=resource_uri, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -295,11 +323,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, name: str, @@ -316,22 +344,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,7 +382,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -350,7 +390,7 @@ def list( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DiagnosticSettingsResourceCollection"]: + ) -> Iterable[_models.DiagnosticSettingsResourceCollection]: """Gets the active diagnostic settings list for the specified resource. :param resource_uri: The identifier of the resource. @@ -362,29 +402,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -398,7 +449,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,4 +467,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"} # type: ignore 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 20ca8defd85f..eaf80de5ad18 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,38 +66,39 @@ def build_create_or_update_request( management_group_id: str, name: str, *, - json: JSONType = None, + json: Optional[_models.ManagementGroupDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -107,30 +110,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -139,53 +144,53 @@ def build_list_request( management_group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ManagementGroupDiagnosticSettingsOperations(object): - """ManagementGroupDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementGroupDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`management_group_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -193,7 +198,7 @@ def get( management_group_id: str, name: str, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -206,22 +211,34 @@ def get( ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -236,7 +253,7 @@ 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}"} # type: ignore @distributed_trace @@ -244,9 +261,9 @@ def create_or_update( self, management_group_id: str, name: str, - parameters: "_models.ManagementGroupDiagnosticSettingsResource", + parameters: _models.ManagementGroupDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.ManagementGroupDiagnosticSettingsResource": + ) -> _models.ManagementGroupDiagnosticSettingsResource: """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -262,27 +279,38 @@ def create_or_update( ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') request = build_create_or_update_request( management_group_id=management_group_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -297,11 +325,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, management_group_id: str, name: str, @@ -318,22 +346,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( management_group_id=management_group_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -344,7 +384,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -352,7 +392,7 @@ def list( self, management_group_id: str, **kwargs: Any - ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: + ) -> Iterable[_models.ManagementGroupDiagnosticSettingsResourceCollection]: """Gets the active management group diagnostic settings list for the specified management group. :param management_group_id: The management group id. @@ -364,29 +404,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( management_group_id=management_group_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -400,7 +451,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,4 +469,4 @@ 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 67ae8f3a043c..7b957557b8a0 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,17 +7,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -38,60 +39,60 @@ def build_get_request( aggregation: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics") # 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), "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') - query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') - query_parameters['metricNamespace'] = _SERIALIZER.query("metric_namespace", metric_namespace, 'str') - query_parameters['metricName'] = _SERIALIZER.query("metric_name", metric_name, 'str') - query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + _params['interval'] = _SERIALIZER.query("interval", interval, 'duration') + _params['metricNamespace'] = _SERIALIZER.query("metric_namespace", metric_namespace, 'str') + _params['metricName'] = _SERIALIZER.query("metric_name", metric_name, 'str') + _params['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PredictiveMetricOperations(object): - """PredictiveMetricOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PredictiveMetricOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`predictive_metric` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -104,7 +105,7 @@ def get( metric_name: str, aggregation: str, **kwargs: Any - ) -> "_models.PredictiveResponse": + ) -> _models.PredictiveResponse: """get predictive autoscale metric future data. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -129,28 +130,40 @@ def get( :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PredictiveResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, autoscale_setting_name=autoscale_setting_name, + api_version=api_version, timespan=timespan, interval=interval, metric_namespace=metric_namespace, metric_name=metric_name, aggregation=aggregation, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -165,5 +178,5 @@ 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"} # type: ignore 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 d69b8767906d..60ce59e6f86d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_get_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,38 +66,39 @@ def build_create_or_update_request( subscription_id: str, name: str, *, - json: JSONType = None, + json: Optional[_models.SubscriptionDiagnosticSettingsResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-05-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -107,30 +110,32 @@ def build_delete_request( name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "name": _SERIALIZER.url("name", name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -139,60 +144,60 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-05-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SubscriptionDiagnosticSettingsOperations(object): - """SubscriptionDiagnosticSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SubscriptionDiagnosticSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_05_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_05_01_preview.MonitorManagementClient`'s + :attr:`subscription_diagnostic_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( self, name: str, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -203,22 +208,34 @@ def get( ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -233,16 +250,16 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore @distributed_trace def create_or_update( self, name: str, - parameters: "_models.SubscriptionDiagnosticSettingsResource", + parameters: _models.SubscriptionDiagnosticSettingsResource, **kwargs: Any - ) -> "_models.SubscriptionDiagnosticSettingsResource": + ) -> _models.SubscriptionDiagnosticSettingsResource: """Creates or updates subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -256,27 +273,38 @@ def create_or_update( ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') request = build_create_or_update_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,11 +319,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, name: str, **kwargs: Any @@ -309,22 +337,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, name=name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -335,14 +375,14 @@ def delete( 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}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.SubscriptionDiagnosticSettingsResourceCollection"]: + ) -> Iterable[_models.SubscriptionDiagnosticSettingsResourceCollection]: """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response @@ -352,29 +392,40 @@ def list( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -388,7 +439,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -402,4 +457,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"} # type: ignore 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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 51092e492216..d80b5f349efb 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**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 935381fe6e10..ed28d78544de 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 2c252c063fa9..3790449c1398 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -30,8 +31,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -50,12 +54,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 2ae420e15518..c956c3bd2fc4 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) self._configure(**kwargs) 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 d852f15ba63d..e385b07e6f31 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -31,8 +32,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -51,7 +55,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 dc488c51fcad..60f9d62f0ead 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 769a807cdbc8..25e509cd03f3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,45 +16,44 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request +from ...operations._action_groups_operations import build_create_notifications_at_action_group_resource_level_request_initial, build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_action_group_resource_level_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ActionGroupsOperations: - """ActionGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_09_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -69,13 +67,17 @@ async def create_or_update( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -83,14 +85,21 @@ async def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -109,7 +118,7 @@ async def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -118,7 +127,7 @@ async def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -130,23 +139,35 @@ async def get( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,11 +182,11 @@ async def get( 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -182,23 +203,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -209,7 +242,7 @@ async def delete( 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}"} # type: ignore @distributed_trace_async @@ -217,9 +250,9 @@ async def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -233,13 +266,17 @@ async def update( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -247,14 +284,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -269,56 +313,74 @@ 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}"} # type: ignore async def _post_test_notifications_initial( self, - notification_request: "_models.NotificationRequestBody", + notification_request: _models.NotificationRequestBody, **kwargs: Any - ) -> "_models.TestNotificationResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] + ) -> Optional[_models.TestNotificationDetailsResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] _json = self._serialize.body(notification_request, 'NotificationRequestBody') request = build_post_test_notifications_request_initial( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationResponse', pipeline_response) + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) 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"} # type: ignore @distributed_trace_async async def begin_post_test_notifications( self, - notification_request: "_models.NotificationRequestBody", + notification_request: _models.NotificationRequestBody, **kwargs: Any - ) -> AsyncLROPoller["_models.TestNotificationResponse"]: + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. @@ -332,39 +394,339 @@ async def begin_post_test_notifications( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationResponse or the - result of cls(response) + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._post_test_notifications_initial( + raw_result = await self._post_test_notifications_initial( # type: ignore notification_request=notification_request, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('TestNotificationResponse', pipeline_response) + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + async def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + async def _create_notifications_at_action_group_resource_level_initial( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -373,17 +735,16 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_post_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace_async async def get_test_notifications( self, notification_id: str, **kwargs: Any - ) -> "_models.TestNotificationDetailsResponse": + ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param notification_id: The notification id. @@ -393,22 +754,34 @@ async def get_test_notifications( :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationDetailsResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_test_notifications_request( subscription_id=self._config.subscription_id, notification_id=notification_id, + api_version=api_version, template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -423,14 +796,146 @@ 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}"} # type: ignore + + + @distributed_trace_async + async def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace_async + async def get_test_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_action_group_resource_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + 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 @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -439,29 +944,40 @@ def list_by_subscription_id( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -475,7 +991,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -489,14 +1009,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ActionGroupList"]: + ) -> AsyncIterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -507,31 +1027,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,7 +1076,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -559,14 +1094,14 @@ 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"} # type: ignore @distributed_trace_async - async def enable_receiver( + async def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -583,13 +1118,17 @@ async def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -597,14 +1136,21 @@ async def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -615,5 +1161,5 @@ async def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 01dd730f69d1..7d4cce34b707 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 @@ -25,7 +25,6 @@ from ._models_py3 import NotificationRequestBody from ._models_py3 import SmsReceiver from ._models_py3 import TestNotificationDetailsResponse -from ._models_py3 import TestNotificationResponse from ._models_py3 import VoiceReceiver from ._models_py3 import WebhookReceiver @@ -33,7 +32,9 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionDetail', 'ActionGroupList', @@ -54,8 +55,9 @@ 'NotificationRequestBody', 'SmsReceiver', 'TestNotificationDetailsResponse', - 'TestNotificationResponse', 'VoiceReceiver', 'WebhookReceiver', 'ReceiverStatus', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 f4bb3bb6ba73..681b968fbd0c 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 @@ -6,11 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ActionDetail(msrest.serialization.Model): """The action detail. @@ -89,7 +93,7 @@ class ActionGroupList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ActionGroupResource"]] = None, + value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -151,10 +155,6 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -165,8 +165,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, } @@ -174,8 +172,6 @@ class AzureResource(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } @@ -197,8 +193,6 @@ def __init__( self.id = None self.name = None self.type = None - self.kind = None - self.identity = None self.location = location self.tags = tags @@ -216,10 +210,6 @@ class ActionGroupResource(AzureResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :ivar kind: Azure resource kind. - :vartype kind: str - :ivar identity: Azure resource identity. - :vartype identity: str :ivar location: Required. Resource location. :vartype location: str :ivar tags: A set of tags. Resource tags. @@ -266,8 +256,6 @@ class ActionGroupResource(AzureResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, 'location': {'required': True}, 'group_short_name': {'max_length': 12, 'min_length': 0}, } @@ -276,8 +264,6 @@ class ActionGroupResource(AzureResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, @@ -302,17 +288,17 @@ def __init__( tags: Optional[Dict[str, str]] = None, group_short_name: Optional[str] = None, enabled: Optional[bool] = True, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["EventHubReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 ): """ @@ -619,8 +605,8 @@ class Context(msrest.serialization.Model): """ _attribute_map = { - 'notification_source': {'key': 'NotificationSource', 'type': 'str'}, - 'context_type': {'key': 'ContextType', 'type': 'str'}, + 'notification_source': {'key': 'notificationSource', 'type': 'str'}, + 'context_type': {'key': 'contextType', 'type': 'str'}, } def __init__( @@ -655,8 +641,8 @@ class EmailReceiver(msrest.serialization.Model): :vartype email_address: str :ivar use_common_alert_schema: Indicates whether to use common alert schema. :vartype use_common_alert_schema: bool - :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", - "Enabled", "Disabled". + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus """ @@ -1021,17 +1007,17 @@ def __init__( self, *, alert_type: str, - email_receivers: Optional[List["EmailReceiver"]] = None, - sms_receivers: Optional[List["SmsReceiver"]] = None, - webhook_receivers: Optional[List["WebhookReceiver"]] = None, - itsm_receivers: Optional[List["ItsmReceiver"]] = None, - azure_app_push_receivers: Optional[List["AzureAppPushReceiver"]] = None, - automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, - voice_receivers: Optional[List["VoiceReceiver"]] = None, - logic_app_receivers: Optional[List["LogicAppReceiver"]] = None, - azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, - arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, - event_hub_receivers: Optional[List["EventHubReceiver"]] = None, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 ): """ @@ -1102,7 +1088,7 @@ class SmsReceiver(msrest.serialization.Model): :vartype country_code: str :ivar phone_number: Required. The phone number of the SMS receiver. :vartype phone_number: str - :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus """ @@ -1167,21 +1153,21 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): } _attribute_map = { - 'context': {'key': 'Context', 'type': 'Context'}, - 'state': {'key': 'State', 'type': 'str'}, - 'completed_time': {'key': 'CompletedTime', 'type': 'str'}, - 'created_time': {'key': 'CreatedTime', 'type': 'str'}, - 'action_details': {'key': 'ActionDetails', 'type': '[ActionDetail]'}, + 'context': {'key': 'context', 'type': 'Context'}, + 'state': {'key': 'state', 'type': 'str'}, + 'completed_time': {'key': 'completedTime', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'str'}, + 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, } def __init__( self, *, state: str, - context: Optional["Context"] = None, + context: Optional["_models.Context"] = None, completed_time: Optional[str] = None, created_time: Optional[str] = None, - action_details: Optional[List["ActionDetail"]] = None, + action_details: Optional[List["_models.ActionDetail"]] = None, **kwargs ): """ @@ -1204,53 +1190,6 @@ def __init__( self.action_details = action_details -class TestNotificationResponse(msrest.serialization.Model): - """The response when test notification succeeded. - - All required parameters must be populated in order to send to Azure. - - :ivar notification_id: Required. The notification id. - :vartype notification_id: str - :ivar correlation_id: Required. The correlation id. - :vartype correlation_id: str - :ivar created_time: Required. The created time. - :vartype created_time: str - """ - - _validation = { - 'notification_id': {'required': True}, - 'correlation_id': {'required': True}, - 'created_time': {'required': True}, - } - - _attribute_map = { - 'notification_id': {'key': 'notificationId', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'created_time': {'key': 'createdTime', 'type': 'str'}, - } - - def __init__( - self, - *, - notification_id: str, - correlation_id: str, - created_time: str, - **kwargs - ): - """ - :keyword notification_id: Required. The notification id. - :paramtype notification_id: str - :keyword correlation_id: Required. The correlation id. - :paramtype correlation_id: str - :keyword created_time: Required. The created time. - :paramtype created_time: str - """ - super(TestNotificationResponse, self).__init__(**kwargs) - self.notification_id = notification_id - self.correlation_id = correlation_id - self.created_time = created_time - - class VoiceReceiver(msrest.serialization.Model): """A voice receiver. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py index 5e8a759db49c..2502d854d186 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 dc488c51fcad..60f9d62f0ead 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 @@ -8,6 +8,11 @@ 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 patch_sdk as _patch_sdk __all__ = [ 'ActionGroupsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 b48ab2b71f6d..bb90a1dcd030 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,39 +34,40 @@ def build_create_or_update_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,31 +80,33 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -114,31 +117,33 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -148,39 +153,40 @@ def build_update_request( resource_group_name: str, action_group_name: str, *, - json: JSONType = None, + json: Optional[_models.ActionGroupPatchBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # 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), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,37 +196,126 @@ def build_update_request( def build_post_test_notifications_request_initial( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_notifications_at_resource_group_level_request_initial( + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.NotificationRequestBody] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -232,30 +327,108 @@ def build_get_test_notifications_request( notification_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_test_notifications_at_resource_group_level_request( + subscription_id: str, + resource_group_name: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # 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), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_test_notifications_at_action_group_resource_level_request( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -264,29 +437,31 @@ def build_list_by_subscription_id_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -296,30 +471,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -329,74 +506,73 @@ def build_enable_receiver_request( action_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.EnableRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ActionGroupsOperations(object): - """ActionGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2021_09_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create_or_update( self, resource_group_name: str, action_group_name: str, - action_group: "_models.ActionGroupResource", + action_group: _models.ActionGroupResource, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -410,13 +586,17 @@ def create_or_update( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group, 'ActionGroupResource') @@ -424,14 +604,21 @@ def create_or_update( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -450,7 +637,7 @@ def create_or_update( return deserialized - 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}"} # type: ignore @distributed_trace @@ -459,7 +646,7 @@ def get( resource_group_name: str, action_group_name: str, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -471,23 +658,35 @@ def get( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -502,11 +701,11 @@ def get( 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, @@ -523,23 +722,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -550,7 +761,7 @@ def delete( 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}"} # type: ignore @distributed_trace @@ -558,9 +769,9 @@ def update( self, resource_group_name: str, action_group_name: str, - action_group_patch: "_models.ActionGroupPatchBody", + action_group_patch: _models.ActionGroupPatchBody, **kwargs: Any - ) -> "_models.ActionGroupResource": + ) -> _models.ActionGroupResource: """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -574,13 +785,17 @@ def update( :rtype: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') @@ -588,14 +803,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, action_group_name=action_group_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -610,56 +832,74 @@ 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}"} # type: ignore def _post_test_notifications_initial( self, - notification_request: "_models.NotificationRequestBody", + notification_request: _models.NotificationRequestBody, **kwargs: Any - ) -> "_models.TestNotificationResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] + ) -> Optional[_models.TestNotificationDetailsResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] _json = self._serialize.body(notification_request, 'NotificationRequestBody') request = build_post_test_notifications_request_initial( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response - if response.status_code not in [202]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TestNotificationResponse', pipeline_response) + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) 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"} # type: ignore @distributed_trace def begin_post_test_notifications( self, - notification_request: "_models.NotificationRequestBody", + notification_request: _models.NotificationRequestBody, **kwargs: Any - ) -> LROPoller["_models.TestNotificationResponse"]: + ) -> LROPoller[_models.TestNotificationDetailsResponse]: """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. @@ -673,39 +913,51 @@ def begin_post_test_notifications( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationResponse or the result of - cls(response) + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._post_test_notifications_initial( + raw_result = self._post_test_notifications_initial( # type: ignore notification_request=notification_request, + api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('TestNotificationResponse', pipeline_response) + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -714,17 +966,304 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore - begin_post_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + def _create_notifications_at_action_group_resource_level_initial( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + + @distributed_trace + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore @distributed_trace def get_test_notifications( self, notification_id: str, **kwargs: Any - ) -> "_models.TestNotificationDetailsResponse": + ) -> _models.TestNotificationDetailsResponse: """Get the test notifications by the notification id. :param notification_id: The notification id. @@ -734,22 +1273,166 @@ def get_test_notifications( :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationDetailsResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_test_notifications_request( subscription_id=self._config.subscription_id, notification_id=notification_id, + api_version=api_version, template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def get_test_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2021_09_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_action_group_resource_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -764,14 +1447,14 @@ def get_test_notifications( return deserialized - get_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/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}"} # type: ignore @distributed_trace def list_by_subscription_id( self, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -780,29 +1463,40 @@ def list_by_subscription_id( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_id_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -816,7 +1510,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -830,14 +1528,14 @@ 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"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ActionGroupList"]: + ) -> Iterable[_models.ActionGroupList]: """Get a list of all action groups in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -848,31 +1546,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -886,7 +1595,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -900,14 +1613,14 @@ 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"} # type: ignore @distributed_trace - def enable_receiver( + def enable_receiver( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, action_group_name: str, - enable_request: "_models.EnableRequest", + enable_request: _models.EnableRequest, **kwargs: Any ) -> None: """Enable a receiver in an action group. This changes the receiver's status from Disabled to @@ -924,13 +1637,17 @@ def enable_receiver( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(enable_request, 'EnableRequest') @@ -938,14 +1655,21 @@ def enable_receiver( resource_group_name=resource_group_name, action_group_name=action_group_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -956,5 +1680,5 @@ def enable_receiver( 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"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 ec9090a57df0..7389161517c6 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 @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 96ea531748cd..406177440408 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 @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01-preview" + 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) 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 828831e97da8..82c79f95fc19 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 @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { 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 c755626c0bd3..163bda97a892 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration @@ -37,8 +38,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -55,14 +59,20 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_endpoints = DataCollectionEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/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 47babc28d5ed..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 = "3.1.0" +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 4eba911f1c6e..ee931f53dd58 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 @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/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 c004814b44c1..8f3d74250c48 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -29,6 +29,9 @@ class MonitorManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01-preview" + 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) 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 eaeaa74c87d5..b6a3c2c01653 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 @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration @@ -37,8 +38,11 @@ class MonitorManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -55,9 +59,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_endpoints = DataCollectionEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_collection_rules = DataCollectionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( 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 86676ba92623..eea5749564d8 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 @@ -10,8 +10,13 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionEndpointsOperations', 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 515853ab89a2..8728c695d93c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionEndpointsOperations: - """DataCollectionEndpointsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.aio.MonitorManagementClient`'s + :attr:`data_collection_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. @@ -65,31 +63,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,13 +130,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. @@ -135,29 +148,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -171,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +213,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -193,7 +221,7 @@ async def get( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. @@ -208,23 +236,35 @@ async def get( :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +279,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -247,9 +287,9 @@ async def create( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.DataCollectionEndpointResource"] = None, + body: Optional[_models.DataCollectionEndpointResource] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. Creates or updates a data collection endpoint. @@ -259,20 +299,24 @@ async def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionEndpointResource') @@ -283,14 +327,21 @@ async def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,7 +360,7 @@ async def create( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -317,9 +368,9 @@ async def update( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. Updates part of a data collection endpoint. @@ -329,20 +380,24 @@ async def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -353,14 +408,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,11 +437,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_endpoint_name: str, @@ -399,23 +461,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,5 +500,5 @@ async def delete( 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}"} # type: ignore 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 b2e9f132408a..e8c12f5e2fb3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRuleAssociationsOperations: - """DataCollectionRuleAssociationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.aio.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -65,29 +63,40 @@ def list_by_resource( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +110,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,7 +128,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"} # type: ignore @distributed_trace def list_by_rule( @@ -123,7 +136,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -140,11 +153,16 @@ def list_by_rule( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,10 +170,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -163,10 +184,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -180,7 +204,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,7 +222,7 @@ 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"} # type: ignore @distributed_trace def list_by_data_collection_endpoint( @@ -202,7 +230,7 @@ def list_by_data_collection_endpoint( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection endpoint. Lists associations for the specified data collection endpoint. @@ -219,11 +247,16 @@ def list_by_data_collection_endpoint( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -231,10 +264,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.list_by_data_collection_endpoint.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -242,10 +278,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -259,7 +298,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -273,7 +316,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -281,7 +324,7 @@ async def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -296,22 +339,34 @@ async def get( ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -326,7 +381,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -334,9 +389,9 @@ async def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -345,7 +400,7 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -354,13 +409,17 @@ async def create( ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -370,14 +429,21 @@ async def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -396,11 +462,11 @@ async def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -419,22 +485,34 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -445,5 +523,5 @@ async def delete( 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}"} # type: ignore 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 5e5ae199e538..ca72d4c85f45 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -25,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DataCollectionRulesOperations: - """DataCollectionRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.aio.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -65,31 +63,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,13 +130,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DataCollectionRuleResourceListResult"]: + ) -> AsyncIterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -135,29 +148,40 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -171,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +213,7 @@ 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"} # type: ignore @distributed_trace_async async def get( @@ -193,7 +221,7 @@ async def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -208,23 +236,35 @@ async def get( :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,7 +279,7 @@ 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}"} # type: ignore @distributed_trace_async @@ -247,9 +287,9 @@ async def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -259,20 +299,24 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -283,14 +327,21 @@ async def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -309,7 +360,7 @@ async def create( return deserialized - 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}"} # type: ignore @distributed_trace_async @@ -317,9 +368,9 @@ async def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -329,20 +380,24 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -353,14 +408,21 @@ async def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,11 +437,11 @@ 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}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -399,23 +461,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,5 +500,5 @@ async def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 5cb1ed8a7ffb..4ba134ae668a 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 @@ -76,7 +76,9 @@ KnownSyslogDataSourceStreams, KnownWindowsEventLogDataSourceStreams, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AzureMonitorMetricsDestination', 'ColumnDefinition', @@ -145,3 +147,5 @@ 'KnownSyslogDataSourceStreams', 'KnownWindowsEventLogDataSourceStreams', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 1d8328f3f7fc..3ec57246510a 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._monitor_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AzureMonitorMetricsDestination(msrest.serialization.Model): @@ -49,8 +51,8 @@ class ColumnDefinition(msrest.serialization.Model): :ivar name: The name of the column. :vartype name: str - :ivar type: The type of the column data. Possible values include: "string", "int", "long", - "real", "boolean", "datetime", "dynamic". + :ivar type: The type of the column data. Known values are: "string", "int", "long", "real", + "boolean", "datetime", "dynamic". :vartype type: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownColumnDefinitionType """ @@ -64,14 +66,14 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "KnownColumnDefinitionType"]] = None, + type: Optional[Union[str, "_models.KnownColumnDefinitionType"]] = None, **kwargs ): """ :keyword name: The name of the column. :paramtype name: str - :keyword type: The type of the column data. Possible values include: "string", "int", "long", - "real", "boolean", "datetime", "dynamic". + :keyword type: The type of the column data. Known values are: "string", "int", "long", "real", + "boolean", "datetime", "dynamic". :paramtype type: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownColumnDefinitionType """ @@ -126,8 +128,8 @@ class DataCollectionEndpoint(msrest.serialization.Model): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ @@ -150,9 +152,9 @@ def __init__( *, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -263,7 +265,7 @@ class NetworkRuleSet(msrest.serialization.Model): """Definition of the network rules. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ @@ -275,12 +277,12 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ @@ -292,7 +294,7 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. :ivar public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :vartype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ @@ -304,12 +306,12 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): def __init__( self, *, - public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs ): """ :keyword public_network_access: The configuration to set whether network access from public - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + internet to the endpoints are allowed. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownPublicNetworkAccessOptions """ @@ -327,7 +329,7 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". :vartype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. @@ -355,8 +357,8 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ @@ -393,12 +395,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "KnownDataCollectionEndpointResourceKind"]] = None, + kind: Optional[Union[str, "_models.KnownDataCollectionEndpointResourceKind"]] = None, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -406,7 +408,7 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". :paramtype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointResourceKind :keyword description: Description of the data collection endpoint. @@ -465,7 +467,7 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DataCollectionEndpointResource"], + value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs ): @@ -500,8 +502,8 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): :ivar network_acls: Network access control rules for the endpoints. :vartype network_acls: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointNetworkAcls - :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". + :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionEndpointProvisioningState """ @@ -524,9 +526,9 @@ def __init__( *, description: Optional[str] = None, immutable_id: Optional[str] = None, - configuration_access: Optional["DataCollectionEndpointConfigurationAccess"] = None, - logs_ingestion: Optional["DataCollectionEndpointLogsIngestion"] = None, - network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, + configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, + logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, + network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, **kwargs ): """ @@ -553,7 +555,7 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType @@ -561,8 +563,8 @@ class SystemData(msrest.serialization.Model): :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -582,26 +584,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -621,7 +623,7 @@ class DataCollectionEndpointResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType @@ -629,8 +631,8 @@ class DataCollectionEndpointResourceSystemData(SystemData): :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -650,26 +652,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -706,7 +708,7 @@ class DataCollectionRule(msrest.serialization.Model): ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -735,10 +737,10 @@ def __init__( *, description: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "StreamDeclaration"]] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -786,7 +788,7 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -911,7 +913,7 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -998,7 +1000,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat def __init__( self, *, - value: List["DataCollectionRuleAssociationProxyOnlyResource"], + value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, **kwargs ): @@ -1027,7 +1029,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. :vartype data_collection_endpoint_id: str - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState @@ -1075,7 +1077,7 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType @@ -1083,8 +1085,8 @@ class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1104,26 +1106,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -1165,12 +1167,12 @@ class DataSourcesSpec(msrest.serialization.Model): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, - log_files: Optional[List["LogFilesDataSource"]] = None, - iis_logs: Optional[List["IisLogsDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, + log_files: Optional[List["_models.LogFilesDataSource"]] = None, + iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, **kwargs ): """ @@ -1235,12 +1237,12 @@ class DataCollectionRuleDataSources(DataSourcesSpec): def __init__( self, *, - performance_counters: Optional[List["PerfCounterDataSource"]] = None, - windows_event_logs: Optional[List["WindowsEventLogDataSource"]] = None, - syslog: Optional[List["SyslogDataSource"]] = None, - extensions: Optional[List["ExtensionDataSource"]] = None, - log_files: Optional[List["LogFilesDataSource"]] = None, - iis_logs: Optional[List["IisLogsDataSource"]] = None, + performance_counters: Optional[List["_models.PerfCounterDataSource"]] = None, + windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, + syslog: Optional[List["_models.SyslogDataSource"]] = None, + extensions: Optional[List["_models.ExtensionDataSource"]] = None, + log_files: Optional[List["_models.LogFilesDataSource"]] = None, + iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, **kwargs ): """ @@ -1284,8 +1286,8 @@ class DestinationsSpec(msrest.serialization.Model): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -1320,8 +1322,8 @@ class DataCollectionRuleDestinations(DestinationsSpec): def __init__( self, *, - log_analytics: Optional[List["LogAnalyticsDestination"]] = None, - azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, + log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, + azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): """ @@ -1372,7 +1374,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :ivar kind: The kind of the resource. Known values are: "Linux", "Windows". :vartype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. @@ -1409,7 +1411,7 @@ class DataCollectionRuleResource(msrest.serialization.Model): ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -1452,13 +1454,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - kind: Optional[Union[str, "KnownDataCollectionRuleResourceKind"]] = None, + kind: Optional[Union[str, "_models.KnownDataCollectionRuleResourceKind"]] = None, description: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "StreamDeclaration"]] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -1466,7 +1468,7 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :keyword kind: The kind of the resource. Known values are: "Linux", "Windows". :paramtype kind: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleResourceKind :keyword description: Description of the data collection rule. @@ -1532,7 +1534,7 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DataCollectionRuleResource"], + value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs ): @@ -1576,7 +1578,7 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleDestinations :ivar data_flows: The specification of data flows. :vartype data_flows: list[~$(python-base-namespace).v2022_02_01_preview.models.DataFlow] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", + :ivar provisioning_state: The resource provisioning state. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownDataCollectionRuleProvisioningState @@ -1605,10 +1607,10 @@ def __init__( *, description: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - stream_declarations: Optional[Dict[str, "StreamDeclaration"]] = None, - data_sources: Optional["DataCollectionRuleDataSources"] = None, - destinations: Optional["DataCollectionRuleDestinations"] = None, - data_flows: Optional[List["DataFlow"]] = None, + stream_declarations: Optional[Dict[str, "_models.StreamDeclaration"]] = None, + data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, + destinations: Optional["_models.DataCollectionRuleDestinations"] = None, + data_flows: Optional[List["_models.DataFlow"]] = None, **kwargs ): """ @@ -1639,7 +1641,7 @@ class DataCollectionRuleResourceSystemData(SystemData): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType @@ -1647,8 +1649,8 @@ class DataCollectionRuleResourceSystemData(SystemData): :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1668,26 +1670,26 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~$(python-base-namespace).v2022_02_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -1721,7 +1723,7 @@ class DataFlow(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownDataFlowStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, destinations: Optional[List[str]] = None, transform_kql: Optional[str] = None, output_stream: Optional[str] = None, @@ -1868,7 +1870,7 @@ class ErrorResponseCommonV2(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -1919,7 +1921,7 @@ def __init__( self, *, extension_name: str, - streams: Optional[List[Union[str, "KnownExtensionDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownExtensionDataSourceStreams"]]] = None, extension_settings: Optional[Any] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, @@ -2056,7 +2058,7 @@ class LogFilesDataSource(msrest.serialization.Model): :vartype streams: list[str] :ivar file_patterns: Required. File Patterns where the log files are located. :vartype file_patterns: list[str] - :ivar format: Required. The data format of the log files. Possible values include: "text". + :ivar format: Required. The data format of the log files. Known values are: "text". :vartype format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFilesDataSourceFormat :ivar settings: The log files specific settings. @@ -2087,8 +2089,8 @@ def __init__( *, streams: List[str], file_patterns: List[str], - format: Union[str, "KnownLogFilesDataSourceFormat"], - settings: Optional["LogFilesDataSourceSettings"] = None, + format: Union[str, "_models.KnownLogFilesDataSourceFormat"], + settings: Optional["_models.LogFilesDataSourceSettings"] = None, name: Optional[str] = None, **kwargs ): @@ -2098,7 +2100,7 @@ def __init__( :paramtype streams: list[str] :keyword file_patterns: Required. File Patterns where the log files are located. :paramtype file_patterns: list[str] - :keyword format: Required. The data format of the log files. Possible values include: "text". + :keyword format: Required. The data format of the log files. Known values are: "text". :paramtype format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFilesDataSourceFormat :keyword settings: The log files specific settings. @@ -2131,7 +2133,7 @@ class LogFileSettings(msrest.serialization.Model): def __init__( self, *, - text: Optional["LogFileSettingsText"] = None, + text: Optional["_models.LogFileSettingsText"] = None, **kwargs ): """ @@ -2156,7 +2158,7 @@ class LogFilesDataSourceSettings(LogFileSettings): def __init__( self, *, - text: Optional["LogFileSettingsText"] = None, + text: Optional["_models.LogFileSettingsText"] = None, **kwargs ): """ @@ -2171,8 +2173,8 @@ class LogFileTextSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Possible - values include: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY + :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Known + values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", "yyyy-MM-ddTHH:mm:ssK". :vartype record_start_timestamp_format: str or @@ -2190,14 +2192,14 @@ class LogFileTextSettings(msrest.serialization.Model): def __init__( self, *, - record_start_timestamp_format: Union[str, "KnownLogFileTextSettingsRecordStartTimestampFormat"], + record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], **kwargs ): """ - :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. - Possible values include: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, - YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss - zzz", "yyyy-MM-ddTHH:mm:ssK". + :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. Known + values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY + HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", + "yyyy-MM-ddTHH:mm:ssK". :paramtype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ @@ -2210,8 +2212,8 @@ class LogFileSettingsText(LogFileTextSettings): All required parameters must be populated in order to send to Azure. - :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Possible - values include: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY + :ivar record_start_timestamp_format: Required. One of the supported timestamp formats. Known + values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", "yyyy-MM-ddTHH:mm:ssK". :vartype record_start_timestamp_format: str or @@ -2229,14 +2231,14 @@ class LogFileSettingsText(LogFileTextSettings): def __init__( self, *, - record_start_timestamp_format: Union[str, "KnownLogFileTextSettingsRecordStartTimestampFormat"], + record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], **kwargs ): """ - :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. - Possible values include: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, - YYYY HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss - zzz", "yyyy-MM-ddTHH:mm:ssK". + :keyword record_start_timestamp_format: Required. One of the supported timestamp formats. Known + values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY + HH:MM:SS", "yyMMdd HH:mm:ss", "ddMMyy HH:mm:ss", "MMM d hh:mm:ss", "dd/MMM/yyyy:HH:mm:ss zzz", + "yyyy-MM-ddTHH:mm:ssK". :paramtype record_start_timestamp_format: str or ~$(python-base-namespace).v2022_02_01_preview.models.KnownLogFileTextSettingsRecordStartTimestampFormat """ @@ -2276,7 +2278,7 @@ class PerfCounterDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownPerfCounterDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownPerfCounterDataSourceStreams"]]] = None, sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, @@ -2347,7 +2349,7 @@ class StreamDeclaration(msrest.serialization.Model): def __init__( self, *, - columns: Optional[List["ColumnDefinition"]] = None, + columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs ): """ @@ -2389,9 +2391,9 @@ class SyslogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownSyslogDataSourceStreams"]]] = None, - facility_names: Optional[List[Union[str, "KnownSyslogDataSourceFacilityNames"]]] = None, - log_levels: Optional[List[Union[str, "KnownSyslogDataSourceLogLevels"]]] = None, + streams: Optional[List[Union[str, "_models.KnownSyslogDataSourceStreams"]]] = None, + facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, + log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, **kwargs ): @@ -2445,7 +2447,7 @@ class WindowsEventLogDataSource(msrest.serialization.Model): def __init__( self, *, - streams: Optional[List[Union[str, "KnownWindowsEventLogDataSourceStreams"]]] = None, + streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, **kwargs diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py index bae76fc255fc..3aef5b96e81e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_monitor_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -20,7 +19,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class KnownColumnDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownColumnDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the column data. """ @@ -32,7 +31,7 @@ class KnownColumnDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enu DATETIME = "datetime" DYNAMIC = "dynamic" -class KnownDataCollectionEndpointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. This property is READ-ONLY. """ @@ -42,14 +41,14 @@ class KnownDataCollectionEndpointProvisioningState(with_metaclass(CaseInsensitiv SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionEndpointResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleAssociationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -59,7 +58,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseIns SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource provisioning state. """ @@ -69,14 +68,14 @@ class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnu SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleResourceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataFlowStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -84,7 +83,7 @@ class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownExtensionDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -92,13 +91,13 @@ class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, st MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownLogFilesDataSourceFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownLogFilesDataSourceFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The data format of the log files """ TEXT = "text" -class KnownLogFileTextSettingsRecordStartTimestampFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownLogFileTextSettingsRecordStartTimestampFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """One of the supported timestamp formats """ @@ -112,12 +111,12 @@ class KnownLogFileTextSettingsRecordStartTimestampFormat(with_metaclass(CaseInse DD_MMM_YYYY_HH_MM_SS_ZZZ = "dd/MMM/yyyy:HH:mm:ss zzz" YYYY_MM_DD_THH_MM_SS_K = "yyyy-MM-ddTHH:mm:ssK" -class KnownPerfCounterDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownPerfCounterDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" -class KnownPublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownPublicNetworkAccessOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The configuration to set whether network access from public internet to the endpoints are allowed. """ @@ -125,7 +124,7 @@ class KnownPublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, st ENABLED = "Enabled" DISABLED = "Disabled" -class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceFacilityNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): AUTH = "auth" AUTHPRIV = "authpriv" @@ -149,7 +148,7 @@ class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, LOCAL7 = "local7" ASTERISK = "*" -class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceLogLevels(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEBUG = "Debug" INFO = "Info" @@ -161,11 +160,11 @@ class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str EMERGENCY = "Emergency" ASTERISK = "*" -class KnownSyslogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_SYSLOG = "Microsoft-Syslog" -class KnownWindowsEventLogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KnownWindowsEventLogDataSourceStreams(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 86676ba92623..eea5749564d8 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 @@ -10,8 +10,13 @@ from ._data_collection_rule_associations_operations import DataCollectionRuleAssociationsOperations 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 patch_sdk as _patch_sdk __all__ = [ 'DataCollectionEndpointsOperations', 'DataCollectionRuleAssociationsOperations', 'DataCollectionRulesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 0256d05f2e38..d861321fb7e0 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,29 +66,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( data_collection_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_request( resource_group_name: str, data_collection_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionEndpointResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, data_collection_endpoint_name: str, *, - json: JSONType = None, + json: Optional[_models.ResourceForUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,62 +228,62 @@ def build_delete_request( data_collection_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionEndpointsOperations(object): - """DataCollectionEndpointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.MonitorManagementClient`'s + :attr:`data_collection_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. @@ -289,31 +297,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,13 +364,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: + ) -> Iterable[_models.DataCollectionEndpointResourceListResult]: """Lists all data collection endpoints in the specified subscription. Lists all data collection endpoints in the specified subscription. @@ -359,29 +382,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -395,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,7 +447,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -417,7 +455,7 @@ def get( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Returns the specified data collection endpoint. Returns the specified data collection endpoint. @@ -432,23 +470,35 @@ def get( :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +513,7 @@ 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}"} # type: ignore @distributed_trace @@ -471,9 +521,9 @@ def create( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.DataCollectionEndpointResource"] = None, + body: Optional[_models.DataCollectionEndpointResource] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Creates or updates a data collection endpoint. Creates or updates a data collection endpoint. @@ -483,20 +533,24 @@ def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionEndpointResource') @@ -507,14 +561,21 @@ def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -533,7 +594,7 @@ def create( return deserialized - 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}"} # type: ignore @distributed_trace @@ -541,9 +602,9 @@ def update( self, resource_group_name: str, data_collection_endpoint_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionEndpointResource": + ) -> _models.DataCollectionEndpointResource: """Updates part of a data collection endpoint. Updates part of a data collection endpoint. @@ -553,20 +614,24 @@ def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. :type data_collection_endpoint_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionEndpointResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionEndpointResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -577,14 +642,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,11 +671,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_endpoint_name: str, @@ -623,23 +695,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -650,5 +734,5 @@ def delete( 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}"} # type: ignore 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 9ed841948399..0bed24410bfa 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,29 +31,31 @@ def build_list_by_resource_request( resource_uri: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations") path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,31 +66,33 @@ def build_list_by_rule_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -99,31 +103,33 @@ def build_list_by_data_collection_endpoint_request( data_collection_endpoint_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations") # 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), "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -133,30 +139,32 @@ def build_get_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -165,38 +173,39 @@ def build_create_request( resource_uri: str, association_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -208,61 +217,61 @@ def build_delete_request( association_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}") # pylint: disable=line-too-long path_format_arguments = { "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), "associationName": _SERIALIZER.url("association_name", association_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRuleAssociationsOperations(object): - """DataCollectionRuleAssociationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRuleAssociationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.MonitorManagementClient`'s + :attr:`data_collection_rule_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource( self, resource_uri: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -276,29 +285,40 @@ def list_by_resource( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=self.list_by_resource.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_request( resource_uri=resource_uri, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -312,7 +332,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -326,7 +350,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"} # type: ignore @distributed_trace def list_by_rule( @@ -334,7 +358,7 @@ def list_by_rule( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -351,11 +375,16 @@ def list_by_rule( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -363,10 +392,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.list_by_rule.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -374,10 +406,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +426,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,7 +444,7 @@ 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"} # type: ignore @distributed_trace def list_by_data_collection_endpoint( @@ -413,7 +452,7 @@ def list_by_data_collection_endpoint( resource_group_name: str, data_collection_endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult]: """Lists associations for the specified data collection endpoint. Lists associations for the specified data collection endpoint. @@ -430,11 +469,16 @@ def list_by_data_collection_endpoint( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -442,10 +486,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=self.list_by_data_collection_endpoint.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -453,10 +500,13 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_endpoint_name=data_collection_endpoint_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -470,7 +520,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,7 +538,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -492,7 +546,7 @@ def get( resource_uri: str, association_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Returns the specified association. Returns the specified association. @@ -507,22 +561,34 @@ def get( ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -537,7 +603,7 @@ def get( return deserialized - get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + get.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace @@ -545,9 +611,9 @@ def create( self, resource_uri: str, association_name: str, - body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + body: Optional[_models.DataCollectionRuleAssociationProxyOnlyResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": + ) -> _models.DataCollectionRuleAssociationProxyOnlyResource: """Creates or updates an association. Creates or updates an association. @@ -556,7 +622,7 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. :type association_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response @@ -565,13 +631,17 @@ def create( ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') @@ -581,14 +651,21 @@ def create( request = build_create_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -607,11 +684,11 @@ def create( return deserialized - create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + create.metadata = {'url': "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_uri: str, association_name: str, @@ -630,22 +707,34 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_uri=resource_uri, association_name=association_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -656,5 +745,5 @@ def delete( 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}"} # type: ignore 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 840d4b52a742..82ab3b1b8442 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,30 +32,32 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules") # 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 = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -64,29 +66,31 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -97,31 +101,33 @@ def build_get_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -131,39 +137,40 @@ def build_create_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.DataCollectionRuleResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -175,39 +182,40 @@ def build_update_request( resource_group_name: str, data_collection_rule_name: str, *, - json: JSONType = None, + json: Optional[_models.ResourceForUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -220,62 +228,62 @@ def build_delete_request( data_collection_rule_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}") # 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), "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DataCollectionRulesOperations(object): - """DataCollectionRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataCollectionRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~$(python-base-namespace).v2022_02_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_02_01_preview.MonitorManagementClient`'s + :attr:`data_collection_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -289,31 +297,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_resource_group_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -327,7 +346,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,13 +364,13 @@ 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"} # type: ignore @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: + ) -> Iterable[_models.DataCollectionRuleResourceListResult]: """Lists all data collection rules in the specified subscription. Lists all data collection rules in the specified subscription. @@ -359,29 +382,40 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] + _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] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_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) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -395,7 +429,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,7 +447,7 @@ 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"} # type: ignore @distributed_trace def get( @@ -417,7 +455,7 @@ def get( resource_group_name: str, data_collection_rule_name: str, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Returns the specified data collection rule. Returns the specified data collection rule. @@ -432,23 +470,35 @@ def get( :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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] request = build_get_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +513,7 @@ 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}"} # type: ignore @distributed_trace @@ -471,9 +521,9 @@ def create( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.DataCollectionRuleResource"] = None, + body: Optional[_models.DataCollectionRuleResource] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -483,20 +533,24 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'DataCollectionRuleResource') @@ -507,14 +561,21 @@ def create( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -533,7 +594,7 @@ def create( return deserialized - 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}"} # type: ignore @distributed_trace @@ -541,9 +602,9 @@ def update( self, resource_group_name: str, data_collection_rule_name: str, - body: Optional["_models.ResourceForUpdate"] = None, + body: Optional[_models.ResourceForUpdate] = None, **kwargs: Any - ) -> "_models.DataCollectionRuleResource": + ) -> _models.DataCollectionRuleResource: """Updates part of a data collection rule. Updates part of a data collection rule. @@ -553,20 +614,24 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. :type data_collection_rule_name: str - :param body: The payload. + :param body: The payload. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCollectionRuleResource] if body is not None: _json = self._serialize.body(body, 'ResourceForUpdate') @@ -577,14 +642,21 @@ def update( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,11 +671,11 @@ 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}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, data_collection_rule_name: str, @@ -623,23 +695,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, data_collection_rule_name=data_collection_rule_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -650,5 +734,5 @@ def delete( 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}"} # type: ignore diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py similarity index 68% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py index ec9090a57df0..7389161517c6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py similarity index 80% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py index 2f232283b850..352bde243cfd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,19 +27,30 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "TokenCredential", + subscription_id: str, **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential - self.api_version = "2017-11-01-preview" + 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) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json similarity index 79% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json index dc6519555c3a..5de5231ff8ca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json @@ -1,6 +1,6 @@ { - "chosen_version": "2017-11-01-preview", - "total_api_version_list": ["2017-11-01-preview"], + "chosen_version": "2022-04-01", + "total_api_version_list": ["2022-04-01"], "client": { "name": "MonitorManagementClient", "filename": "_monitor_management_client", @@ -8,10 +8,10 @@ "host_value": "\"https://management.azure.com\"", "parameterized_host_template": null, "azure_arm": true, - "has_lro_operations": false, + "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -20,6 +20,12 @@ "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true } }, "async": { @@ -28,11 +34,17 @@ "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true } }, "constant": { }, - "call": "credential", + "call": "credential, subscription_id", "service_client_specific": { "sync": { "api_version": { @@ -85,6 +97,6 @@ "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": { - "metric_baseline": "MetricBaselineOperations" + "action_groups": "ActionGroupsOperations" } } \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py similarity index 75% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py index 54b7a3e3d3f5..5bc9559c063d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py @@ -7,15 +7,16 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricBaselineOperations +from .operations import ActionGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,34 +25,43 @@ class MonitorManagementClient: """Monitor Management Client. - :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: - $(python-base-namespace).v2017_11_01_preview.operations.MetricBaselineOperations + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: $(python-base-namespace).v2022_04_01.operations.ActionGroupsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "TokenCredential", + subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) + 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.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_vendor.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py similarity index 95% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py index 47babc28d5ed..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_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 = "3.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py similarity index 66% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py index 4eba911f1c6e..ee931f53dd58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MonitorManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py similarity index 80% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py index b94ccd520e18..5233148746fd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClientConfiguration(Configuration): +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 @@ -27,19 +27,30 @@ class MonitorManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", + subscription_id: str, **kwargs: Any ) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") self.credential = credential - self.api_version = "2017-11-01-preview" + 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) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py similarity index 76% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py index 294998b3c92d..11e0698e4977 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py @@ -7,15 +7,16 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricBaselineOperations +from .operations import ActionGroupsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,29 +25,39 @@ class MonitorManagementClient: """Monitor Management Client. - :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: - $(python-base-namespace).v2017_11_01_preview.aio.operations.MetricBaselineOperations + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: + $(python-base-namespace).v2022_04_01.aio.operations.ActionGroupsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", + subscription_id: str, base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) + 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.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py similarity index 59% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/__init__.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py index 04cb64ccf630..60f9d62f0ead 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py @@ -6,8 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._metric_baseline_operations import MetricBaselineOperations +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 patch_sdk as _patch_sdk __all__ = [ - 'MetricBaselineOperations', + 'ActionGroupsOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..5e5f094900a1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py @@ -0,0 +1,950 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._action_groups_operations import build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_04_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group: The action group to create or use for the update. + :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. + :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + async def _post_test_notifications_initial( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_test_notifications_initial( # type: ignore + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + async def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + @distributed_trace_async + async def get_test_notifications( + self, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace_async + async def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def list_by_subscription_id( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ActionGroupList]: + """Get a list of all action groups 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 ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ActionGroupList]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param enable_request: The receiver to re-enable. + :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..7d4cce34b707 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/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 ActionDetail +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import AzureResource +from ._models_py3 import Context +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import EventHubReceiver +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import NotificationRequestBody +from ._models_py3 import SmsReceiver +from ._models_py3 import TestNotificationDetailsResponse +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + + +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 patch_sdk as _patch_sdk +__all__ = [ + 'ActionDetail', + 'ActionGroupList', + 'ActionGroupPatchBody', + 'ActionGroupResource', + 'ArmRoleReceiver', + 'AutomationRunbookReceiver', + 'AzureAppPushReceiver', + 'AzureFunctionReceiver', + 'AzureResource', + 'Context', + 'EmailReceiver', + 'EnableRequest', + 'ErrorResponse', + 'EventHubReceiver', + 'ItsmReceiver', + 'LogicAppReceiver', + 'NotificationRequestBody', + 'SmsReceiver', + 'TestNotificationDetailsResponse', + 'VoiceReceiver', + 'WebhookReceiver', + 'ReceiverStatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..3a38c32b0fe1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py @@ -0,0 +1,1315 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, TYPE_CHECKING + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class ActionDetail(msrest.serialization.Model): + """The action detail. + + :ivar mechanism_type: The mechanism type. + :vartype mechanism_type: str + :ivar name: The name of the action. + :vartype name: str + :ivar status: The status of the action. + :vartype status: str + :ivar sub_state: The substatus of the action. + :vartype sub_state: str + :ivar send_time: The send time. + :vartype send_time: str + :ivar detail: The detail of the friendly error message. + :vartype detail: str + """ + + _attribute_map = { + 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, + 'name': {'key': 'Name', 'type': 'str'}, + 'status': {'key': 'Status', 'type': 'str'}, + 'sub_state': {'key': 'SubState', 'type': 'str'}, + 'send_time': {'key': 'SendTime', 'type': 'str'}, + 'detail': {'key': 'Detail', 'type': 'str'}, + } + + def __init__( + self, + *, + mechanism_type: Optional[str] = None, + name: Optional[str] = None, + status: Optional[str] = None, + sub_state: Optional[str] = None, + send_time: Optional[str] = None, + detail: Optional[str] = None, + **kwargs + ): + """ + :keyword mechanism_type: The mechanism type. + :paramtype mechanism_type: str + :keyword name: The name of the action. + :paramtype name: str + :keyword status: The status of the action. + :paramtype status: str + :keyword sub_state: The substatus of the action. + :paramtype sub_state: str + :keyword send_time: The send time. + :paramtype send_time: str + :keyword detail: The detail of the friendly error message. + :paramtype detail: str + """ + super(ActionDetail, self).__init__(**kwargs) + self.mechanism_type = mechanism_type + self.name = name + self.status = status + self.sub_state = sub_state + self.send_time = send_time + self.detail = detail + + +class ActionGroupList(msrest.serialization.Model): + """A list of action groups. + + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super(ActionGroupList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ActionGroupPatchBody(msrest.serialization.Model): + """An action group object for the body of patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :vartype enabled: bool + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + enabled: Optional[bool] = True, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ + super(ActionGroupPatchBody, self).__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class AzureResource(msrest.serialization.Model): + """An azure resource object. + + 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: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ActionGroupResource(AzureResource): + """An action group 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: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :vartype enabled: bool + :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] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2022_04_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2022_04_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2022_04_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2022_04_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2022_04_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~$(python-base-namespace).v2022_04_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'group_short_name': {'max_length': 12, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, + 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, + 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, + 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, + 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, + 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, + 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, + 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, + 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, + 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + group_short_name: Optional[str] = None, + enabled: Optional[bool] = True, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :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] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2022_04_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2022_04_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2022_04_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2022_04_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2022_04_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] + """ + super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + self.group_short_name = group_short_name + self.enabled = enabled + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class ArmRoleReceiver(msrest.serialization.Model): + """An arm role receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'role_id': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'role_id': {'key': 'roleId', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + role_id: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(ArmRoleReceiver, self).__init__(**kwargs) + self.name = name + self.role_id = role_id + self.use_common_alert_schema = use_common_alert_schema + + +class AutomationRunbookReceiver(msrest.serialization.Model): + """The Azure Automation Runbook notification receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'automation_account_id': {'required': True}, + 'runbook_name': {'required': True}, + 'webhook_resource_id': {'required': True}, + 'is_global_runbook': {'required': True}, + } + + _attribute_map = { + 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, + 'runbook_name': {'key': 'runbookName', 'type': 'str'}, + 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, + 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + automation_account_id: str, + runbook_name: str, + webhook_resource_id: str, + is_global_runbook: bool, + name: Optional[str] = None, + service_uri: Optional[str] = None, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(AutomationRunbookReceiver, self).__init__(**kwargs) + self.automation_account_id = automation_account_id + self.runbook_name = runbook_name + self.webhook_resource_id = webhook_resource_id + self.is_global_runbook = is_global_runbook + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + + +class AzureAppPushReceiver(msrest.serialization.Model): + """The Azure mobile App push notification receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str + """ + + _validation = { + 'name': {'required': True}, + 'email_address': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + email_address: str, + **kwargs + ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ + super(AzureAppPushReceiver, self).__init__(**kwargs) + self.name = name + self.email_address = email_address + + +class AzureFunctionReceiver(msrest.serialization.Model): + """An azure function receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the azure function receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'function_app_resource_id': {'required': True}, + 'function_name': {'required': True}, + 'http_trigger_url': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, + 'function_name': {'key': 'functionName', 'type': 'str'}, + 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + function_app_resource_id: str, + function_name: str, + http_trigger_url: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(AzureFunctionReceiver, self).__init__(**kwargs) + self.name = name + self.function_app_resource_id = function_app_resource_id + self.function_name = function_name + self.http_trigger_url = http_trigger_url + self.use_common_alert_schema = use_common_alert_schema + + +class Context(msrest.serialization.Model): + """The context info. + + :ivar notification_source: The source of the notification request. + :vartype notification_source: str + :ivar context_type: The context id type. + :vartype context_type: str + """ + + _attribute_map = { + 'notification_source': {'key': 'notificationSource', 'type': 'str'}, + 'context_type': {'key': 'contextType', 'type': 'str'}, + } + + def __init__( + self, + *, + notification_source: Optional[str] = None, + context_type: Optional[str] = None, + **kwargs + ): + """ + :keyword notification_source: The source of the notification request. + :paramtype notification_source: str + :keyword context_type: The context id type. + :paramtype context_type: str + """ + super(Context, self).__init__(**kwargs) + self.notification_source = notification_source + self.context_type = context_type + + +class EmailReceiver(msrest.serialization.Model): + """An email receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". + :vartype status: str or ~$(python-base-namespace).v2022_04_01.models.ReceiverStatus + """ + + _validation = { + 'name': {'required': True}, + 'email_address': {'required': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + email_address: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(EmailReceiver, self).__init__(**kwargs) + self.name = name + self.email_address = email_address + self.use_common_alert_schema = use_common_alert_schema + self.status = None + + +class EnableRequest(msrest.serialization.Model): + """Describes a receiver that should be resubscribed. + + All required parameters must be populated in order to send to Azure. + + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str + """ + + _validation = { + 'receiver_name': {'required': True}, + } + + _attribute_map = { + 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + } + + def __init__( + self, + *, + receiver_name: str, + **kwargs + ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ + super(EnableRequest, self).__init__(**kwargs) + self.receiver_name = receiver_name + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class EventHubReceiver(msrest.serialization.Model): + """An Event hub receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar event_hub_name_space: Required. The Event Hub namespace. + :vartype event_hub_name_space: str + :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :vartype event_hub_name: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar tenant_id: The tenant Id for the subscription containing this event hub. + :vartype tenant_id: str + :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :vartype subscription_id: str + """ + + _validation = { + 'name': {'required': True}, + 'event_hub_name_space': {'required': True}, + 'event_hub_name': {'required': True}, + 'subscription_id': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, + 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + event_hub_name_space: str, + event_hub_name: str, + subscription_id: str, + use_common_alert_schema: Optional[bool] = False, + tenant_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword event_hub_name_space: Required. The Event Hub namespace. + :paramtype event_hub_name_space: str + :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :paramtype event_hub_name: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword tenant_id: The tenant Id for the subscription containing this event hub. + :paramtype tenant_id: str + :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :paramtype subscription_id: str + """ + super(EventHubReceiver, self).__init__(**kwargs) + self.name = name + self.event_hub_name_space = event_hub_name_space + self.event_hub_name = event_hub_name + self.use_common_alert_schema = use_common_alert_schema + self.tenant_id = tenant_id + self.subscription_id = subscription_id + + +class ItsmReceiver(msrest.serialization.Model): + """An Itsm receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined + in above workspace. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :vartype region: str + """ + + _validation = { + 'name': {'required': True}, + 'workspace_id': {'required': True}, + 'connection_id': {'required': True}, + 'ticket_configuration': {'required': True}, + 'region': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, + 'connection_id': {'key': 'connectionId', 'type': 'str'}, + 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + workspace_id: str, + connection_id: str, + ticket_configuration: str, + region: str, + **kwargs + ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ + super(ItsmReceiver, self).__init__(**kwargs) + self.name = name + self.workspace_id = workspace_id + self.connection_id = connection_id + self.ticket_configuration = ticket_configuration + self.region = region + + +class LogicAppReceiver(msrest.serialization.Model): + """A logic app receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'resource_id': {'required': True}, + 'callback_url': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + resource_id: str, + callback_url: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(LogicAppReceiver, self).__init__(**kwargs) + self.name = name + self.resource_id = resource_id + self.callback_url = callback_url + self.use_common_alert_schema = use_common_alert_schema + + +class NotificationRequestBody(msrest.serialization.Model): + """The request body which contain contact detail metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar alert_type: Required. The name of the supported alert type. + :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] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2022_04_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2022_04_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2022_04_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2022_04_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2022_04_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~$(python-base-namespace).v2022_04_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] + """ + + _validation = { + 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, + } + + _attribute_map = { + 'alert_type': {'key': 'alertType', 'type': 'str'}, + 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, + 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, + 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, + 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, + 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, + 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, + 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, + 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, + 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, + 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, + } + + def __init__( + self, + *, + alert_type: str, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 + ): + """ + :keyword alert_type: Required. The name of the supported alert type. + :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] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2022_04_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2022_04_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2022_04_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2022_04_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2022_04_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2022_04_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2022_04_01.models.EventHubReceiver] + """ + super(NotificationRequestBody, self).__init__(**kwargs) + self.alert_type = alert_type + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class SmsReceiver(msrest.serialization.Model): + """An SMS receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + "Disabled". + :vartype status: str or ~$(python-base-namespace).v2022_04_01.models.ReceiverStatus + """ + + _validation = { + 'name': {'required': True}, + 'country_code': {'required': True}, + 'phone_number': {'required': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + country_code: str, + phone_number: str, + **kwargs + ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ + super(SmsReceiver, self).__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + self.status = None + + +class TestNotificationDetailsResponse(msrest.serialization.Model): + """The details of the test notification results. + + All required parameters must be populated in order to send to Azure. + + :ivar context: The context info. + :vartype context: ~$(python-base-namespace).v2022_04_01.models.Context + :ivar state: Required. The overall state. + :vartype state: str + :ivar completed_time: The completed time. + :vartype completed_time: str + :ivar created_time: The created time. + :vartype created_time: str + :ivar action_details: The list of action detail. + :vartype action_details: list[~$(python-base-namespace).v2022_04_01.models.ActionDetail] + """ + + _validation = { + 'state': {'required': True}, + } + + _attribute_map = { + 'context': {'key': 'context', 'type': 'Context'}, + 'state': {'key': 'state', 'type': 'str'}, + 'completed_time': {'key': 'completedTime', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'str'}, + 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, + } + + def __init__( + self, + *, + state: str, + context: Optional["_models.Context"] = None, + completed_time: Optional[str] = None, + created_time: Optional[str] = None, + action_details: Optional[List["_models.ActionDetail"]] = None, + **kwargs + ): + """ + :keyword context: The context info. + :paramtype context: ~$(python-base-namespace).v2022_04_01.models.Context + :keyword state: Required. The overall state. + :paramtype state: str + :keyword completed_time: The completed time. + :paramtype completed_time: str + :keyword created_time: The created time. + :paramtype created_time: str + :keyword action_details: The list of action detail. + :paramtype action_details: list[~$(python-base-namespace).v2022_04_01.models.ActionDetail] + """ + super(TestNotificationDetailsResponse, self).__init__(**kwargs) + self.context = context + self.state = state + self.completed_time = completed_time + self.created_time = created_time + self.action_details = action_details + + +class VoiceReceiver(msrest.serialization.Model): + """A voice receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str + """ + + _validation = { + 'name': {'required': True}, + 'country_code': {'required': True}, + 'phone_number': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + country_code: str, + phone_number: str, + **kwargs + ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ + super(VoiceReceiver, self).__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + + +class WebhookReceiver(msrest.serialization.Model): + """A webhook receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str + """ + + _validation = { + 'name': {'required': True}, + 'service_uri': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, + 'object_id': {'key': 'objectId', 'type': 'str'}, + 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + service_uri: str, + use_common_alert_schema: Optional[bool] = False, + use_aad_auth: Optional[bool] = False, + object_id: Optional[str] = None, + identifier_uri: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ + super(WebhookReceiver, self).__init__(**kwargs) + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + self.use_aad_auth = use_aad_auth + self.object_id = object_id + self.identifier_uri = identifier_uri + self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py similarity index 63% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py index 84dc084ea9ed..2502d854d186 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_monitor_management_client_enums.py @@ -7,19 +7,14 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - - DATA = "Data" - METADATA = "Metadata" - -class Sensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """the sensitivity of the baseline. +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the status of the receiver. Receivers that are not Enabled will not receive any + communications. """ - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" + NOT_SPECIFIED = "NotSpecified" + ENABLED = "Enabled" + DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..60f9d62f0ead --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py @@ -0,0 +1,18 @@ +# 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 ._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 patch_sdk as _patch_sdk +__all__ = [ + 'ActionGroupsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..9ea13c25a685 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py @@ -0,0 +1,1385 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: Optional[_models.ActionGroupResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + *, + json: Optional[_models.ActionGroupPatchBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_post_test_notifications_request_initial( + subscription_id: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_notifications_at_resource_group_level_request_initial( + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_test_notifications_request( + subscription_id: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_test_notifications_at_resource_group_level_request( + subscription_id: str, + resource_group_name: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # 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), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_enable_receiver_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: Optional[_models.EnableRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_04_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group: The action group to create or use for the update. + :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. + :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + def _post_test_notifications_initial( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace + def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_test_notifications_initial( # type: ignore + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + @distributed_trace + def get_test_notifications( + self, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_04_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def list_by_subscription_id( + self, + **kwargs: Any + ) -> Iterable[_models.ActionGroupList]: + """Get a list of all action groups 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 ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ActionGroupList]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_04_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param enable_request: The receiver to re-enable. + :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/py.typed similarity index 100% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/py.typed rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/py.typed 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 new file mode 100644 index 000000000000..7389161517c6 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitor_management_client import MonitorManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['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 new file mode 100644 index 000000000000..91a604b890ba --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class 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. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-06-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-monitor/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/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 new file mode 100644 index 000000000000..a7c22b74128a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json @@ -0,0 +1,102 @@ +{ + "chosen_version": "2022-06-01", + "total_api_version_list": ["2022-06-01"], + "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": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "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 new file mode 100644 index 000000000000..334d6b5aeb3c --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class MonitorManagementClient: + """Monitor Management Client. + + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: $(python-base-namespace).v2022_06_01.operations.ActionGroupsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + 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.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MonitorManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py similarity index 80% rename from sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/__init__.py rename to sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py index 04cb64ccf630..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py @@ -6,8 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._metric_baseline_operations import MetricBaselineOperations - -__all__ = [ - 'MetricBaselineOperations', -] +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 new file mode 100644 index 000000000000..ee931f53dd58 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['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 new file mode 100644 index 000000000000..8401bd015ff7 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class 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. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-06-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-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_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py new file mode 100644 index 000000000000..f19eacc58157 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class MonitorManagementClient: + """Monitor Management Client. + + :ivar action_groups: ActionGroupsOperations operations + :vartype action_groups: + $(python-base-namespace).v2022_06_01.aio.operations.ActionGroupsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + 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.action_groups = ActionGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MonitorManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..60f9d62f0ead --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# 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 ._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 patch_sdk as _patch_sdk +__all__ = [ + 'ActionGroupsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..244e18f49441 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py @@ -0,0 +1,1165 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._action_groups_operations import build_create_notifications_at_action_group_resource_level_request_initial, build_create_notifications_at_resource_group_level_request_initial, build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_at_action_group_resource_level_request, build_get_test_notifications_at_resource_group_level_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_06_01.aio.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group: The action group to create or use for the update. + :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. + :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + async def _post_test_notifications_initial( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._post_test_notifications_initial( # type: ignore + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + async def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + async def _create_notifications_at_action_group_resource_level_initial( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + + @distributed_trace_async + async def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> AsyncLROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationDetailsResponse or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + @distributed_trace_async + async def get_test_notifications( + self, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace_async + async def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace_async + async def get_test_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_action_group_resource_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + 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 + + + @distributed_trace + def list_by_subscription_id( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ActionGroupList]: + """Get a list of all action groups 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 ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ActionGroupList]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace_async + async def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param enable_request: The receiver to re-enable. + :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..7d4cce34b707 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/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 ActionDetail +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import AzureResource +from ._models_py3 import Context +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import EventHubReceiver +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import NotificationRequestBody +from ._models_py3 import SmsReceiver +from ._models_py3 import TestNotificationDetailsResponse +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + + +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 patch_sdk as _patch_sdk +__all__ = [ + 'ActionDetail', + 'ActionGroupList', + 'ActionGroupPatchBody', + 'ActionGroupResource', + 'ArmRoleReceiver', + 'AutomationRunbookReceiver', + 'AzureAppPushReceiver', + 'AzureFunctionReceiver', + 'AzureResource', + 'Context', + 'EmailReceiver', + 'EnableRequest', + 'ErrorResponse', + 'EventHubReceiver', + 'ItsmReceiver', + 'LogicAppReceiver', + 'NotificationRequestBody', + 'SmsReceiver', + 'TestNotificationDetailsResponse', + 'VoiceReceiver', + 'WebhookReceiver', + 'ReceiverStatus', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..a2ead431a985 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py @@ -0,0 +1,1315 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, TYPE_CHECKING + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class ActionDetail(msrest.serialization.Model): + """The action detail. + + :ivar mechanism_type: The mechanism type. + :vartype mechanism_type: str + :ivar name: The name of the action. + :vartype name: str + :ivar status: The status of the action. + :vartype status: str + :ivar sub_state: The substatus of the action. + :vartype sub_state: str + :ivar send_time: The send time. + :vartype send_time: str + :ivar detail: The detail of the friendly error message. + :vartype detail: str + """ + + _attribute_map = { + 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, + 'name': {'key': 'Name', 'type': 'str'}, + 'status': {'key': 'Status', 'type': 'str'}, + 'sub_state': {'key': 'SubState', 'type': 'str'}, + 'send_time': {'key': 'SendTime', 'type': 'str'}, + 'detail': {'key': 'Detail', 'type': 'str'}, + } + + def __init__( + self, + *, + mechanism_type: Optional[str] = None, + name: Optional[str] = None, + status: Optional[str] = None, + sub_state: Optional[str] = None, + send_time: Optional[str] = None, + detail: Optional[str] = None, + **kwargs + ): + """ + :keyword mechanism_type: The mechanism type. + :paramtype mechanism_type: str + :keyword name: The name of the action. + :paramtype name: str + :keyword status: The status of the action. + :paramtype status: str + :keyword sub_state: The substatus of the action. + :paramtype sub_state: str + :keyword send_time: The send time. + :paramtype send_time: str + :keyword detail: The detail of the friendly error message. + :paramtype detail: str + """ + super(ActionDetail, self).__init__(**kwargs) + self.mechanism_type = mechanism_type + self.name = name + self.status = status + self.sub_state = sub_state + self.send_time = send_time + self.detail = detail + + +class ActionGroupList(msrest.serialization.Model): + """A list of action groups. + + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ + super(ActionGroupList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ActionGroupPatchBody(msrest.serialization.Model): + """An action group object for the body of patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :vartype enabled: bool + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + enabled: Optional[bool] = True, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ + super(ActionGroupPatchBody, self).__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class AzureResource(msrest.serialization.Model): + """An azure resource object. + + 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: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ActionGroupResource(AzureResource): + """An action group 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: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :vartype enabled: bool + :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] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2022_06_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2022_06_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2022_06_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2022_06_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2022_06_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~$(python-base-namespace).v2022_06_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'group_short_name': {'max_length': 12, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, + 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, + 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, + 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, + 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, + 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, + 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, + 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, + 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, + 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + group_short_name: Optional[str] = None, + enabled: Optional[bool] = True, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :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] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2022_06_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2022_06_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2022_06_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2022_06_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2022_06_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] + """ + super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) + self.group_short_name = group_short_name + self.enabled = enabled + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class ArmRoleReceiver(msrest.serialization.Model): + """An arm role receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'role_id': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'role_id': {'key': 'roleId', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + role_id: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(ArmRoleReceiver, self).__init__(**kwargs) + self.name = name + self.role_id = role_id + self.use_common_alert_schema = use_common_alert_schema + + +class AutomationRunbookReceiver(msrest.serialization.Model): + """The Azure Automation Runbook notification receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'automation_account_id': {'required': True}, + 'runbook_name': {'required': True}, + 'webhook_resource_id': {'required': True}, + 'is_global_runbook': {'required': True}, + } + + _attribute_map = { + 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, + 'runbook_name': {'key': 'runbookName', 'type': 'str'}, + 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, + 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + automation_account_id: str, + runbook_name: str, + webhook_resource_id: str, + is_global_runbook: bool, + name: Optional[str] = None, + service_uri: Optional[str] = None, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(AutomationRunbookReceiver, self).__init__(**kwargs) + self.automation_account_id = automation_account_id + self.runbook_name = runbook_name + self.webhook_resource_id = webhook_resource_id + self.is_global_runbook = is_global_runbook + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + + +class AzureAppPushReceiver(msrest.serialization.Model): + """The Azure mobile App push notification receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str + """ + + _validation = { + 'name': {'required': True}, + 'email_address': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + email_address: str, + **kwargs + ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ + super(AzureAppPushReceiver, self).__init__(**kwargs) + self.name = name + self.email_address = email_address + + +class AzureFunctionReceiver(msrest.serialization.Model): + """An azure function receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the azure function receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'function_app_resource_id': {'required': True}, + 'function_name': {'required': True}, + 'http_trigger_url': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, + 'function_name': {'key': 'functionName', 'type': 'str'}, + 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + function_app_resource_id: str, + function_name: str, + http_trigger_url: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(AzureFunctionReceiver, self).__init__(**kwargs) + self.name = name + self.function_app_resource_id = function_app_resource_id + self.function_name = function_name + self.http_trigger_url = http_trigger_url + self.use_common_alert_schema = use_common_alert_schema + + +class Context(msrest.serialization.Model): + """The context info. + + :ivar notification_source: The source of the notification request. + :vartype notification_source: str + :ivar context_type: The context id type. + :vartype context_type: str + """ + + _attribute_map = { + 'notification_source': {'key': 'notificationSource', 'type': 'str'}, + 'context_type': {'key': 'contextType', 'type': 'str'}, + } + + def __init__( + self, + *, + notification_source: Optional[str] = None, + context_type: Optional[str] = None, + **kwargs + ): + """ + :keyword notification_source: The source of the notification request. + :paramtype notification_source: str + :keyword context_type: The context id type. + :paramtype context_type: str + """ + super(Context, self).__init__(**kwargs) + self.notification_source = notification_source + self.context_type = context_type + + +class EmailReceiver(msrest.serialization.Model): + """An email receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar status: The receiver status of the e-mail. Known values are: "NotSpecified", "Enabled", + "Disabled". + :vartype status: str or ~$(python-base-namespace).v2022_06_01.models.ReceiverStatus + """ + + _validation = { + 'name': {'required': True}, + 'email_address': {'required': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'email_address': {'key': 'emailAddress', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + email_address: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(EmailReceiver, self).__init__(**kwargs) + self.name = name + self.email_address = email_address + self.use_common_alert_schema = use_common_alert_schema + self.status = None + + +class EnableRequest(msrest.serialization.Model): + """Describes a receiver that should be resubscribed. + + All required parameters must be populated in order to send to Azure. + + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str + """ + + _validation = { + 'receiver_name': {'required': True}, + } + + _attribute_map = { + 'receiver_name': {'key': 'receiverName', 'type': 'str'}, + } + + def __init__( + self, + *, + receiver_name: str, + **kwargs + ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ + super(EnableRequest, self).__init__(**kwargs) + self.receiver_name = receiver_name + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class EventHubReceiver(msrest.serialization.Model): + """An Event hub receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar event_hub_name_space: Required. The Event Hub namespace. + :vartype event_hub_name_space: str + :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :vartype event_hub_name: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar tenant_id: The tenant Id for the subscription containing this event hub. + :vartype tenant_id: str + :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :vartype subscription_id: str + """ + + _validation = { + 'name': {'required': True}, + 'event_hub_name_space': {'required': True}, + 'event_hub_name': {'required': True}, + 'subscription_id': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, + 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + event_hub_name_space: str, + event_hub_name: str, + subscription_id: str, + use_common_alert_schema: Optional[bool] = False, + tenant_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword event_hub_name_space: Required. The Event Hub namespace. + :paramtype event_hub_name_space: str + :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :paramtype event_hub_name: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword tenant_id: The tenant Id for the subscription containing this event hub. + :paramtype tenant_id: str + :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :paramtype subscription_id: str + """ + super(EventHubReceiver, self).__init__(**kwargs) + self.name = name + self.event_hub_name_space = event_hub_name_space + self.event_hub_name = event_hub_name + self.use_common_alert_schema = use_common_alert_schema + self.tenant_id = tenant_id + self.subscription_id = subscription_id + + +class ItsmReceiver(msrest.serialization.Model): + """An Itsm receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined + in above workspace. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :vartype region: str + """ + + _validation = { + 'name': {'required': True}, + 'workspace_id': {'required': True}, + 'connection_id': {'required': True}, + 'ticket_configuration': {'required': True}, + 'region': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, + 'connection_id': {'key': 'connectionId', 'type': 'str'}, + 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, + 'region': {'key': 'region', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + workspace_id: str, + connection_id: str, + ticket_configuration: str, + region: str, + **kwargs + ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ + super(ItsmReceiver, self).__init__(**kwargs) + self.name = name + self.workspace_id = workspace_id + self.connection_id = connection_id + self.ticket_configuration = ticket_configuration + self.region = region + + +class LogicAppReceiver(msrest.serialization.Model): + """A logic app receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + """ + + _validation = { + 'name': {'required': True}, + 'resource_id': {'required': True}, + 'callback_url': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + resource_id: str, + callback_url: str, + use_common_alert_schema: Optional[bool] = False, + **kwargs + ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ + super(LogicAppReceiver, self).__init__(**kwargs) + self.name = name + self.resource_id = resource_id + self.callback_url = callback_url + self.use_common_alert_schema = use_common_alert_schema + + +class NotificationRequestBody(msrest.serialization.Model): + """The request body which contain contact detail metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar alert_type: Required. The name of the supported alert type. + :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] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2022_06_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2022_06_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2022_06_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureAppPushReceiver] + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :vartype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AutomationRunbookReceiver] + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2022_06_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2022_06_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this + action group. + :vartype azure_function_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureFunctionReceiver] + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :vartype arm_role_receivers: list[~$(python-base-namespace).v2022_06_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] + """ + + _validation = { + 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, + } + + _attribute_map = { + 'alert_type': {'key': 'alertType', 'type': 'str'}, + 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, + 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, + 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, + 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, + 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, + 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, + 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, + 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, + 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, + 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, + 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, + } + + def __init__( + self, + *, + alert_type: str, + email_receivers: Optional[List["_models.EmailReceiver"]] = None, + sms_receivers: Optional[List["_models.SmsReceiver"]] = None, + webhook_receivers: Optional[List["_models.WebhookReceiver"]] = None, + itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, + azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, + automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, + voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, + logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, + 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 + ): + """ + :keyword alert_type: Required. The name of the supported alert type. + :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] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2022_06_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2022_06_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2022_06_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2022_06_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2022_06_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2022_06_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2022_06_01.models.EventHubReceiver] + """ + super(NotificationRequestBody, self).__init__(**kwargs) + self.alert_type = alert_type + self.email_receivers = email_receivers + self.sms_receivers = sms_receivers + self.webhook_receivers = webhook_receivers + self.itsm_receivers = itsm_receivers + self.azure_app_push_receivers = azure_app_push_receivers + self.automation_runbook_receivers = automation_runbook_receivers + self.voice_receivers = voice_receivers + self.logic_app_receivers = logic_app_receivers + self.azure_function_receivers = azure_function_receivers + self.arm_role_receivers = arm_role_receivers + self.event_hub_receivers = event_hub_receivers + + +class SmsReceiver(msrest.serialization.Model): + """An SMS receiver. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str + :ivar status: The status of the receiver. Known values are: "NotSpecified", "Enabled", + "Disabled". + :vartype status: str or ~$(python-base-namespace).v2022_06_01.models.ReceiverStatus + """ + + _validation = { + 'name': {'required': True}, + 'country_code': {'required': True}, + 'phone_number': {'required': True}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + country_code: str, + phone_number: str, + **kwargs + ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ + super(SmsReceiver, self).__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + self.status = None + + +class TestNotificationDetailsResponse(msrest.serialization.Model): + """The details of the test notification results. + + All required parameters must be populated in order to send to Azure. + + :ivar context: The context info. + :vartype context: ~$(python-base-namespace).v2022_06_01.models.Context + :ivar state: Required. The overall state. + :vartype state: str + :ivar completed_time: The completed time. + :vartype completed_time: str + :ivar created_time: The created time. + :vartype created_time: str + :ivar action_details: The list of action detail. + :vartype action_details: list[~$(python-base-namespace).v2022_06_01.models.ActionDetail] + """ + + _validation = { + 'state': {'required': True}, + } + + _attribute_map = { + 'context': {'key': 'context', 'type': 'Context'}, + 'state': {'key': 'state', 'type': 'str'}, + 'completed_time': {'key': 'completedTime', 'type': 'str'}, + 'created_time': {'key': 'createdTime', 'type': 'str'}, + 'action_details': {'key': 'actionDetails', 'type': '[ActionDetail]'}, + } + + def __init__( + self, + *, + state: str, + context: Optional["_models.Context"] = None, + completed_time: Optional[str] = None, + created_time: Optional[str] = None, + action_details: Optional[List["_models.ActionDetail"]] = None, + **kwargs + ): + """ + :keyword context: The context info. + :paramtype context: ~$(python-base-namespace).v2022_06_01.models.Context + :keyword state: Required. The overall state. + :paramtype state: str + :keyword completed_time: The completed time. + :paramtype completed_time: str + :keyword created_time: The created time. + :paramtype created_time: str + :keyword action_details: The list of action detail. + :paramtype action_details: list[~$(python-base-namespace).v2022_06_01.models.ActionDetail] + """ + super(TestNotificationDetailsResponse, self).__init__(**kwargs) + self.context = context + self.state = state + self.completed_time = completed_time + self.created_time = created_time + self.action_details = action_details + + +class VoiceReceiver(msrest.serialization.Model): + """A voice receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str + """ + + _validation = { + 'name': {'required': True}, + 'country_code': {'required': True}, + 'phone_number': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'country_code': {'key': 'countryCode', 'type': 'str'}, + 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + country_code: str, + phone_number: str, + **kwargs + ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ + super(VoiceReceiver, self).__init__(**kwargs) + self.name = name + self.country_code = country_code + self.phone_number = phone_number + + +class WebhookReceiver(msrest.serialization.Model): + """A webhook receiver. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str + """ + + _validation = { + 'name': {'required': True}, + 'service_uri': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'service_uri': {'key': 'serviceUri', 'type': 'str'}, + 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, + 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, + 'object_id': {'key': 'objectId', 'type': 'str'}, + 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + service_uri: str, + use_common_alert_schema: Optional[bool] = False, + use_aad_auth: Optional[bool] = False, + object_id: Optional[str] = None, + identifier_uri: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ + super(WebhookReceiver, self).__init__(**kwargs) + self.name = name + self.service_uri = service_uri + self.use_common_alert_schema = use_common_alert_schema + self.use_aad_auth = use_aad_auth + self.object_id = object_id + self.identifier_uri = identifier_uri + self.tenant_id = tenant_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py new file mode 100644 index 000000000000..2502d854d186 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_monitor_management_client_enums.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ReceiverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the status of the receiver. Receivers that are not Enabled will not receive any + communications. + """ + + NOT_SPECIFIED = "NotSpecified" + ENABLED = "Enabled" + DISABLED = "Disabled" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 new file mode 100644 index 000000000000..60f9d62f0ead --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py @@ -0,0 +1,18 @@ +# 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 ._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 patch_sdk as _patch_sdk +__all__ = [ + 'ActionGroupsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/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 new file mode 100644 index 000000000000..3a6787b26316 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py @@ -0,0 +1,1684 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: Optional[_models.ActionGroupResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + *, + json: Optional[_models.ActionGroupPatchBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_post_test_notifications_request_initial( + subscription_id: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_notifications_at_resource_group_level_request_initial( + subscription_id: str, + resource_group_name: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications") # 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + *, + json: Optional[_models.NotificationRequestBody] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_test_notifications_request( + subscription_id: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_test_notifications_at_resource_group_level_request( + subscription_id: str, + resource_group_name: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}") # 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), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_test_notifications_at_action_group_resource_level_request( + subscription_id: str, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_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 + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}") # 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), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "notificationId": _SERIALIZER.url("notification_id", notification_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_enable_receiver_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: Optional[_models.EnableRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class ActionGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_06_01.MonitorManagementClient`'s + :attr:`action_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + action_group_name: str, + action_group: _models.ActionGroupResource, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Create a new action group or update an existing one. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group: The action group to create or use for the update. + :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Get an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> None: + """Delete an action group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + action_group_name: str, + action_group_patch: _models.ActionGroupPatchBody, + **kwargs: Any + ) -> _models.ActionGroupResource: + """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param action_group_patch: Parameters supplied to the operation. + :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ActionGroupResource, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupResource] + + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ActionGroupResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + + + def _post_test_notifications_initial( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _post_test_notifications_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace + def begin_post_test_notifications( + self, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._post_test_notifications_initial( # type: ignore + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_post_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + def _create_notifications_at_resource_group_level_initial( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_resource_group_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_resource_group_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_resource_group_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + + @distributed_trace + def begin_create_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + resource_group_name=resource_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + + def _create_notifications_at_action_group_resource_level_initial( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> Optional[_models.TestNotificationDetailsResponse]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') + + request = build_create_notifications_at_action_group_resource_level_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_notifications_at_action_group_resource_level_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if response.status_code == 202: + response_headers['location']=self._deserialize('str', response.headers.get('location')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_notifications_at_action_group_resource_level_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + + @distributed_trace + def begin_create_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_request: _models.NotificationRequestBody, + **kwargs: Any + ) -> LROPoller[_models.TestNotificationDetailsResponse]: + """Send test notifications to a set of provided receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_request: The notification request body which includes the contact details. + :type notification_request: + ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationDetailsResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_request=notification_request, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_notifications_at_action_group_resource_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + + @distributed_trace + def get_test_notifications( + self, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def get_test_notifications_at_resource_group_level( + self, + resource_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_resource_group_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_test_notifications_at_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + + + @distributed_trace + def get_test_notifications_at_action_group_resource_level( + self, + resource_group_name: str, + action_group_name: str, + notification_id: str, + **kwargs: Any + ) -> _models.TestNotificationDetailsResponse: + """Get the test notifications by the notification id. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param notification_id: The notification id. + :type notification_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TestNotificationDetailsResponse, or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_06_01.models.TestNotificationDetailsResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TestNotificationDetailsResponse] + + + request = build_get_test_notifications_at_action_group_resource_level_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_name, + notification_id=notification_id, + api_version=api_version, + template_url=self.get_test_notifications_at_action_group_resource_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + 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 + + + @distributed_trace + def list_by_subscription_id( + self, + **kwargs: Any + ) -> Iterable[_models.ActionGroupList]: + """Get a list of all action groups 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 ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription_id.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.ActionGroupList]: + """Get a list of all action groups in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ActionGroupList or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_06_01.models.ActionGroupList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ActionGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ActionGroupList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + + @distributed_trace + def enable_receiver( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + action_group_name: str, + enable_request: _models.EnableRequest, + **kwargs: Any + ) -> None: + """Enable a receiver in an action group. This changes the receiver's status from Disabled to + Enabled. This operation is only supported for Email or SMS receivers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param action_group_name: The name of the action group. + :type action_group_name: str + :param enable_request: The receiver to re-enable. + :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + enable_receiver.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file