diff --git a/src/datadog/azext_datadog/azext_metadata.json b/src/datadog/azext_datadog/azext_metadata.json index 14d2c1ae419..cfc30c747c7 100644 --- a/src/datadog/azext_datadog/azext_metadata.json +++ b/src/datadog/azext_datadog/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isExperimental": true, - "azext.minCliCoreVersion": "2.17.0" + "azext.minCliCoreVersion": "2.15.0" } \ No newline at end of file diff --git a/src/datadog/azext_datadog/generated/_help.py b/src/datadog/azext_datadog/generated/_help.py index f5eded6281a..1ac9685ba17 100644 --- a/src/datadog/azext_datadog/generated/_help.py +++ b/src/datadog/azext_datadog/generated/_help.py @@ -14,14 +14,14 @@ helps['datadog terms'] = """ type: group - short-summary: Manage marketplace agreements with datadog + short-summary: Manage marketplace agreement with datadog """ helps['datadog terms list'] = """ type: command - short-summary: "List datadog marketplace agreements" + short-summary: "List Datadog marketplace agreements in the subscription." examples: - - name: List marketplace agreements + - name: MarketplaceAgreements_List text: |- az datadog terms list """ @@ -126,14 +126,11 @@ examples: - name: Monitors_Create text: |- - az datadog monitor create --name "myMonitor" --resource-group "myResourceGroup" --location "West US 2" \ ---tags Environment="Dev" --user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" \ ---type "SystemAssigned" --sku-name "payg_v2_Monthly" - - name: Monitors creation with linking to Datadogo organization. - text: |- - az datadog monitor create --name "myMonitor" --resource-group "myResourceGroup" --location "West US 2" \ ---datadog-organization-properties api-key=XX application-key=XX --tags Environment="Dev" --user-info name="Alice" \ -email-address="alice@microsoft.com" phone-number="123-456-7890" --type "SystemAssigned" --sku-name "Linked" + az datadog monitor create --monitor-name "myMonitor" --name "myMonitor" --location "West US" \ +--datadog-organization-properties name="myOrg" enterprise-app-id="00000000-0000-0000-0000-000000000000" \ +linking-auth-code="someAuthCode" linking-client-id="00000000-0000-0000-0000-000000000000" subscription="pro" \ +--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" --name "free_Monthly" --tags \ +Environment="Dev" --resource-group "myResourceGroup" """ helps['datadog monitor update'] = """ @@ -142,7 +139,7 @@ examples: - name: Monitors_Update text: |- - az datadog monitor update --name "myMonitor" --tags Environment="Dev" --resource-group \ + az datadog monitor update --monitor-name "myMonitor" --tags Environment="Dev" --resource-group \ "myResourceGroup" """ @@ -226,6 +223,9 @@ - name: Pause executing next line of CLI script until the datadog monitor is successfully created. text: |- az datadog monitor wait --name "myMonitor" --resource-group "myResourceGroup" --created + - name: Pause executing next line of CLI script until the datadog monitor is successfully updated. + text: |- + az datadog monitor wait --name "myMonitor" --resource-group "myResourceGroup" --updated - name: Pause executing next line of CLI script until the datadog monitor is successfully deleted. text: |- az datadog monitor wait --name "myMonitor" --resource-group "myResourceGroup" --deleted @@ -354,7 +354,7 @@ parameters: - name: --properties long-summary: | - Usage: --properties provisioning-state=XX single-sign-on-state=XX enterprise-app-id=XX + Usage: --properties single-sign-on-state=XX enterprise-app-id=XX single-sign-on-state: Various states of the SSO resource enterprise-app-id: The Id of the Enterprise App used for Single sign-on. @@ -372,7 +372,7 @@ parameters: - name: --properties long-summary: | - Usage: --properties provisioning-state=XX single-sign-on-state=XX enterprise-app-id=XX + Usage: --properties single-sign-on-state=XX enterprise-app-id=XX single-sign-on-state: Various states of the SSO resource enterprise-app-id: The Id of the Enterprise App used for Single sign-on. diff --git a/src/datadog/azext_datadog/generated/_params.py b/src/datadog/azext_datadog/generated/_params.py index 88de549148a..d0acc0dc2e8 100644 --- a/src/datadog/azext_datadog/generated/_params.py +++ b/src/datadog/azext_datadog/generated/_params.py @@ -48,8 +48,7 @@ def load_arguments(self, _): with self.argument_context('datadog monitor create') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' - 'name') + c.argument('monitor_name', type=str, help='Monitor resource name') c.argument('tags', tags_type) c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False, validator=get_default_location_from_resource_group) @@ -58,13 +57,13 @@ def load_arguments(self, _): c.argument('datadog_organization_properties', action=AddDatadogOrganizationProperties, nargs='+', help='Datadog organization properties') c.argument('user_info', action=AddUserInfo, nargs='+', help='User info') - c.argument('sku_name', type=str, help='Name of the SKU.', arg_group='Sku') + c.argument('name', type=str, help='Name of the SKU.', arg_group='Sku') with self.argument_context('datadog monitor update') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('monitor_name', options_list=['--name', '-n', '--monitor-name'], type=str, help='Monitor resource ' - 'name', id_part='name') + c.argument('monitor_name', type=str, help='Monitor resource name', id_part='name') c.argument('tags', tags_type) + c.argument('name', type=str, help='Name of the SKU.', arg_group='Sku') with self.argument_context('datadog monitor delete') as c: c.argument('resource_group_name', resource_group_name_type) diff --git a/src/datadog/azext_datadog/generated/commands.py b/src/datadog/azext_datadog/generated/commands.py index 4d908a36b1f..548d41a5fda 100644 --- a/src/datadog/azext_datadog/generated/commands.py +++ b/src/datadog/azext_datadog/generated/commands.py @@ -21,7 +21,7 @@ def load_command_table(self, _): 'greementsOperations.{}', client_factory=cf_marketplace_agreement) with self.command_group('datadog terms', datadog_marketplace_agreement, - client_factory=cf_marketplace_agreement, is_experimental=True) as g: + client_factory=cf_marketplace_agreement) as g: g.custom_command('list', 'datadog_terms_list') g.custom_command('create', 'datadog_terms_create') g.custom_command('update', 'datadog_terms_update') @@ -34,7 +34,7 @@ def load_command_table(self, _): g.custom_command('list', 'datadog_monitor_list') g.custom_show_command('show', 'datadog_monitor_show') g.custom_command('create', 'datadog_monitor_create', supports_no_wait=True) - g.custom_command('update', 'datadog_monitor_update') + g.custom_command('update', 'datadog_monitor_update', supports_no_wait=True) g.custom_command('delete', 'datadog_monitor_delete', supports_no_wait=True, confirmation=True) g.custom_command('get-default-key', 'datadog_monitor_get_default_key') g.custom_command('list-api-key', 'datadog_monitor_list_api_key') diff --git a/src/datadog/azext_datadog/generated/custom.py b/src/datadog/azext_datadog/generated/custom.py index 56858a63ac2..af3a40e3d6f 100644 --- a/src/datadog/azext_datadog/generated/custom.py +++ b/src/datadog/azext_datadog/generated/custom.py @@ -10,7 +10,6 @@ # pylint: disable=too-many-lines # pylint: disable=unused-argument -from azure.cli.command_modules.role.custom import create_role_assignment, list_role_assignments, delete_role_assignments from azure.cli.core.util import sdk_no_wait @@ -18,13 +17,6 @@ def datadog_terms_list(client): return client.list() -def datadog_marketplace_agreement_create(client, - properties=None): - body = {} - body['properties'] = properties - return client.create_or_update(body=body) - - def datadog_terms_create(client, properties=None): body = {} @@ -53,8 +45,7 @@ def datadog_monitor_show(client, monitor_name=monitor_name) -def datadog_monitor_create(cmd, - client, +def datadog_monitor_create(client, resource_group_name, monitor_name, tags=None, @@ -62,7 +53,7 @@ def datadog_monitor_create(cmd, type_=None, datadog_organization_properties=None, user_info=None, - sku_name=None, + name=None, no_wait=False): body = {} body['tags'] = tags @@ -74,54 +65,41 @@ def datadog_monitor_create(cmd, body['properties']['datadog_organization_properties'] = datadog_organization_properties body['properties']['user_info'] = user_info body['sku'] = {} - body['sku']['name'] = sku_name - poller = sdk_no_wait(no_wait, - client.begin_create, - resource_group_name=resource_group_name, - monitor_name=monitor_name, - body=body) - result = poller.result() - if result and result.identity and result.identity.principal_id: - scrope = '/subscriptions/' + result.id.split('/')[2] - create_role_assignment(cmd, role='43d0d8ad-25c7-4714-9337-8ba259a9fe05', - assignee_object_id=result.identity.principal_id, - scope=scrope, assignee_principal_type='ServicePrincipal') - return poller + body['sku']['name'] = name + return sdk_no_wait(no_wait, + client.begin_create, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body) def datadog_monitor_update(client, resource_group_name, monitor_name, - tags=None): + tags=None, + name=None, + no_wait=False): body = {} body['tags'] = tags + body['sku'] = {} + body['sku']['name'] = name body['properties'] = {} body['properties']['monitoring_status'] = "Enabled" - return client.update(resource_group_name=resource_group_name, - monitor_name=monitor_name, - body=body) + return sdk_no_wait(no_wait, + client.begin_update, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body) -def datadog_monitor_delete(cmd, - client, +def datadog_monitor_delete(client, resource_group_name, monitor_name, no_wait=False): - monitor = client.get(resource_group_name=resource_group_name, - monitor_name=monitor_name) - poller = sdk_no_wait(no_wait, - client.begin_delete, - resource_group_name=resource_group_name, - monitor_name=monitor_name) - result = poller.result() - if not result: - scrope = '/subscriptions/' + monitor.id.split('/')[2] - role_assignments = list_role_assignments(cmd, role='43d0d8ad-25c7-4714-9337-8ba259a9fe05', scope=scrope) - for i in role_assignments: - if i.get('principalId') == monitor.identity.principal_id: - delete_role_assignments(cmd, ids=[i.get('id')]) - break - return poller + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + monitor_name=monitor_name) def datadog_monitor_get_default_key(client, diff --git a/src/datadog/azext_datadog/tests/latest/example_steps.py b/src/datadog/azext_datadog/tests/latest/example_steps.py new file mode 100644 index 00000000000..194dd22cf0f --- /dev/null +++ b/src/datadog/azext_datadog/tests/latest/example_steps.py @@ -0,0 +1,263 @@ +# -------------------------------------------------------------------------- +# 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 .. import try_manual + + +# EXAMPLE: /MarketplaceAgreements/put/MarketplaceAgreements_CreateOrUpdate +@try_manual +def step_terms_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog terms create ' + '--properties accepted=true', + checks=checks) + + +# EXAMPLE: /MarketplaceAgreements/get/MarketplaceAgreements_List +@try_manual +def step_terms_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog terms list', + checks=checks) + + +# EXAMPLE: /Monitors/put/Monitors_Create +@try_manual +def step_monitor_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor create ' + '--monitor-name "{myMonitor}" ' + '--name "{myMonitor}" ' + '--location "West US" ' + '--datadog-organization-properties name="myOrg" enterprise-app-id="00000000-0000-0000-0000-000000000000" ' + 'linking-auth-code="someAuthCode" linking-client-id="00000000-0000-0000-0000-000000000000" ' + 'subscription="pro" ' + '--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" ' + '--name "free_Monthly" ' + '--tags Environment="Dev" ' + '--resource-group "{rg}"', + checks=[]) + test.cmd('az datadog monitor wait --created ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/get/Monitors_Get +@try_manual +def step_monitor_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor show ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/get/Monitors_List +@try_manual +def step_monitor_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list ' + '-g ""', + checks=checks) + + +# EXAMPLE: /Monitors/get/Monitors_ListByResourceGroup +@try_manual +def step_monitor_list2(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/patch/Monitors_Update +@try_manual +def step_monitor_update(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor update ' + '--monitor-name "{myMonitor}" ' + '--tags Environment="Dev" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_GetDefaultKey +@try_manual +def step_monitor_get_default_key(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor get-default-key ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_ListApiKeys +@try_manual +def step_monitor_list_api_key(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list-api-key ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_ListHosts +@try_manual +def step_monitor_list_host(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list-host ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_ListLinkedResources +@try_manual +def step_monitor_list_linked_resource(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list-linked-resource ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_ListMonitoredResources +@try_manual +def step_monitor_list_monitored_resource(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor list-monitored-resource ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_RefreshSetPasswordLink +@try_manual +def step_monitor_refresh_set_password_link(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor refresh-set-password-link ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/post/Monitors_SetDefaultKey +@try_manual +def step_monitor_set_default_key(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor set-default-key ' + '--monitor-name "{myMonitor}" ' + '--key "1111111111111111aaaaaaaaaaaaaaaa" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /SingleSignOnConfigurations/put/SingleSignOnConfigurations_CreateOrUpdate +@try_manual +def step_sso_config_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog sso-config create ' + '--configuration-name "default" ' + '--monitor-name "{myMonitor}" ' + '--properties enterprise-app-id="00000000-0000-0000-0000-000000000000" single-sign-on-state="Enable" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_Get +@try_manual +def step_sso_config_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog sso-config show ' + '--configuration-name "default" ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_List +@try_manual +def step_sso_config_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog sso-config list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /TagRules/put/TagRules_CreateOrUpdate +@try_manual +def step_tag_rule_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog tag-rule create ' + '--monitor-name "{myMonitor}" ' + '--log-rules-filtering-tags name="Environment" action="Include" value="Prod" ' + '--log-rules-filtering-tags name="Environment" action="Exclude" value="Dev" ' + '--send-aad-logs false ' + '--send-resource-logs true ' + '--send-subscription-logs true ' + '--resource-group "{rg}" ' + '--rule-set-name "default"', + checks=checks) + + +# EXAMPLE: /TagRules/get/TagRules_Get +@try_manual +def step_tag_rule_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog tag-rule show ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}" ' + '--rule-set-name "default"', + checks=checks) + + +# EXAMPLE: /TagRules/get/TagRules_List +@try_manual +def step_tag_rule_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog tag-rule list ' + '--monitor-name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Monitors/delete/Monitors_Delete +@try_manual +def step_monitor_delete(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az datadog monitor delete -y ' + '--name "{myMonitor}" ' + '--resource-group "{rg}"', + checks=checks) + diff --git a/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py b/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py index 8cde69dbc38..29c2835b813 100644 --- a/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py +++ b/src/datadog/azext_datadog/tests/latest/test_datadog_scenario.py @@ -9,341 +9,111 @@ # -------------------------------------------------------------------------- import os -import mock from azure.cli.testsdk import ScenarioTest -from .. import try_manual, raise_if, calc_coverage from azure.cli.testsdk import ResourceGroupPreparer -from azure_devtools.scenario_tests import AllowLargeResponse +from .example_steps import step_terms_create +from .example_steps import step_terms_list +from .example_steps import step_monitor_create +from .example_steps import step_monitor_show +from .example_steps import step_monitor_list +from .example_steps import step_monitor_list2 +from .example_steps import step_monitor_update +from .example_steps import step_monitor_get_default_key +from .example_steps import step_monitor_list_api_key +from .example_steps import step_monitor_list_host +from .example_steps import step_monitor_list_linked_resource +from .example_steps import step_monitor_list_monitored_resource +from .example_steps import step_monitor_refresh_set_password_link +from .example_steps import step_monitor_set_default_key +from .example_steps import step_sso_config_create +from .example_steps import step_sso_config_show +from .example_steps import step_sso_config_list +from .example_steps import step_tag_rule_create +from .example_steps import step_tag_rule_show +from .example_steps import step_tag_rule_list +from .example_steps import step_monitor_delete +from .. import ( + try_manual, + raise_if, + calc_coverage +) TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) +# Env setup_scenario @try_manual -def setup(test, rg): +def setup_scenario(test, rg): pass -# EXAMPLE: /Monitors/put/Monitors_Create +# Env cleanup_scenario @try_manual -def step__monitors_put_monitors_create(test, rg): - with mock.patch('azure.cli.command_modules.role.custom._gen_guid', side_effect=test.create_guid): - test.cmd('az datadog monitor create ' - '--name "{myMonitor}" ' - '--sku-name "drawdown_testing_20200904_Monthly" ' - '--location "East US 2 EUAP" ' - '--type "SystemAssigned" ' - '--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" ' - '--tags Environment="Dev" ' - '--resource-group "{rg}"', - checks=[ - test.check("name", "{myMonitor}", case_sensitive=False), - test.check("sku.name", "drawdown_testing_20200904_Monthly", case_sensitive=False), - test.check("location", "eastus2euap", case_sensitive=False), - test.check("properties.marketplaceSubscriptionStatus", "Active", case_sensitive=False), - test.check("properties.monitoringStatus", "Enabled", case_sensitive=False), - test.check("properties.provisioningState", "Succeeded", case_sensitive=False), - test.check("tags.Environment", "Dev", case_sensitive=False), - ]) - test.cmd('az datadog monitor wait --created ' - '--name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[]) - - -# EXAMPLE: /Monitors/get/Monitors_Get -@try_manual -def step__monitors_get_monitors_get(test, rg): - test.cmd('az datadog monitor show ' - '--name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check("name", "{myMonitor}", case_sensitive=False), - test.check("sku.name", "drawdown_testing_20200904_Monthly", case_sensitive=False), - test.check("location", "eastus2euap", case_sensitive=False), - test.check("properties.marketplaceSubscriptionStatus", "Active", case_sensitive=False), - test.check("properties.monitoringStatus", "Enabled", case_sensitive=False), - test.check("properties.provisioningState", "Succeeded", case_sensitive=False), - test.check("tags.Environment", "Dev", case_sensitive=False), - ]) - - -# EXAMPLE: /Monitors/get/Monitors_List -@try_manual -def step__monitors_get_monitors_list(test, rg): - test.cmd('az datadog monitor list ' - '-g ""', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /Monitors/get/Monitors_ListByResourceGroup -@try_manual -def step__monitors_get_monitors_listbyresourcegroup(test, rg): - test.cmd('az datadog monitor list ' - '--resource-group "{rg}"', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /Monitors/patch/Monitors_Update -@try_manual -def step__monitors_patch_monitors_update(test, rg): - test.cmd('az datadog monitor update ' - '--name "{myMonitor}" ' - '--tags Environment="Dev2" ' - '--resource-group "{rg}"', - checks=[ - test.check("name", "{myMonitor}", case_sensitive=False), - test.check("sku.name", "drawdown_testing_20200904_Monthly", case_sensitive=False), - test.check("location", "eastus2euap", case_sensitive=False), - test.check("properties.marketplaceSubscriptionStatus", "Active", case_sensitive=False), - test.check("properties.monitoringStatus", "Enabled", case_sensitive=False), - test.check("properties.provisioningState", "Succeeded", case_sensitive=False), - test.check("tags.Environment", "Dev2", case_sensitive=False), - ]) - - -# EXAMPLE: /ApiKeys/post/ApiKeys_GetDefaultKey -@try_manual -def step__apikeys_post_apikeys_getdefaultkey(test, rg): - test.cmd('az datadog monitor get-default-key ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check("key", "1111111111111111aaaaaaaaaaaaaaaa", case_sensitive=False), - ]) - - -# EXAMPLE: /ApiKeys/post/ApiKeys_List -@try_manual -def step__apikeys_post_apikeys_list(test, rg): - test.cmd('az datadog monitor list-api-key ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /ApiKeys/post/ApiKeys_SetDefaultKey -@try_manual -def step__apikeys_post_apikeys_setdefaultkey(test, rg): - test.cmd('az datadog monitor set-default-key ' - '--monitor-name "{myMonitor}" ' - '--key "1111111111111111aaaaaaaaaaaaaaaa" ' - '--resource-group "{rg}"', - checks=[]) - - -# EXAMPLE: /Hosts/post/Hosts_List -@try_manual -def step__hosts_post_hosts_list(test, rg): - test.cmd('az datadog monitor list-host ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[]) - - -# EXAMPLE: /LinkedResources/post/LinkedResources_List -@try_manual -def step__linkedresources_post_linkedresources_list(test, rg): - test.cmd('az datadog monitor list-linked-resource ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /MonitoredResources/post/MonitoredResources_List -@try_manual -def step__monitoredresources_post(test, rg): - test.cmd('az datadog monitor list-monitored-resource ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[]) - - -# EXAMPLE: /RefreshSetPassword/post/RefreshSetPassword_Get -@try_manual -def step__refreshsetpassword_post(test, rg): - test.cmd('az datadog monitor refresh-set-password-link ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check("setPasswordLink", None), - ]) - - -# EXAMPLE: /SingleSignOnConfigurations/put/SingleSignOnConfigurations_CreateOrUpdate -@try_manual -def step__singlesignonconfigurations_put(test, rg): - test.cmd('az datadog sso-config create ' - '--configuration-name "default" ' - '--monitor-name "{myMonitor}" ' - '--properties enterprise-app-id="ac754169-3489-42ae-bd06-8be89db12e58" single-sign-on-state="Enable" ' - '--resource-group "{rg}"', - checks=[]) - - -# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_Get -@try_manual -def step__singlesignonconfigurations_get(test, rg): - test.cmd('az datadog sso-config show ' - '--configuration-name "default" ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check("name", "default", case_sensitive=False), - test.check("type", "Microsoft.Datadog/monitors/singleSignOnConfigurations", case_sensitive=False), - ]) - - -# EXAMPLE: /SingleSignOnConfigurations/get/SingleSignOnConfigurations_List -@try_manual -def step__singlesignonconfigurations_get2(test, rg): - test.cmd('az datadog sso-config list ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /TagRules/put/TagRules_CreateOrUpdate -@try_manual -def step__tagrules_put_tagrules_createorupdate(test, rg): - test.cmd('az datadog tag-rule create ' - '--monitor-name "{myMonitor}" ' - '--log-rules-filtering-tags name="Environment" action="Include" value="Prod" ' - '--log-rules-filtering-tags name="Environment" action="Exclude" value="Dev" ' - '--send-aad-logs false ' - '--send-resource-logs true ' - '--send-subscription-logs true ' - '--resource-group "{rg}" ' - '--rule-set-name "default"', - checks=[ - test.check("name", "default", case_sensitive=False), - test.check("type", "Microsoft.Datadog/monitors/tagRules", case_sensitive=False), - ]) - - -# EXAMPLE: /TagRules/get/TagRules_Get -@try_manual -def step__tagrules_get_tagrules_get(test, rg): - test.cmd('az datadog tag-rule show ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}" ' - '--rule-set-name "default"', - checks=[ - test.check("name", "default", case_sensitive=False), - test.check("type", "Microsoft.Datadog/monitors/tagRules", case_sensitive=False), - ]) - - -# EXAMPLE: /TagRules/get/TagRules_List -@try_manual -def step__tagrules_get_tagrules_list(test, rg): - test.cmd('az datadog tag-rule list ' - '--monitor-name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[ - test.check('length(@)', 1), - ]) - - -# EXAMPLE: /Monitors/delete/Monitors_Delete -@try_manual -def step__monitors_delete_monitors_delete(test, rg): - test.cmd('az datadog monitor delete -y ' - '--name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[]) - - -@try_manual -def step__terms_list(test, rg): - test.cmd('az datadog terms list', - checks=[ - test.check('length(@)', 2) - ]) - - -@try_manual -def step__monitors_put_monitors_create_link(test, rg): - with mock.patch('azure.cli.command_modules.role.custom._gen_guid', side_effect=test.create_guid): - test.cmd('az datadog monitor create ' - '--name "{myMonitor}" ' - '--sku-name "Linked" ' - '--datadog-organization-properties ' - 'api-key=XX ' - 'application-key=XX ' - '--location "East US 2 EUAP" ' - '--type "SystemAssigned" ' - '--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" ' - '--tags Environment="Dev" ' - '--resource-group "{rg}"', - checks=[ - test.check("name", "{myMonitor}", case_sensitive=False), - test.check("sku.name", "Linked", case_sensitive=False), - test.check("location", "eastus2euap", case_sensitive=False), - test.check("properties.marketplaceSubscriptionStatus", "Active", case_sensitive=False), - test.check("properties.monitoringStatus", "Enabled", case_sensitive=False), - test.check("properties.provisioningState", "Succeeded", case_sensitive=False), - test.check("tags.Environment", "Dev", case_sensitive=False), - ]) - test.cmd('az datadog monitor wait --created ' - '--name "{myMonitor}" ' - '--resource-group "{rg}"', - checks=[]) - - -@try_manual -def cleanup(test, rg): +def cleanup_scenario(test, rg): pass +# Testcase: Scenario @try_manual def call_scenario(test, rg): - setup(test, rg) - step__monitors_put_monitors_create(test, rg) - step__monitors_get_monitors_get(test, rg) - step__monitors_get_monitors_list(test, rg) - step__monitors_get_monitors_listbyresourcegroup(test, rg) - step__monitors_patch_monitors_update(test, rg) - step__hosts_post_hosts_list(test, rg) - step__linkedresources_post_linkedresources_list(test, rg) - step__monitoredresources_post(test, rg) - step__refreshsetpassword_post(test, rg) - step__singlesignonconfigurations_put(test, rg) - step__singlesignonconfigurations_get(test, rg) - step__singlesignonconfigurations_get2(test, rg) - step__tagrules_put_tagrules_createorupdate(test, rg) - step__tagrules_get_tagrules_get(test, rg) - step__tagrules_get_tagrules_list(test, rg) - step__apikeys_post_apikeys_list(test, rg) - step__apikeys_post_apikeys_setdefaultkey(test, rg) - step__apikeys_post_apikeys_getdefaultkey(test, rg) - step__monitors_delete_monitors_delete(test, rg) - step__terms_list(test, rg) - step__monitors_put_monitors_create_link(test, rg) - cleanup(test, rg) - - -@try_manual -class MicrosoftDatadogClientScenarioTest(ScenarioTest): - - @AllowLargeResponse() - @ResourceGroupPreparer(name_prefix='clitestdatadog_myResourceGroup'[:7], key='rg', parameter_name='rg') - def test_datadog(self, rg): - + setup_scenario(test, rg) + step_terms_create(test, rg, checks=[]) + step_terms_list(test, rg, checks=[]) + step_monitor_create(test, rg, checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("sku.name", "free_Monthly", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + step_monitor_show(test, rg, checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + step_monitor_list(test, rg, checks=[ + test.check('length(@)', 1), + ]) + step_monitor_list2(test, rg, checks=[ + test.check('length(@)', 1), + ]) + step_monitor_update(test, rg, checks=[ + test.check("name", "{myMonitor}", case_sensitive=False), + test.check("sku.name", "free_Monthly", case_sensitive=False), + test.check("location", "West US", case_sensitive=False), + test.check("tags.Environment", "Dev", case_sensitive=False), + ]) + step_monitor_get_default_key(test, rg, checks=[]) + step_monitor_list_api_key(test, rg, checks=[]) + step_monitor_list_host(test, rg, checks=[]) + step_monitor_list_linked_resource(test, rg, checks=[]) + step_monitor_list_monitored_resource(test, rg, checks=[]) + step_monitor_refresh_set_password_link(test, rg, checks=[]) + step_monitor_set_default_key(test, rg, checks=[]) + step_sso_config_create(test, rg, checks=[]) + step_sso_config_show(test, rg, checks=[]) + step_sso_config_list(test, rg, checks=[]) + step_tag_rule_create(test, rg, checks=[]) + step_tag_rule_show(test, rg, checks=[]) + step_tag_rule_list(test, rg, checks=[]) + step_monitor_delete(test, rg, checks=[]) + cleanup_scenario(test, rg) + + +# Test class for Scenario +@try_manual +class DatadogScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(DatadogScenarioTest, self).__init__(*args, **kwargs) self.kwargs.update({ 'myMonitor': 'myMonitor', }) + + @ResourceGroupPreparer(name_prefix='clitestdatadog_myResourceGroup'[:7], key='rg', parameter_name='rg') + def test_datadog_Scenario(self, rg): call_scenario(self, rg) calc_coverage(__file__) raise_if() + diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations/_monitors_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations/_monitors_operations.py index c485d529446..37d8af8b680 100644 --- a/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations/_monitors_operations.py +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/aio/operations/_monitors_operations.py @@ -818,28 +818,13 @@ def get_long_running_output(pipeline_response): return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore - async def update( + async def _update_initial( self, resource_group_name: str, monitor_name: str, body: Optional["models.DatadogMonitorResourceUpdateParameters"] = None, **kwargs ) -> "models.DatadogMonitorResource": - """Update a monitor resource. - - Update a monitor resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param monitor_name: Monitor resource name. - :type monitor_name: str - :param body: - :type body: ~microsoft_datadog_client.models.DatadogMonitorResourceUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatadogMonitorResource, or the result of cls(response) - :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -850,7 +835,7 @@ async def update( accept = "application/json" # Construct URL - url = self.update.metadata['url'] # type: ignore + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), @@ -877,18 +862,95 @@ async def update( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + monitor_name: str, + body: Optional["models.DatadogMonitorResourceUpdateParameters"] = None, + **kwargs + ) -> AsyncLROPoller["models.DatadogMonitorResource"]: + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_datadog_client.models.DatadogMonitorResourceUpdateParameters + :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: True for ARMPolling, False for no polling, or a + polling object for 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 DatadogMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_datadog_client.models.DatadogMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore async def _delete_initial( self, diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py index 77500389ed8..f533a74176b 100644 --- a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models.py @@ -406,11 +406,14 @@ class DatadogMonitorResourceUpdateParameters(msrest.serialization.Model): :type properties: ~microsoft_datadog_client.models.MonitorUpdateProperties :param tags: A set of tags. The new tags of the monitor resource. :type tags: dict[str, str] + :param sku: + :type sku: ~microsoft_datadog_client.models.ResourceSku """ _attribute_map = { 'properties': {'key': 'properties', 'type': 'MonitorUpdateProperties'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'ResourceSku'}, } def __init__( @@ -420,6 +423,7 @@ def __init__( super(DatadogMonitorResourceUpdateParameters, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) self.tags = kwargs.get('tags', None) + self.sku = kwargs.get('sku', None) class DatadogOrganizationProperties(msrest.serialization.Model): @@ -989,6 +993,8 @@ def __init__( class MonitoringTagRulesProperties(msrest.serialization.Model): """Definition of the properties for a TagRules resource. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py index 403aace93cf..ee88c8f4fa6 100644 --- a/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/models/_models_py3.py @@ -460,11 +460,14 @@ class DatadogMonitorResourceUpdateParameters(msrest.serialization.Model): :type properties: ~microsoft_datadog_client.models.MonitorUpdateProperties :param tags: A set of tags. The new tags of the monitor resource. :type tags: dict[str, str] + :param sku: + :type sku: ~microsoft_datadog_client.models.ResourceSku """ _attribute_map = { 'properties': {'key': 'properties', 'type': 'MonitorUpdateProperties'}, 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'ResourceSku'}, } def __init__( @@ -472,11 +475,13 @@ def __init__( *, properties: Optional["MonitorUpdateProperties"] = None, tags: Optional[Dict[str, str]] = None, + sku: Optional["ResourceSku"] = None, **kwargs ): super(DatadogMonitorResourceUpdateParameters, self).__init__(**kwargs) self.properties = properties self.tags = tags + self.sku = sku class DatadogOrganizationProperties(msrest.serialization.Model): @@ -1097,6 +1102,8 @@ def __init__( class MonitoringTagRulesProperties(msrest.serialization.Model): """Definition of the properties for a TagRules resource. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar provisioning_state: Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_datadog_client.models.ProvisioningState diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitors_operations.py b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitors_operations.py index 248c7a30a26..0606c2e954c 100644 --- a/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitors_operations.py +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/operations/_monitors_operations.py @@ -833,7 +833,7 @@ def get_long_running_output(pipeline_response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore - def update( + def _update_initial( self, resource_group_name, # type: str monitor_name, # type: str @@ -841,21 +841,6 @@ def update( **kwargs # type: Any ): # type: (...) -> "models.DatadogMonitorResource" - """Update a monitor resource. - - Update a monitor resource. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param monitor_name: Monitor resource name. - :type monitor_name: str - :param body: - :type body: ~microsoft_datadog_client.models.DatadogMonitorResourceUpdateParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatadogMonitorResource, or the result of cls(response) - :rtype: ~microsoft_datadog_client.models.DatadogMonitorResource - :raises: ~azure.core.exceptions.HttpResponseError - """ cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -866,7 +851,7 @@ def update( accept = "application/json" # Construct URL - url = self.update.metadata['url'] # type: ignore + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), @@ -893,18 +878,96 @@ def update( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize(models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + monitor_name, # type: str + body=None, # type: Optional["models.DatadogMonitorResourceUpdateParameters"] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.DatadogMonitorResource"] + """Update a monitor resource. + + Update a monitor resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param monitor_name: Monitor resource name. + :type monitor_name: str + :param body: + :type body: ~microsoft_datadog_client.models.DatadogMonitorResourceUpdateParameters + :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: True for ARMPolling, False for no polling, or a + polling object for 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 DatadogMonitorResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_datadog_client.models.DatadogMonitorResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.DatadogMonitorResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + monitor_name=monitor_name, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('DatadogMonitorResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = 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 + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}'} # type: ignore def _delete_initial( self, diff --git a/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed b/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/datadog/azext_datadog/vendored_sdks/datadog/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/datadog/report.md b/src/datadog/report.md new file mode 100644 index 00000000000..1fce7601cc6 --- /dev/null +++ b/src/datadog/report.md @@ -0,0 +1,370 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az datadog|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az datadog` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az datadog terms|MarketplaceAgreements|[commands](#CommandsInMarketplaceAgreements)| +|az datadog monitor|Monitors|[commands](#CommandsInMonitors)| +|az datadog tag-rule|TagRules|[commands](#CommandsInTagRules)| +|az datadog sso-config|SingleSignOnConfigurations|[commands](#CommandsInSingleSignOnConfigurations)| + +## COMMANDS +### Commands in `az datadog monitor` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az datadog monitor list](#MonitorsListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersMonitorsListByResourceGroup)|[Example](#ExamplesMonitorsListByResourceGroup)| +|[az datadog monitor list](#MonitorsList)|List|[Parameters](#ParametersMonitorsList)|[Example](#ExamplesMonitorsList)| +|[az datadog monitor show](#MonitorsGet)|Get|[Parameters](#ParametersMonitorsGet)|[Example](#ExamplesMonitorsGet)| +|[az datadog monitor create](#MonitorsCreate)|Create|[Parameters](#ParametersMonitorsCreate)|[Example](#ExamplesMonitorsCreate)| +|[az datadog monitor update](#MonitorsUpdate)|Update|[Parameters](#ParametersMonitorsUpdate)|[Example](#ExamplesMonitorsUpdate)| +|[az datadog monitor delete](#MonitorsDelete)|Delete|[Parameters](#ParametersMonitorsDelete)|[Example](#ExamplesMonitorsDelete)| +|[az datadog monitor get-default-key](#MonitorsGetDefaultKey)|GetDefaultKey|[Parameters](#ParametersMonitorsGetDefaultKey)|[Example](#ExamplesMonitorsGetDefaultKey)| +|[az datadog monitor list-api-key](#MonitorsListApiKeys)|ListApiKeys|[Parameters](#ParametersMonitorsListApiKeys)|[Example](#ExamplesMonitorsListApiKeys)| +|[az datadog monitor list-host](#MonitorsListHosts)|ListHosts|[Parameters](#ParametersMonitorsListHosts)|[Example](#ExamplesMonitorsListHosts)| +|[az datadog monitor list-linked-resource](#MonitorsListLinkedResources)|ListLinkedResources|[Parameters](#ParametersMonitorsListLinkedResources)|[Example](#ExamplesMonitorsListLinkedResources)| +|[az datadog monitor list-monitored-resource](#MonitorsListMonitoredResources)|ListMonitoredResources|[Parameters](#ParametersMonitorsListMonitoredResources)|[Example](#ExamplesMonitorsListMonitoredResources)| +|[az datadog monitor refresh-set-password-link](#MonitorsRefreshSetPasswordLink)|RefreshSetPasswordLink|[Parameters](#ParametersMonitorsRefreshSetPasswordLink)|[Example](#ExamplesMonitorsRefreshSetPasswordLink)| +|[az datadog monitor set-default-key](#MonitorsSetDefaultKey)|SetDefaultKey|[Parameters](#ParametersMonitorsSetDefaultKey)|[Example](#ExamplesMonitorsSetDefaultKey)| + +### Commands in `az datadog sso-config` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az datadog sso-config list](#SingleSignOnConfigurationsList)|List|[Parameters](#ParametersSingleSignOnConfigurationsList)|[Example](#ExamplesSingleSignOnConfigurationsList)| +|[az datadog sso-config show](#SingleSignOnConfigurationsGet)|Get|[Parameters](#ParametersSingleSignOnConfigurationsGet)|[Example](#ExamplesSingleSignOnConfigurationsGet)| +|[az datadog sso-config create](#SingleSignOnConfigurationsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersSingleSignOnConfigurationsCreateOrUpdate#Create)|[Example](#ExamplesSingleSignOnConfigurationsCreateOrUpdate#Create)| +|[az datadog sso-config update](#SingleSignOnConfigurationsCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersSingleSignOnConfigurationsCreateOrUpdate#Update)|Not Found| + +### Commands in `az datadog tag-rule` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az datadog tag-rule list](#TagRulesList)|List|[Parameters](#ParametersTagRulesList)|[Example](#ExamplesTagRulesList)| +|[az datadog tag-rule show](#TagRulesGet)|Get|[Parameters](#ParametersTagRulesGet)|[Example](#ExamplesTagRulesGet)| +|[az datadog tag-rule create](#TagRulesCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersTagRulesCreateOrUpdate#Create)|[Example](#ExamplesTagRulesCreateOrUpdate#Create)| +|[az datadog tag-rule update](#TagRulesCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersTagRulesCreateOrUpdate#Update)|Not Found| + +### Commands in `az datadog terms` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az datadog terms list](#MarketplaceAgreementsList)|List|[Parameters](#ParametersMarketplaceAgreementsList)|[Example](#ExamplesMarketplaceAgreementsList)| +|[az datadog terms create](#MarketplaceAgreementsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersMarketplaceAgreementsCreateOrUpdate#Create)|[Example](#ExamplesMarketplaceAgreementsCreateOrUpdate#Create)| +|[az datadog terms update](#MarketplaceAgreementsCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersMarketplaceAgreementsCreateOrUpdate#Update)|Not Found| + + +## COMMAND DETAILS + +### group `az datadog monitor` +#### Command `az datadog monitor list` + +##### Example +``` +az datadog monitor list --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| + +#### Command `az datadog monitor list` + +##### Example +``` +az datadog monitor list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az datadog monitor show` + +##### Example +``` +az datadog monitor show --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor create` + +##### Example +``` +az datadog monitor create --monitor-name "myMonitor" --name "myMonitor" --location "West US" \ +--datadog-organization-properties name="myOrg" enterprise-app-id="00000000-0000-0000-0000-000000000000" \ +linking-auth-code="someAuthCode" linking-client-id="00000000-0000-0000-0000-000000000000" subscription="pro" \ +--user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" --name "free_Monthly" --tags \ +Environment="Dev" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--tags**|dictionary|Dictionary of |tags|tags| +|**--location**|string||location|location| +|**--type**|choice|Identity type|type|type| +|**--datadog-organization-properties**|object|Datadog organization properties|datadog_organization_properties|datadogOrganizationProperties| +|**--user-info**|object|User info|user_info|userInfo| +|**--name**|string|Name of the SKU.|name|name| + +#### Command `az datadog monitor update` + +##### Example +``` +az datadog monitor update --monitor-name "myMonitor" --tags Environment="Dev" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--tags**|dictionary|The new tags of the monitor resource.|tags|tags| +|**--name**|string|Name of the SKU.|name|name| + +#### Command `az datadog monitor delete` + +##### Example +``` +az datadog monitor delete --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor get-default-key` + +##### Example +``` +az datadog monitor get-default-key --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor list-api-key` + +##### Example +``` +az datadog monitor list-api-key --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor list-host` + +##### Example +``` +az datadog monitor list-host --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor list-linked-resource` + +##### Example +``` +az datadog monitor list-linked-resource --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor list-monitored-resource` + +##### Example +``` +az datadog monitor list-monitored-resource --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor refresh-set-password-link` + +##### Example +``` +az datadog monitor refresh-set-password-link --name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog monitor set-default-key` + +##### Example +``` +az datadog monitor set-default-key --monitor-name "myMonitor" --key "1111111111111111aaaaaaaaaaaaaaaa" \ +--resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--created-by**|string|The user that created the API key.|created_by|createdBy| +|**--name**|string|The name of the API key.|name|name| +|**--key**|string|The value of the API key.|key|key| +|**--created**|string|The time of creation of the API key.|created|created| + +### group `az datadog sso-config` +#### Command `az datadog sso-config list` + +##### Example +``` +az datadog sso-config list --monitor-name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog sso-config show` + +##### Example +``` +az datadog sso-config show --configuration-name "default" --monitor-name "myMonitor" --resource-group \ +"myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string|Configuration name|configuration_name|configurationName| + +#### Command `az datadog sso-config create` + +##### Example +``` +az datadog sso-config create --configuration-name "default" --monitor-name "myMonitor" --properties \ +enterprise-app-id="00000000-0000-0000-0000-000000000000" single-sign-on-state="Enable" --resource-group \ +"myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string|Configuration name|configuration_name|configurationName| +|**--properties**|object||properties|properties| + +#### Command `az datadog sso-config update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--configuration-name**|string|Configuration name|configuration_name|configurationName| +|**--properties**|object||properties|properties| + +### group `az datadog tag-rule` +#### Command `az datadog tag-rule list` + +##### Example +``` +az datadog tag-rule list --monitor-name "myMonitor" --resource-group "myResourceGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| + +#### Command `az datadog tag-rule show` + +##### Example +``` +az datadog tag-rule show --monitor-name "myMonitor" --resource-group "myResourceGroup" --rule-set-name "default" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string|Rule set name|rule_set_name|ruleSetName| + +#### Command `az datadog tag-rule create` + +##### Example +``` +az datadog tag-rule create --monitor-name "myMonitor" --log-rules-filtering-tags name="Environment" action="Include" \ +value="Prod" --log-rules-filtering-tags name="Environment" action="Exclude" value="Dev" --send-aad-logs false \ +--send-resource-logs true --send-subscription-logs true --resource-group "myResourceGroup" --rule-set-name "default" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string|Rule set name|rule_set_name|ruleSetName| +|**--filtering-tags**|array|List of filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|filtering_tags|filteringTags| +|**--send-aad-logs**|boolean|Flag specifying if AAD logs should be sent for the Monitor resource.|send_aad_logs|sendAadLogs| +|**--send-subscription-logs**|boolean|Flag specifying if Azure subscription logs should be sent for the Monitor resource.|send_subscription_logs|sendSubscriptionLogs| +|**--send-resource-logs**|boolean|Flag specifying if Azure resource logs should be sent for the Monitor resource.|send_resource_logs|sendResourceLogs| +|**--log-rules-filtering-tags**|array|List of filtering tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|log_rules_filtering_tags|filteringTags| + +#### Command `az datadog tag-rule update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--monitor-name**|string|Monitor resource name|monitor_name|monitorName| +|**--rule-set-name**|string|Rule set name|rule_set_name|ruleSetName| +|**--filtering-tags**|array|List of filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|filtering_tags|filteringTags| +|**--send-aad-logs**|boolean|Flag specifying if AAD logs should be sent for the Monitor resource.|send_aad_logs|sendAadLogs| +|**--send-subscription-logs**|boolean|Flag specifying if Azure subscription logs should be sent for the Monitor resource.|send_subscription_logs|sendSubscriptionLogs| +|**--send-resource-logs**|boolean|Flag specifying if Azure resource logs should be sent for the Monitor resource.|send_resource_logs|sendResourceLogs| +|**--log-rules-filtering-tags**|array|List of filtering tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags.|log_rules_filtering_tags|filteringTags| + +### group `az datadog terms` +#### Command `az datadog terms list` + +##### Example +``` +az datadog terms list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az datadog terms create` + +##### Example +``` +az datadog terms create --properties accepted=true +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--properties**|object|Represents the properties of the resource.|properties|properties| + +#### Command `az datadog terms update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--properties**|object|Represents the properties of the resource.|properties|properties| diff --git a/src/datadog/setup.cfg b/src/datadog/setup.cfg index 8bfd5a12f85..2fdd96e5d39 100644 --- a/src/datadog/setup.cfg +++ b/src/datadog/setup.cfg @@ -1,4 +1 @@ -[egg_info] -tag_build = -tag_date = 0 - +#setup.cfg \ No newline at end of file