Skip to content

Commit c5193f8

Browse files
shivansh257Shivansh Agarwal
andauthored
Fix resource creation in datadog (#9144)
* fix resource creation * update attribute * update example * update version * update version --------- Co-authored-by: Shivansh Agarwal <agarwalshiv@microsoft.com>
1 parent 917ba68 commit c5193f8

File tree

7 files changed

+76
-52
lines changed

7 files changed

+76
-52
lines changed

src/datadog/HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
33
Release History
44
===============
5+
2.0.0
6+
++++++
7+
* Fix resource creation issue
58

69
1.0.0
710
++++++

src/datadog/azext_datadog/aaz/latest/datadog/monitor/_create.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ class Create(AAZCommand):
1818
"""Creates a new Datadog monitor resource in your Azure subscription. This sets up the integration between Azure and your Datadog account, enabling observability and monitoring of your Azure resources through Datadog.
1919
2020
:example: Monitors_Create
21-
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"
21+
az datadog monitor create --name "myMonitor" --resource-group "myResourceGroup" --location "West US 2" --org-properties name="myResourceGroup" --tags Environment="Dev" --user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" --sku name="payg_v3_Monthly" --identity type="SystemAssigned" --monitoring-status "Enabled"
2222
2323
:example: Monitors creation with linking to Datadog organization.
24-
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"
24+
az datadog monitor create --name "myMonitor-link" --resource-group "myResourceGroup" --location "West US 2" --org-properties api-key=XX application-key=XX --tags Environment="Dev" --user-info name="Alice" email-address="alice@microsoft.com" phone-number="123-456-7890" --identity type="SystemAssigned" --sku name="Linked"
2525
"""
2626

2727
_aaz_info = {
28-
"version": "2021-03-01",
28+
"version": "2023-10-20",
2929
"resources": [
30-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2021-03-01"],
30+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2023-10-20"],
3131
]
3232
}
3333

@@ -99,8 +99,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
9999
# define Arg Group "Properties"
100100

101101
_args_schema = cls._args_schema
102-
_args_schema.datadog_organization_properties = AAZObjectArg(
103-
options=["--datadog-organization-properties"],
102+
_args_schema.org_properties = AAZObjectArg(
103+
options=["--org-properties"],
104104
arg_group="Properties",
105105
help="Datadog organization properties",
106106
)
@@ -117,28 +117,40 @@ def _build_arguments_schema(cls, *args, **kwargs):
117117
help="User info",
118118
)
119119

120-
datadog_organization_properties = cls._args_schema.datadog_organization_properties
121-
datadog_organization_properties.api_key = AAZStrArg(
120+
org_properties = cls._args_schema.org_properties
121+
org_properties.api_key = AAZStrArg(
122122
options=["api-key"],
123123
help="Api key associated to the Datadog organization.",
124124
)
125-
datadog_organization_properties.application_key = AAZStrArg(
125+
org_properties.application_key = AAZStrArg(
126126
options=["application-key"],
127127
help="Application key associated to the Datadog organization.",
128128
)
129-
datadog_organization_properties.enterprise_app_id = AAZStrArg(
129+
org_properties.cspm = AAZBoolArg(
130+
options=["cspm"],
131+
help="The configuration which describes the state of cloud security posture management. This collects configuration information for all resources in a subscription and track conformance to industry benchmarks.",
132+
)
133+
org_properties.enterprise_app_id = AAZStrArg(
130134
options=["enterprise-app-id"],
131135
help="The Id of the Enterprise App used for Single sign on.",
132136
)
133-
datadog_organization_properties.linking_auth_code = AAZStrArg(
137+
org_properties.id = AAZStrArg(
138+
options=["id"],
139+
help="Id of the Datadog organization.",
140+
)
141+
org_properties.linking_auth_code = AAZStrArg(
134142
options=["linking-auth-code"],
135143
help="The auth code used to linking to an existing datadog organization.",
136144
)
137-
datadog_organization_properties.linking_client_id = AAZStrArg(
145+
org_properties.linking_client_id = AAZStrArg(
138146
options=["linking-client-id"],
139147
help="The client_id from an existing in exchange for an auth token to link organization.",
140148
)
141-
datadog_organization_properties.redirect_uri = AAZStrArg(
149+
org_properties.name = AAZStrArg(
150+
options=["name"],
151+
help="Name of the Datadog organization.",
152+
)
153+
org_properties.redirect_uri = AAZStrArg(
142154
options=["redirect-uri"],
143155
help="The redirect uri for linking.",
144156
)
@@ -248,7 +260,7 @@ def url_parameters(self):
248260
def query_parameters(self):
249261
parameters = {
250262
**self.serialize_query_param(
251-
"api-version", "2021-03-01",
263+
"api-version", "2023-10-20",
252264
required=True,
253265
),
254266
}
@@ -285,17 +297,20 @@ def content(self):
285297

286298
properties = _builder.get(".properties")
287299
if properties is not None:
288-
properties.set_prop("datadogOrganizationProperties", AAZObjectType, ".datadog_organization_properties")
300+
properties.set_prop("datadogOrganizationProperties", AAZObjectType, ".org_properties")
289301
properties.set_prop("monitoringStatus", AAZStrType, ".monitoring_status")
290302
properties.set_prop("userInfo", AAZObjectType, ".user_info", typ_kwargs={"flags": {"secret": True}})
291303

292304
datadog_organization_properties = _builder.get(".properties.datadogOrganizationProperties")
293305
if datadog_organization_properties is not None:
294306
datadog_organization_properties.set_prop("apiKey", AAZStrType, ".api_key", typ_kwargs={"flags": {"secret": True}})
295307
datadog_organization_properties.set_prop("applicationKey", AAZStrType, ".application_key", typ_kwargs={"flags": {"secret": True}})
308+
datadog_organization_properties.set_prop("cspm", AAZBoolType, ".cspm")
296309
datadog_organization_properties.set_prop("enterpriseAppId", AAZStrType, ".enterprise_app_id")
310+
datadog_organization_properties.set_prop("id", AAZStrType, ".id")
297311
datadog_organization_properties.set_prop("linkingAuthCode", AAZStrType, ".linking_auth_code", typ_kwargs={"flags": {"secret": True}})
298312
datadog_organization_properties.set_prop("linkingClientId", AAZStrType, ".linking_client_id", typ_kwargs={"flags": {"secret": True}})
313+
datadog_organization_properties.set_prop("name", AAZStrType, ".name")
299314
datadog_organization_properties.set_prop("redirectUri", AAZStrType, ".redirect_uri")
300315

301316
user_info = _builder.get(".properties.userInfo")
@@ -393,12 +408,9 @@ def _build_schema_on_200_201(cls):
393408
)
394409

395410
datadog_organization_properties = cls._schema_on_200_201.properties.datadog_organization_properties
396-
datadog_organization_properties.id = AAZStrType(
397-
flags={"read_only": True},
398-
)
399-
datadog_organization_properties.name = AAZStrType(
400-
flags={"read_only": True},
401-
)
411+
datadog_organization_properties.cspm = AAZBoolType()
412+
datadog_organization_properties.id = AAZStrType()
413+
datadog_organization_properties.name = AAZStrType()
402414

403415
user_info = cls._schema_on_200_201.properties.user_info
404416
user_info.email_address = AAZStrType(

src/datadog/azext_datadog/aaz/latest/datadog/monitor/_delete.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class Delete(AAZCommand):
2323
"""
2424

2525
_aaz_info = {
26-
"version": "2021-03-01",
26+
"version": "2023-10-20",
2727
"resources": [
28-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2021-03-01"],
28+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2023-10-20"],
2929
]
3030
}
3131

@@ -143,7 +143,7 @@ def url_parameters(self):
143143
def query_parameters(self):
144144
parameters = {
145145
**self.serialize_query_param(
146-
"api-version", "2021-03-01",
146+
"api-version", "2023-10-20",
147147
required=True,
148148
),
149149
}

src/datadog/azext_datadog/aaz/latest/datadog/monitor/_show.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class Show(AAZCommand):
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2021-03-01",
25+
"version": "2023-10-20",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2021-03-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2023-10-20"],
2828
]
2929
}
3030

@@ -120,7 +120,7 @@ def url_parameters(self):
120120
def query_parameters(self):
121121
parameters = {
122122
**self.serialize_query_param(
123-
"api-version", "2021-03-01",
123+
"api-version", "2023-10-20",
124124
required=True,
125125
),
126126
}
@@ -214,12 +214,9 @@ def _build_schema_on_200(cls):
214214
)
215215

216216
datadog_organization_properties = cls._schema_on_200.properties.datadog_organization_properties
217-
datadog_organization_properties.id = AAZStrType(
218-
flags={"read_only": True},
219-
)
220-
datadog_organization_properties.name = AAZStrType(
221-
flags={"read_only": True},
222-
)
217+
datadog_organization_properties.cspm = AAZBoolType()
218+
datadog_organization_properties.id = AAZStrType()
219+
datadog_organization_properties.name = AAZStrType()
223220

224221
user_info = cls._schema_on_200.properties.user_info
225222
user_info.email_address = AAZStrType(

src/datadog/azext_datadog/aaz/latest/datadog/monitor/_update.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class Update(AAZCommand):
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2021-03-01",
25+
"version": "2023-10-20",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2021-03-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2023-10-20"],
2828
]
2929
}
3030

@@ -104,6 +104,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
104104
# define Arg Group "Properties"
105105

106106
_args_schema = cls._args_schema
107+
_args_schema.org_properties = AAZObjectArg(
108+
options=["--org-properties"],
109+
arg_group="Properties",
110+
help="Specify the Datadog organization name. In the case of linking to existing organizations, Id, ApiKey, and Applicationkey is required as well.",
111+
nullable=True,
112+
)
107113
_args_schema.monitoring_status = AAZStrArg(
108114
options=["--monitoring-status"],
109115
arg_group="Properties",
@@ -118,6 +124,13 @@ def _build_arguments_schema(cls, *args, **kwargs):
118124
nullable=True,
119125
)
120126

127+
org_properties = cls._args_schema.org_properties
128+
org_properties.cspm = AAZBoolArg(
129+
options=["cspm"],
130+
help="The configuration which describes the state of cloud security posture management. This collects configuration information for all resources in a subscription and track conformance to industry benchmarks.",
131+
nullable=True,
132+
)
133+
121134
user_info = cls._args_schema.user_info
122135
user_info.email_address = AAZStrArg(
123136
options=["email-address"],
@@ -223,7 +236,7 @@ def url_parameters(self):
223236
def query_parameters(self):
224237
parameters = {
225238
**self.serialize_query_param(
226-
"api-version", "2021-03-01",
239+
"api-version", "2023-10-20",
227240
required=True,
228241
),
229242
}
@@ -322,7 +335,7 @@ def url_parameters(self):
322335
def query_parameters(self):
323336
parameters = {
324337
**self.serialize_query_param(
325-
"api-version", "2021-03-01",
338+
"api-version", "2023-10-20",
326339
required=True,
327340
),
328341
}
@@ -392,9 +405,14 @@ def _update_instance(self, instance):
392405

393406
properties = _builder.get(".properties")
394407
if properties is not None:
408+
properties.set_prop("datadogOrganizationProperties", AAZObjectType, ".org_properties")
395409
properties.set_prop("monitoringStatus", AAZStrType, ".monitoring_status")
396410
properties.set_prop("userInfo", AAZObjectType, ".user_info", typ_kwargs={"flags": {"secret": True}})
397411

412+
datadog_organization_properties = _builder.get(".properties.datadogOrganizationProperties")
413+
if datadog_organization_properties is not None:
414+
datadog_organization_properties.set_prop("cspm", AAZBoolType, ".cspm")
415+
398416
user_info = _builder.get(".properties.userInfo")
399417
if user_info is not None:
400418
user_info.set_prop("emailAddress", AAZStrType, ".email_address")
@@ -503,12 +521,9 @@ def _build_schema_datadog_monitor_resource_read(cls, _schema):
503521
)
504522

505523
datadog_organization_properties = _schema_datadog_monitor_resource_read.properties.datadog_organization_properties
506-
datadog_organization_properties.id = AAZStrType(
507-
flags={"read_only": True},
508-
)
509-
datadog_organization_properties.name = AAZStrType(
510-
flags={"read_only": True},
511-
)
524+
datadog_organization_properties.cspm = AAZBoolType()
525+
datadog_organization_properties.id = AAZStrType()
526+
datadog_organization_properties.name = AAZStrType()
512527

513528
user_info = _schema_datadog_monitor_resource_read.properties.user_info
514529
user_info.email_address = AAZStrType(

src/datadog/azext_datadog/aaz/latest/datadog/monitor/_wait.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Wait(AAZWaitCommand):
2020

2121
_aaz_info = {
2222
"resources": [
23-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2021-03-01"],
23+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.datadog/monitors/{}", "2023-10-20"],
2424
]
2525
}
2626

@@ -116,7 +116,7 @@ def url_parameters(self):
116116
def query_parameters(self):
117117
parameters = {
118118
**self.serialize_query_param(
119-
"api-version", "2021-03-01",
119+
"api-version", "2023-10-20",
120120
required=True,
121121
),
122122
}
@@ -210,12 +210,9 @@ def _build_schema_on_200(cls):
210210
)
211211

212212
datadog_organization_properties = cls._schema_on_200.properties.datadog_organization_properties
213-
datadog_organization_properties.id = AAZStrType(
214-
flags={"read_only": True},
215-
)
216-
datadog_organization_properties.name = AAZStrType(
217-
flags={"read_only": True},
218-
)
213+
datadog_organization_properties.cspm = AAZBoolType()
214+
datadog_organization_properties.id = AAZStrType()
215+
datadog_organization_properties.name = AAZStrType()
219216

220217
user_info = cls._schema_on_200.properties.user_info
221218
user_info.email_address = AAZStrType(

src/datadog/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
# HISTORY.rst entry.
13-
VERSION = '1.0.0'
13+
VERSION = '2.0.0'
1414

1515
# The full list of classifiers is available at
1616
# https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)