Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datadog/azext_datadog/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.17.0"
"azext.minCliCoreVersion": "2.15.0"
}
28 changes: 14 additions & 14 deletions src/datadog/azext_datadog/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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="[email protected]" 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="[email protected]" 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="[email protected]" phone-number="123-456-7890" --name "free_Monthly" --tags \
Environment="Dev" --resource-group "myResourceGroup"
"""

helps['datadog monitor update'] = """
Expand All @@ -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"
"""

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions src/datadog/azext_datadog/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/datadog/azext_datadog/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
68 changes: 23 additions & 45 deletions src/datadog/azext_datadog/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@
# 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


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 = {}
Expand Down Expand Up @@ -53,16 +45,15 @@ 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,
location=None,
type_=None,
datadog_organization_properties=None,
user_info=None,
sku_name=None,
name=None,
no_wait=False):
body = {}
body['tags'] = tags
Expand All @@ -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,
Expand Down
Loading