diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 07a00c9a7f..7a0a9aa0fe 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -41461,6 +41461,39 @@ components: example: "/api/v2/scorecard/rules?page%5Blimit%5D=2&page%5Boffset%5D=2&page%5Bsize%5D=2" type: string type: object + ListScorecardScoresMeta: + description: Pagination metadata for scores. + properties: + count: + description: The number of results returned in this page. + format: int64 + type: integer + limit: + description: The page limit. + format: int64 + type: integer + offset: + description: The page offset. + format: int64 + type: integer + total: + description: The total number of results. + format: int64 + type: integer + type: object + ListScorecardScoresResponse: + description: A list of scorecard scores for a given aggregation type. + properties: + data: + description: Array of score objects. + items: + $ref: "#/components/schemas/ScorecardScoreData" + type: array + links: + $ref: "#/components/schemas/ListRulesResponseLinks" + meta: + $ref: "#/components/schemas/ListScorecardScoresMeta" + type: object ListScorecardsResponse: description: Response containing a list of scorecards. properties: @@ -62579,6 +62612,119 @@ components: type: string x-enum-varnames: - SCORECARD + ScorecardScoreAttributes: + description: Attributes of a scorecard score. + properties: + aggregation: + $ref: "#/components/schemas/ScorecardScoresAggregation" + denominator: + description: The denominator used to compute the score ratio. + format: int64 + type: integer + level: + description: The maturity level of the associated rule. + format: int64 + type: integer + numerator: + description: The numerator used to compute the score ratio. + format: int64 + type: integer + score: + description: The computed score ratio (numerator/denominator), from 0 to 1. + format: double + type: number + total_entities: + description: The total number of entities evaluated. + format: int64 + type: integer + total_fail: + description: The number of rules that failed. + format: int64 + type: integer + total_no_data: + description: The number of rules with no data. + format: int64 + type: integer + total_pass: + description: The number of rules that passed. + format: int64 + type: integer + total_skip: + description: The number of rules that were skipped. + format: int64 + type: integer + type: object + ScorecardScoreData: + description: A scorecard score object for a single entity, rule, scorecard, service, or team. + properties: + attributes: + $ref: "#/components/schemas/ScorecardScoreAttributes" + id: + description: The ID of the entity or resource being scored. + example: "" + type: string + relationships: + $ref: "#/components/schemas/ScorecardScoreRelationships" + type: + $ref: "#/components/schemas/ScorecardScoreDataType" + required: + - id + - type + type: object + ScorecardScoreDataType: + default: score + description: The JSON:API resource type. + enum: [score] + example: score + type: string + x-enum-varnames: + - SCORE + ScorecardScoreRelationshipData: + description: A relationship data object for a score. + properties: + id: + description: The ID of the related resource. + example: "" + type: string + type: + description: The type of the related resource. + example: "" + type: string + required: + - id + - type + type: object + ScorecardScoreRelationshipItem: + description: A relationship item for a score. + properties: + data: + $ref: "#/components/schemas/ScorecardScoreRelationshipData" + type: object + ScorecardScoreRelationships: + description: Relationships for a scorecard score, depending on the aggregation type. + properties: + entity: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + rule: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + scorecard: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + service: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + team: + $ref: "#/components/schemas/ScorecardScoreRelationshipItem" + type: object + ScorecardScoresAggregation: + description: Dimension to group scores by. + enum: [by-entity, by-rule, by-scorecard, by-team, by-kind] + example: by-entity + type: string + x-enum-varnames: + - BY_ENTITY + - BY_RULE + - BY_SCORECARD + - BY_TEAM + - BY_KIND ScorecardType: default: scorecard description: The JSON:API type for scorecard. @@ -128170,6 +128316,127 @@ paths: summary: List all scorecards tags: - Scorecards + /api/v2/scorecard/scores/{aggregation}: + get: + description: Returns a list of scorecard scores for each aggregation type, with score breakdowns. + operationId: ListScorecardScores + parameters: + - description: The type of scores being requested. + in: path + name: aggregation + required: true + schema: + $ref: "#/components/schemas/ScorecardScoresAggregation" + - description: Filter scores by an entity query string. + in: query + name: filter[entity][query] + required: false + schema: + type: string + - description: Filter scores by rule ID(s), comma-separated. + in: query + name: filter[rule][id] + required: false + schema: + type: string + - description: Filter scores by rule name. + in: query + name: filter[rule][name] + required: false + schema: + type: string + - description: Filter scores by rule level(s), comma-separated. + in: query + name: filter[rule][level] + required: false + schema: + type: string + - description: Filter scores by scorecard ID(s), comma-separated. + in: query + name: filter[rule][scorecard_id] + required: false + schema: + type: string + - description: Filter scores to show only custom rules. + in: query + name: filter[rule][is_custom] + required: false + schema: + type: boolean + - description: Filter scores to show only enabled rules. + in: query + name: filter[rule][is_enabled] + required: false + schema: + type: boolean + - description: "Sort scores by field. Use a hyphen prefix for descending order. Options: score, numerator, denominator, total_pass, total_fail, total_skip, total_no_data." + in: query + name: sort + required: false + schema: + type: string + - description: Offset for pagination. + in: query + name: page[offset] + required: false + schema: + default: 0 + type: integer + - description: Number of scores to return. Max is 1000. + in: query + name: page[limit] + required: false + schema: + default: 100 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + aggregation: by-entity + denominator: 4 + numerator: 3 + score: 0.75 + total_fail: 1 + total_no_data: 0 + total_pass: 3 + total_skip: 0 + id: service:my-service + relationships: + entity: + data: + id: service:my-service + type: entity + type: score + links: + next: /api/v2/scorecard/scores/by-entity?page[offset]=100&page[limit]=100 + meta: + count: 1 + limit: 100 + offset: 0 + total: 42 + schema: + $ref: "#/components/schemas/ListScorecardScoresResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - apm_service_catalog_read + summary: List all scores + tags: + - Scorecards /api/v2/seats/users: delete: description: |- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 18c6f936a0..b3dfe61205 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -16769,6 +16769,20 @@ datadog\_api\_client.v2.model.list\_rules\_response\_links module :members: :show-inheritance: +datadog\_api\_client.v2.model.list\_scorecard\_scores\_meta module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.list_scorecard_scores_meta + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.list\_scorecard\_scores\_response module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.list_scorecard_scores_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.list\_scorecards\_response module --------------------------------------------------------------- @@ -27808,6 +27822,55 @@ datadog\_api\_client.v2.model.scorecard\_list\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.scorecard\_score\_attributes module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_score\_data module +----------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_score\_data\_type module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_data_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_score\_relationship\_data module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_relationship_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_score\_relationship\_item module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_relationship_item + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_score\_relationships module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_score_relationships + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.scorecard\_scores\_aggregation module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.scorecard_scores_aggregation + :members: + :show-inheritance: + datadog\_api\_client.v2.model.scorecard\_type module ---------------------------------------------------- diff --git a/examples/v2/scorecards/ListScorecardScores.py b/examples/v2/scorecards/ListScorecardScores.py new file mode 100644 index 0000000000..539f5ba9c3 --- /dev/null +++ b/examples/v2/scorecards/ListScorecardScores.py @@ -0,0 +1,16 @@ +""" +List all scores returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.scorecards_api import ScorecardsApi +from datadog_api_client.v2.model.scorecard_scores_aggregation import ScorecardScoresAggregation + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = ScorecardsApi(api_client) + response = api_instance.list_scorecard_scores( + aggregation=ScorecardScoresAggregation.BY_ENTITY, + ) + + print(response) diff --git a/src/datadog_api_client/v2/api/scorecards_api.py b/src/datadog_api_client/v2/api/scorecards_api.py index e0a71e0df4..71067db3c5 100644 --- a/src/datadog_api_client/v2/api/scorecards_api.py +++ b/src/datadog_api_client/v2/api/scorecards_api.py @@ -31,6 +31,8 @@ from datadog_api_client.v2.model.update_rule_response import UpdateRuleResponse from datadog_api_client.v2.model.update_rule_request import UpdateRuleRequest from datadog_api_client.v2.model.list_scorecards_response import ListScorecardsResponse +from datadog_api_client.v2.model.list_scorecard_scores_response import ListScorecardScoresResponse +from datadog_api_client.v2.model.scorecard_scores_aggregation import ScorecardScoresAggregation class ScorecardsApi: @@ -400,6 +402,79 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._list_scorecard_scores_endpoint = _Endpoint( + settings={ + "response_type": (ListScorecardScoresResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/scorecard/scores/{aggregation}", + "operation_id": "list_scorecard_scores", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "aggregation": { + "required": True, + "openapi_types": (ScorecardScoresAggregation,), + "attribute": "aggregation", + "location": "path", + }, + "filter_entity_query": { + "openapi_types": (str,), + "attribute": "filter[entity][query]", + "location": "query", + }, + "filter_rule_id": { + "openapi_types": (str,), + "attribute": "filter[rule][id]", + "location": "query", + }, + "filter_rule_name": { + "openapi_types": (str,), + "attribute": "filter[rule][name]", + "location": "query", + }, + "filter_rule_level": { + "openapi_types": (str,), + "attribute": "filter[rule][level]", + "location": "query", + }, + "filter_rule_scorecard_id": { + "openapi_types": (str,), + "attribute": "filter[rule][scorecard_id]", + "location": "query", + }, + "filter_rule_is_custom": { + "openapi_types": (bool,), + "attribute": "filter[rule][is_custom]", + "location": "query", + }, + "filter_rule_is_enabled": { + "openapi_types": (bool,), + "attribute": "filter[rule][is_enabled]", + "location": "query", + }, + "sort": { + "openapi_types": (str,), + "attribute": "sort", + "location": "query", + }, + "page_offset": { + "openapi_types": (int,), + "attribute": "page[offset]", + "location": "query", + }, + "page_limit": { + "openapi_types": (int,), + "attribute": "page[limit]", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._update_scorecard_campaign_endpoint = _Endpoint( settings={ "response_type": (CampaignResponse,), @@ -990,6 +1065,84 @@ def list_scorecards( return self._list_scorecards_endpoint.call_with_http_info(**kwargs) + def list_scorecard_scores( + self, + aggregation: ScorecardScoresAggregation, + *, + filter_entity_query: Union[str, UnsetType] = unset, + filter_rule_id: Union[str, UnsetType] = unset, + filter_rule_name: Union[str, UnsetType] = unset, + filter_rule_level: Union[str, UnsetType] = unset, + filter_rule_scorecard_id: Union[str, UnsetType] = unset, + filter_rule_is_custom: Union[bool, UnsetType] = unset, + filter_rule_is_enabled: Union[bool, UnsetType] = unset, + sort: Union[str, UnsetType] = unset, + page_offset: Union[int, UnsetType] = unset, + page_limit: Union[int, UnsetType] = unset, + ) -> ListScorecardScoresResponse: + """List all scores. + + Returns a list of scorecard scores for each aggregation type, with score breakdowns. + + :param aggregation: The type of scores being requested. + :type aggregation: ScorecardScoresAggregation + :param filter_entity_query: Filter scores by an entity query string. + :type filter_entity_query: str, optional + :param filter_rule_id: Filter scores by rule ID(s), comma-separated. + :type filter_rule_id: str, optional + :param filter_rule_name: Filter scores by rule name. + :type filter_rule_name: str, optional + :param filter_rule_level: Filter scores by rule level(s), comma-separated. + :type filter_rule_level: str, optional + :param filter_rule_scorecard_id: Filter scores by scorecard ID(s), comma-separated. + :type filter_rule_scorecard_id: str, optional + :param filter_rule_is_custom: Filter scores to show only custom rules. + :type filter_rule_is_custom: bool, optional + :param filter_rule_is_enabled: Filter scores to show only enabled rules. + :type filter_rule_is_enabled: bool, optional + :param sort: Sort scores by field. Use a hyphen prefix for descending order. Options: score, numerator, denominator, total_pass, total_fail, total_skip, total_no_data. + :type sort: str, optional + :param page_offset: Offset for pagination. + :type page_offset: int, optional + :param page_limit: Number of scores to return. Max is 1000. + :type page_limit: int, optional + :rtype: ListScorecardScoresResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["aggregation"] = aggregation + + if filter_entity_query is not unset: + kwargs["filter_entity_query"] = filter_entity_query + + if filter_rule_id is not unset: + kwargs["filter_rule_id"] = filter_rule_id + + if filter_rule_name is not unset: + kwargs["filter_rule_name"] = filter_rule_name + + if filter_rule_level is not unset: + kwargs["filter_rule_level"] = filter_rule_level + + if filter_rule_scorecard_id is not unset: + kwargs["filter_rule_scorecard_id"] = filter_rule_scorecard_id + + if filter_rule_is_custom is not unset: + kwargs["filter_rule_is_custom"] = filter_rule_is_custom + + if filter_rule_is_enabled is not unset: + kwargs["filter_rule_is_enabled"] = filter_rule_is_enabled + + if sort is not unset: + kwargs["sort"] = sort + + if page_offset is not unset: + kwargs["page_offset"] = page_offset + + if page_limit is not unset: + kwargs["page_limit"] = page_limit + + return self._list_scorecard_scores_endpoint.call_with_http_info(**kwargs) + def update_scorecard_campaign( self, campaign_id: str, diff --git a/src/datadog_api_client/v2/model/list_scorecard_scores_meta.py b/src/datadog_api_client/v2/model/list_scorecard_scores_meta.py new file mode 100644 index 0000000000..4b1a002885 --- /dev/null +++ b/src/datadog_api_client/v2/model/list_scorecard_scores_meta.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class ListScorecardScoresMeta(ModelNormal): + @cached_property + def openapi_types(_): + return { + "count": (int,), + "limit": (int,), + "offset": (int,), + "total": (int,), + } + + attribute_map = { + "count": "count", + "limit": "limit", + "offset": "offset", + "total": "total", + } + + def __init__( + self_, + count: Union[int, UnsetType] = unset, + limit: Union[int, UnsetType] = unset, + offset: Union[int, UnsetType] = unset, + total: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Pagination metadata for scores. + + :param count: The number of results returned in this page. + :type count: int, optional + + :param limit: The page limit. + :type limit: int, optional + + :param offset: The page offset. + :type offset: int, optional + + :param total: The total number of results. + :type total: int, optional + """ + if count is not unset: + kwargs["count"] = count + if limit is not unset: + kwargs["limit"] = limit + if offset is not unset: + kwargs["offset"] = offset + if total is not unset: + kwargs["total"] = total + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/list_scorecard_scores_response.py b/src/datadog_api_client/v2/model/list_scorecard_scores_response.py new file mode 100644 index 0000000000..69d58b07da --- /dev/null +++ b/src/datadog_api_client/v2/model/list_scorecard_scores_response.py @@ -0,0 +1,66 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.scorecard_score_data import ScorecardScoreData + from datadog_api_client.v2.model.list_rules_response_links import ListRulesResponseLinks + from datadog_api_client.v2.model.list_scorecard_scores_meta import ListScorecardScoresMeta + + +class ListScorecardScoresResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.scorecard_score_data import ScorecardScoreData + from datadog_api_client.v2.model.list_rules_response_links import ListRulesResponseLinks + from datadog_api_client.v2.model.list_scorecard_scores_meta import ListScorecardScoresMeta + + return { + "data": ([ScorecardScoreData],), + "links": (ListRulesResponseLinks,), + "meta": (ListScorecardScoresMeta,), + } + + attribute_map = { + "data": "data", + "links": "links", + "meta": "meta", + } + + def __init__( + self_, + data: Union[List[ScorecardScoreData], UnsetType] = unset, + links: Union[ListRulesResponseLinks, UnsetType] = unset, + meta: Union[ListScorecardScoresMeta, UnsetType] = unset, + **kwargs, + ): + """ + A list of scorecard scores for a given aggregation type. + + :param data: Array of score objects. + :type data: [ScorecardScoreData], optional + + :param links: Links attributes. + :type links: ListRulesResponseLinks, optional + + :param meta: Pagination metadata for scores. + :type meta: ListScorecardScoresMeta, optional + """ + if data is not unset: + kwargs["data"] = data + if links is not unset: + kwargs["links"] = links + if meta is not unset: + kwargs["meta"] = meta + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/scorecard_score_attributes.py b/src/datadog_api_client/v2/model/scorecard_score_attributes.py new file mode 100644 index 0000000000..a640ef1395 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_attributes.py @@ -0,0 +1,118 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.scorecard_scores_aggregation import ScorecardScoresAggregation + + +class ScorecardScoreAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.scorecard_scores_aggregation import ScorecardScoresAggregation + + return { + "aggregation": (ScorecardScoresAggregation,), + "denominator": (int,), + "level": (int,), + "numerator": (int,), + "score": (float,), + "total_entities": (int,), + "total_fail": (int,), + "total_no_data": (int,), + "total_pass": (int,), + "total_skip": (int,), + } + + attribute_map = { + "aggregation": "aggregation", + "denominator": "denominator", + "level": "level", + "numerator": "numerator", + "score": "score", + "total_entities": "total_entities", + "total_fail": "total_fail", + "total_no_data": "total_no_data", + "total_pass": "total_pass", + "total_skip": "total_skip", + } + + def __init__( + self_, + aggregation: Union[ScorecardScoresAggregation, UnsetType] = unset, + denominator: Union[int, UnsetType] = unset, + level: Union[int, UnsetType] = unset, + numerator: Union[int, UnsetType] = unset, + score: Union[float, UnsetType] = unset, + total_entities: Union[int, UnsetType] = unset, + total_fail: Union[int, UnsetType] = unset, + total_no_data: Union[int, UnsetType] = unset, + total_pass: Union[int, UnsetType] = unset, + total_skip: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Attributes of a scorecard score. + + :param aggregation: Dimension to group scores by. + :type aggregation: ScorecardScoresAggregation, optional + + :param denominator: The denominator used to compute the score ratio. + :type denominator: int, optional + + :param level: The maturity level of the associated rule. + :type level: int, optional + + :param numerator: The numerator used to compute the score ratio. + :type numerator: int, optional + + :param score: The computed score ratio (numerator/denominator), from 0 to 1. + :type score: float, optional + + :param total_entities: The total number of entities evaluated. + :type total_entities: int, optional + + :param total_fail: The number of rules that failed. + :type total_fail: int, optional + + :param total_no_data: The number of rules with no data. + :type total_no_data: int, optional + + :param total_pass: The number of rules that passed. + :type total_pass: int, optional + + :param total_skip: The number of rules that were skipped. + :type total_skip: int, optional + """ + if aggregation is not unset: + kwargs["aggregation"] = aggregation + if denominator is not unset: + kwargs["denominator"] = denominator + if level is not unset: + kwargs["level"] = level + if numerator is not unset: + kwargs["numerator"] = numerator + if score is not unset: + kwargs["score"] = score + if total_entities is not unset: + kwargs["total_entities"] = total_entities + if total_fail is not unset: + kwargs["total_fail"] = total_fail + if total_no_data is not unset: + kwargs["total_no_data"] = total_no_data + if total_pass is not unset: + kwargs["total_pass"] = total_pass + if total_skip is not unset: + kwargs["total_skip"] = total_skip + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/scorecard_score_data.py b/src/datadog_api_client/v2/model/scorecard_score_data.py new file mode 100644 index 0000000000..bf6317a918 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_data.py @@ -0,0 +1,73 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.scorecard_score_attributes import ScorecardScoreAttributes + from datadog_api_client.v2.model.scorecard_score_relationships import ScorecardScoreRelationships + from datadog_api_client.v2.model.scorecard_score_data_type import ScorecardScoreDataType + + +class ScorecardScoreData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.scorecard_score_attributes import ScorecardScoreAttributes + from datadog_api_client.v2.model.scorecard_score_relationships import ScorecardScoreRelationships + from datadog_api_client.v2.model.scorecard_score_data_type import ScorecardScoreDataType + + return { + "attributes": (ScorecardScoreAttributes,), + "id": (str,), + "relationships": (ScorecardScoreRelationships,), + "type": (ScorecardScoreDataType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + id: str, + type: ScorecardScoreDataType, + attributes: Union[ScorecardScoreAttributes, UnsetType] = unset, + relationships: Union[ScorecardScoreRelationships, UnsetType] = unset, + **kwargs, + ): + """ + A scorecard score object for a single entity, rule, scorecard, service, or team. + + :param attributes: Attributes of a scorecard score. + :type attributes: ScorecardScoreAttributes, optional + + :param id: The ID of the entity or resource being scored. + :type id: str + + :param relationships: Relationships for a scorecard score, depending on the aggregation type. + :type relationships: ScorecardScoreRelationships, optional + + :param type: The JSON:API resource type. + :type type: ScorecardScoreDataType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if relationships is not unset: + kwargs["relationships"] = relationships + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/scorecard_score_data_type.py b/src/datadog_api_client/v2/model/scorecard_score_data_type.py new file mode 100644 index 0000000000..61fcf3ce0f --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_data_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ScorecardScoreDataType(ModelSimple): + """ + The JSON:API resource type. + + :param value: If omitted defaults to "score". Must be one of ["score"]. + :type value: str + """ + + allowed_values = { + "score", + } + SCORE: ClassVar["ScorecardScoreDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ScorecardScoreDataType.SCORE = ScorecardScoreDataType("score") diff --git a/src/datadog_api_client/v2/model/scorecard_score_relationship_data.py b/src/datadog_api_client/v2/model/scorecard_score_relationship_data.py new file mode 100644 index 0000000000..06183ba455 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_relationship_data.py @@ -0,0 +1,39 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class ScorecardScoreRelationshipData(ModelNormal): + @cached_property + def openapi_types(_): + return { + "id": (str,), + "type": (str,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: str, type: str, **kwargs): + """ + A relationship data object for a score. + + :param id: The ID of the related resource. + :type id: str + + :param type: The type of the related resource. + :type type: str + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/scorecard_score_relationship_item.py b/src/datadog_api_client/v2/model/scorecard_score_relationship_item.py new file mode 100644 index 0000000000..7065315462 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_relationship_item.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.scorecard_score_relationship_data import ScorecardScoreRelationshipData + + +class ScorecardScoreRelationshipItem(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.scorecard_score_relationship_data import ScorecardScoreRelationshipData + + return { + "data": (ScorecardScoreRelationshipData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[ScorecardScoreRelationshipData, UnsetType] = unset, **kwargs): + """ + A relationship item for a score. + + :param data: A relationship data object for a score. + :type data: ScorecardScoreRelationshipData, optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/scorecard_score_relationships.py b/src/datadog_api_client/v2/model/scorecard_score_relationships.py new file mode 100644 index 0000000000..cb0a870ef5 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_score_relationships.py @@ -0,0 +1,78 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.scorecard_score_relationship_item import ScorecardScoreRelationshipItem + + +class ScorecardScoreRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.scorecard_score_relationship_item import ScorecardScoreRelationshipItem + + return { + "entity": (ScorecardScoreRelationshipItem,), + "rule": (ScorecardScoreRelationshipItem,), + "scorecard": (ScorecardScoreRelationshipItem,), + "service": (ScorecardScoreRelationshipItem,), + "team": (ScorecardScoreRelationshipItem,), + } + + attribute_map = { + "entity": "entity", + "rule": "rule", + "scorecard": "scorecard", + "service": "service", + "team": "team", + } + + def __init__( + self_, + entity: Union[ScorecardScoreRelationshipItem, UnsetType] = unset, + rule: Union[ScorecardScoreRelationshipItem, UnsetType] = unset, + scorecard: Union[ScorecardScoreRelationshipItem, UnsetType] = unset, + service: Union[ScorecardScoreRelationshipItem, UnsetType] = unset, + team: Union[ScorecardScoreRelationshipItem, UnsetType] = unset, + **kwargs, + ): + """ + Relationships for a scorecard score, depending on the aggregation type. + + :param entity: A relationship item for a score. + :type entity: ScorecardScoreRelationshipItem, optional + + :param rule: A relationship item for a score. + :type rule: ScorecardScoreRelationshipItem, optional + + :param scorecard: A relationship item for a score. + :type scorecard: ScorecardScoreRelationshipItem, optional + + :param service: A relationship item for a score. + :type service: ScorecardScoreRelationshipItem, optional + + :param team: A relationship item for a score. + :type team: ScorecardScoreRelationshipItem, optional + """ + if entity is not unset: + kwargs["entity"] = entity + if rule is not unset: + kwargs["rule"] = rule + if scorecard is not unset: + kwargs["scorecard"] = scorecard + if service is not unset: + kwargs["service"] = service + if team is not unset: + kwargs["team"] = team + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/scorecard_scores_aggregation.py b/src/datadog_api_client/v2/model/scorecard_scores_aggregation.py new file mode 100644 index 0000000000..36af126a09 --- /dev/null +++ b/src/datadog_api_client/v2/model/scorecard_scores_aggregation.py @@ -0,0 +1,47 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class ScorecardScoresAggregation(ModelSimple): + """ + Dimension to group scores by. + + :param value: Must be one of ["by-entity", "by-rule", "by-scorecard", "by-team", "by-kind"]. + :type value: str + """ + + allowed_values = { + "by-entity", + "by-rule", + "by-scorecard", + "by-team", + "by-kind", + } + BY_ENTITY: ClassVar["ScorecardScoresAggregation"] + BY_RULE: ClassVar["ScorecardScoresAggregation"] + BY_SCORECARD: ClassVar["ScorecardScoresAggregation"] + BY_TEAM: ClassVar["ScorecardScoresAggregation"] + BY_KIND: ClassVar["ScorecardScoresAggregation"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +ScorecardScoresAggregation.BY_ENTITY = ScorecardScoresAggregation("by-entity") +ScorecardScoresAggregation.BY_RULE = ScorecardScoresAggregation("by-rule") +ScorecardScoresAggregation.BY_SCORECARD = ScorecardScoresAggregation("by-scorecard") +ScorecardScoresAggregation.BY_TEAM = ScorecardScoresAggregation("by-team") +ScorecardScoresAggregation.BY_KIND = ScorecardScoresAggregation("by-kind") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index b9f03d887d..8c3bc12efe 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -3363,6 +3363,8 @@ from datadog_api_client.v2.model.list_rules_response import ListRulesResponse from datadog_api_client.v2.model.list_rules_response_data_item import ListRulesResponseDataItem from datadog_api_client.v2.model.list_rules_response_links import ListRulesResponseLinks +from datadog_api_client.v2.model.list_scorecard_scores_meta import ListScorecardScoresMeta +from datadog_api_client.v2.model.list_scorecard_scores_response import ListScorecardScoresResponse from datadog_api_client.v2.model.list_scorecards_response import ListScorecardsResponse from datadog_api_client.v2.model.list_security_findings_response import ListSecurityFindingsResponse from datadog_api_client.v2.model.list_tags_response import ListTagsResponse @@ -5597,6 +5599,13 @@ from datadog_api_client.v2.model.scorecard_list_response_attributes import ScorecardListResponseAttributes from datadog_api_client.v2.model.scorecard_list_response_data import ScorecardListResponseData from datadog_api_client.v2.model.scorecard_list_type import ScorecardListType +from datadog_api_client.v2.model.scorecard_score_attributes import ScorecardScoreAttributes +from datadog_api_client.v2.model.scorecard_score_data import ScorecardScoreData +from datadog_api_client.v2.model.scorecard_score_data_type import ScorecardScoreDataType +from datadog_api_client.v2.model.scorecard_score_relationship_data import ScorecardScoreRelationshipData +from datadog_api_client.v2.model.scorecard_score_relationship_item import ScorecardScoreRelationshipItem +from datadog_api_client.v2.model.scorecard_score_relationships import ScorecardScoreRelationships +from datadog_api_client.v2.model.scorecard_scores_aggregation import ScorecardScoresAggregation from datadog_api_client.v2.model.scorecard_type import ScorecardType from datadog_api_client.v2.model.search_issues_include_query_parameter_item import SearchIssuesIncludeQueryParameterItem from datadog_api_client.v2.model.seat_assignments_data_type import SeatAssignmentsDataType @@ -10067,6 +10076,8 @@ "ListRulesResponse", "ListRulesResponseDataItem", "ListRulesResponseLinks", + "ListScorecardScoresMeta", + "ListScorecardScoresResponse", "ListScorecardsResponse", "ListSecurityFindingsResponse", "ListTagsResponse", @@ -11519,6 +11530,13 @@ "ScorecardListResponseAttributes", "ScorecardListResponseData", "ScorecardListType", + "ScorecardScoreAttributes", + "ScorecardScoreData", + "ScorecardScoreDataType", + "ScorecardScoreRelationshipData", + "ScorecardScoreRelationshipItem", + "ScorecardScoreRelationships", + "ScorecardScoresAggregation", "ScorecardType", "SearchIssuesIncludeQueryParameterItem", "SeatAssignmentsDataType", diff --git a/tests/v2/features/scorecards.feature b/tests/v2/features/scorecards.feature index 750948d899..e932599c67 100644 --- a/tests/v2/features/scorecards.feature +++ b/tests/v2/features/scorecards.feature @@ -183,6 +183,20 @@ Feature: Scorecards When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/service-catalog + Scenario: List all scores returns "Bad Request" response + Given new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/service-catalog + Scenario: List all scores returns "OK" response + Given new "ListScorecardScores" request + And request contains "aggregation" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/service-catalog Scenario: Update Scorecard outcomes asynchronously returns "Accepted" response Given there is a valid "create_scorecard_rule" in the system diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 049acf0531..998d5322ab 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -5276,6 +5276,12 @@ "type": "safe" } }, + "ListScorecardScores": { + "tag": "Scorecards", + "undo": { + "type": "safe" + } + }, "UnassignSeatsUser": { "tag": "Seats", "undo": {