Skip to content

Commit 83c4855

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add PUT endpoint to scorecards APIs (#2081)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 86f3085 commit 83c4855

15 files changed

+500
-12
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-07-30 19:24:55.550204",
8-
"spec_repo_commit": "edbd396a"
7+
"regenerated": "2024-08-01 14:34:28.948043",
8+
"spec_repo_commit": "d28278c6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-07-30 19:24:55.567305",
13-
"spec_repo_commit": "edbd396a"
12+
"regenerated": "2024-08-01 14:34:28.967083",
13+
"spec_repo_commit": "d28278c6"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ components:
464464
schema:
465465
type: string
466466
RuleId:
467-
description: The ID of the rule/scorecard.
467+
description: The ID of the rule.
468468
in: path
469469
name: rule_id
470470
required: true
@@ -16546,7 +16546,7 @@ components:
1654616546
properties:
1654716547
id:
1654816548
description: The unique ID for a scorecard.
16549-
example: 00000000-0000-beef-0000-000000000000
16549+
example: q8MQxk8TCqrHnWkp
1655016550
type: string
1655116551
type:
1655216552
$ref: '#/components/schemas/ScorecardType'
@@ -17391,7 +17391,7 @@ components:
1739117391
type: object
1739217392
RuleId:
1739317393
description: The unique ID for a scorecard rule.
17394-
example: 00000000-0000-beef-0000-000000000000
17394+
example: q8MQxk8TCqrHnWkx
1739517395
type: string
1739617396
RuleOutcomeRelationships:
1739717397
description: The JSON:API relationship to a scorecard rule.
@@ -23230,6 +23230,38 @@ components:
2323023230
id:
2323123231
$ref: '#/components/schemas/ApiID'
2323223232
type: object
23233+
UpdateRuleRequest:
23234+
description: Request to update a scorecard rule.
23235+
properties:
23236+
data:
23237+
$ref: '#/components/schemas/UpdateRuleRequestData'
23238+
type: object
23239+
UpdateRuleRequestData:
23240+
description: Data for the request to update a scorecard rule.
23241+
properties:
23242+
attributes:
23243+
$ref: '#/components/schemas/RuleAttributes'
23244+
type:
23245+
$ref: '#/components/schemas/RuleType'
23246+
type: object
23247+
UpdateRuleResponse:
23248+
description: The response from a rule update request.
23249+
properties:
23250+
data:
23251+
$ref: '#/components/schemas/UpdateRuleResponseData'
23252+
type: object
23253+
UpdateRuleResponseData:
23254+
description: The data for a rule update response.
23255+
properties:
23256+
attributes:
23257+
$ref: '#/components/schemas/RuleAttributes'
23258+
id:
23259+
$ref: '#/components/schemas/RuleId'
23260+
relationships:
23261+
$ref: '#/components/schemas/RelationshipToRule'
23262+
type:
23263+
$ref: '#/components/schemas/RuleType'
23264+
type: object
2323323265
UsageApplicationSecurityMonitoringResponse:
2323423266
description: Application Security Monitoring usage response.
2323523267
properties:
@@ -33671,6 +33703,43 @@ paths:
3367133703
x-unstable: '**Note**: This endpoint is in public beta.
3367233704

3367333705
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
33706+
put:
33707+
description: Updates an existing rule.
33708+
operationId: UpdateScorecardRule
33709+
parameters:
33710+
- $ref: '#/components/parameters/RuleId'
33711+
requestBody:
33712+
content:
33713+
application/json:
33714+
schema:
33715+
$ref: '#/components/schemas/UpdateRuleRequest'
33716+
description: Rule attributes.
33717+
required: true
33718+
responses:
33719+
'200':
33720+
content:
33721+
application/json:
33722+
schema:
33723+
$ref: '#/components/schemas/UpdateRuleResponse'
33724+
description: Rule updated successfully
33725+
'400':
33726+
$ref: '#/components/responses/BadRequestResponse'
33727+
'403':
33728+
$ref: '#/components/responses/ForbiddenResponse'
33729+
'429':
33730+
$ref: '#/components/responses/TooManyRequestsResponse'
33731+
security:
33732+
- apiKeyAuth: []
33733+
appKeyAuth: []
33734+
- AuthZ:
33735+
- apm_service_catalog_write
33736+
summary: Update an existing rule
33737+
tags:
33738+
- Service Scorecards
33739+
x-codegen-request-body-name: body
33740+
x-unstable: '**Note**: This endpoint is in public beta.
33741+
33742+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
3367433743
/api/v2/security/cloud_workload/policy/download:
3367533744
get:
3367633745
description: 'The download endpoint generates a Cloud Workload Security policy
@@ -38387,8 +38456,8 @@ tags:
3838738456

3838838457
and improve communication with internal and external users.'
3838938458
name: Service Level Objectives
38390-
- description: 'API to create, update scorecard rules and outcomes. See [Service Scorecards](https://docs.datadoghq.com/service_catalog/scorecards)
38391-
for more information.
38459+
- description: 'API to create and update scorecard rules and outcomes. See [Service
38460+
Scorecards](https://docs.datadoghq.com/service_catalog/scorecards) for more information.
3839238461

3839338462

3839438463
This feature is currently in BETA. If you have any feedback, contact [Datadog

docs/datadog_api_client.v2.model.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10371,6 +10371,34 @@ datadog\_api\_client.v2.model.update\_open\_api\_response\_data module
1037110371
:members:
1037210372
:show-inheritance:
1037310373

10374+
datadog\_api\_client.v2.model.update\_rule\_request module
10375+
----------------------------------------------------------
10376+
10377+
.. automodule:: datadog_api_client.v2.model.update_rule_request
10378+
:members:
10379+
:show-inheritance:
10380+
10381+
datadog\_api\_client.v2.model.update\_rule\_request\_data module
10382+
----------------------------------------------------------------
10383+
10384+
.. automodule:: datadog_api_client.v2.model.update_rule_request_data
10385+
:members:
10386+
:show-inheritance:
10387+
10388+
datadog\_api\_client.v2.model.update\_rule\_response module
10389+
-----------------------------------------------------------
10390+
10391+
.. automodule:: datadog_api_client.v2.model.update_rule_response
10392+
:members:
10393+
:show-inheritance:
10394+
10395+
datadog\_api\_client.v2.model.update\_rule\_response\_data module
10396+
-----------------------------------------------------------------
10397+
10398+
.. automodule:: datadog_api_client.v2.model.update_rule_response_data
10399+
:members:
10400+
:show-inheritance:
10401+
1037410402
datadog\_api\_client.v2.model.usage\_application\_security\_monitoring\_response module
1037510403
---------------------------------------------------------------------------------------
1037610404

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Update an existing rule returns "Rule updated successfully" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.service_scorecards_api import ServiceScorecardsApi
8+
from datadog_api_client.v2.model.rule_attributes import RuleAttributes
9+
from datadog_api_client.v2.model.update_rule_request import UpdateRuleRequest
10+
from datadog_api_client.v2.model.update_rule_request_data import UpdateRuleRequestData
11+
12+
# there is a valid "create_scorecard_rule" in the system
13+
CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_NAME = environ["CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_NAME"]
14+
CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_SCORECARD_NAME = environ["CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_SCORECARD_NAME"]
15+
CREATE_SCORECARD_RULE_DATA_ID = environ["CREATE_SCORECARD_RULE_DATA_ID"]
16+
17+
body = UpdateRuleRequest(
18+
data=UpdateRuleRequestData(
19+
attributes=RuleAttributes(
20+
enabled=True,
21+
name=CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_NAME,
22+
scorecard_name=CREATE_SCORECARD_RULE_DATA_ATTRIBUTES_SCORECARD_NAME,
23+
description="Updated description via test",
24+
),
25+
),
26+
)
27+
28+
configuration = Configuration()
29+
configuration.unstable_operations["update_scorecard_rule"] = True
30+
with ApiClient(configuration) as api_client:
31+
api_instance = ServiceScorecardsApi(api_client)
32+
response = api_instance.update_scorecard_rule(rule_id=CREATE_SCORECARD_RULE_DATA_ID, body=body)
33+
34+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def __init__(
273273
"v2.delete_scorecard_rule": False,
274274
"v2.list_scorecard_outcomes": False,
275275
"v2.list_scorecard_rules": False,
276+
"v2.update_scorecard_rule": False,
276277
"v2.create_incident_service": False,
277278
"v2.delete_incident_service": False,
278279
"v2.get_incident_service": False,

src/datadog_api_client/v2/api/service_scorecards_api.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
from datadog_api_client.v2.model.list_rules_response_data_item import ListRulesResponseDataItem
2323
from datadog_api_client.v2.model.create_rule_response import CreateRuleResponse
2424
from datadog_api_client.v2.model.create_rule_request import CreateRuleRequest
25+
from datadog_api_client.v2.model.update_rule_response import UpdateRuleResponse
26+
from datadog_api_client.v2.model.update_rule_request import UpdateRuleRequest
2527

2628

2729
class ServiceScorecardsApi:
2830
"""
29-
API to create, update scorecard rules and outcomes. See `Service Scorecards <https://docs.datadoghq.com/service_catalog/scorecards>`_ for more information.
31+
API to create and update scorecard rules and outcomes. See `Service Scorecards <https://docs.datadoghq.com/service_catalog/scorecards>`_ for more information.
3032
3133
This feature is currently in BETA. If you have any feedback, contact `Datadog support <https://docs.datadoghq.com/help/>`_.
3234
"""
@@ -233,6 +235,32 @@ def __init__(self, api_client=None):
233235
api_client=api_client,
234236
)
235237

238+
self._update_scorecard_rule_endpoint = _Endpoint(
239+
settings={
240+
"response_type": (UpdateRuleResponse,),
241+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
242+
"endpoint_path": "/api/v2/scorecard/rules/{rule_id}",
243+
"operation_id": "update_scorecard_rule",
244+
"http_method": "PUT",
245+
"version": "v2",
246+
},
247+
params_map={
248+
"rule_id": {
249+
"required": True,
250+
"openapi_types": (str,),
251+
"attribute": "rule_id",
252+
"location": "path",
253+
},
254+
"body": {
255+
"required": True,
256+
"openapi_types": (UpdateRuleRequest,),
257+
"location": "body",
258+
},
259+
},
260+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
261+
api_client=api_client,
262+
)
263+
236264
def create_scorecard_outcomes_batch(
237265
self,
238266
body: OutcomesBatchRequest,
@@ -275,7 +303,7 @@ def delete_scorecard_rule(
275303
276304
Deletes a single rule.
277305
278-
:param rule_id: The ID of the rule/scorecard.
306+
:param rule_id: The ID of the rule.
279307
:type rule_id: str
280308
:rtype: None
281309
"""
@@ -599,3 +627,25 @@ def list_scorecard_rules_with_pagination(
599627
"kwargs": kwargs,
600628
}
601629
return endpoint.call_with_http_info_paginated(pagination)
630+
631+
def update_scorecard_rule(
632+
self,
633+
rule_id: str,
634+
body: UpdateRuleRequest,
635+
) -> UpdateRuleResponse:
636+
"""Update an existing rule.
637+
638+
Updates an existing rule.
639+
640+
:param rule_id: The ID of the rule.
641+
:type rule_id: str
642+
:param body: Rule attributes.
643+
:type body: UpdateRuleRequest
644+
:rtype: UpdateRuleResponse
645+
"""
646+
kwargs: Dict[str, Any] = {}
647+
kwargs["rule_id"] = rule_id
648+
649+
kwargs["body"] = body
650+
651+
return self._update_scorecard_rule_endpoint.call_with_http_info(**kwargs)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.update_rule_request_data import UpdateRuleRequestData
18+
19+
20+
class UpdateRuleRequest(ModelNormal):
21+
@cached_property
22+
def openapi_types(_):
23+
from datadog_api_client.v2.model.update_rule_request_data import UpdateRuleRequestData
24+
25+
return {
26+
"data": (UpdateRuleRequestData,),
27+
}
28+
29+
attribute_map = {
30+
"data": "data",
31+
}
32+
33+
def __init__(self_, data: Union[UpdateRuleRequestData, UnsetType] = unset, **kwargs):
34+
"""
35+
Request to update a scorecard rule.
36+
37+
:param data: Data for the request to update a scorecard rule.
38+
:type data: UpdateRuleRequestData, optional
39+
"""
40+
if data is not unset:
41+
kwargs["data"] = data
42+
super().__init__(kwargs)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v2.model.rule_attributes import RuleAttributes
18+
from datadog_api_client.v2.model.rule_type import RuleType
19+
20+
21+
class UpdateRuleRequestData(ModelNormal):
22+
@cached_property
23+
def openapi_types(_):
24+
from datadog_api_client.v2.model.rule_attributes import RuleAttributes
25+
from datadog_api_client.v2.model.rule_type import RuleType
26+
27+
return {
28+
"attributes": (RuleAttributes,),
29+
"type": (RuleType,),
30+
}
31+
32+
attribute_map = {
33+
"attributes": "attributes",
34+
"type": "type",
35+
}
36+
37+
def __init__(
38+
self_, attributes: Union[RuleAttributes, UnsetType] = unset, type: Union[RuleType, UnsetType] = unset, **kwargs
39+
):
40+
"""
41+
Data for the request to update a scorecard rule.
42+
43+
:param attributes: Details of a rule.
44+
:type attributes: RuleAttributes, optional
45+
46+
:param type: The JSON:API type for scorecard rules.
47+
:type type: RuleType, optional
48+
"""
49+
if attributes is not unset:
50+
kwargs["attributes"] = attributes
51+
if type is not unset:
52+
kwargs["type"] = type
53+
super().__init__(kwargs)

0 commit comments

Comments
 (0)