diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 73163c4c17..b4048675b2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -71914,6 +71914,55 @@ components: $ref: "#/components/schemas/Trigger" type: array type: object + SpecAttributes: + description: Attributes of an API spec. + properties: + name: + description: The name of the spec. + example: pets-api + type: string + status: + $ref: "#/components/schemas/SpecAttributesStatus" + version: + description: The version of the spec. + example: "2.1.0" + type: string + type: object + SpecAttributesStatus: + description: The publication status of the spec. + enum: + - published + - draft + - deprecated + example: published + type: string + x-enum-varnames: + - PUBLISHED + - DRAFT + - DEPRECATED + SpecData: + description: A single API spec resource. + properties: + attributes: + $ref: "#/components/schemas/SpecAttributes" + id: + description: The unique identifier of the spec. + example: d5e5d5a0-1234-5678-9abc-def012345678 + type: string + type: + $ref: "#/components/schemas/SpecType" + required: + - type + type: object + SpecType: + default: spec + description: Type of the spec resource. + enum: + - spec + example: spec + type: string + x-enum-varnames: + - SPEC SpecVersion: description: The version of the CycloneDX specification a BOM conforms to. enum: @@ -71932,6 +71981,15 @@ components: - ONE_THREE - ONE_FOUR - ONE_FIVE + SpecsListResponse: + description: Response containing a list of specs. + properties: + data: + description: List of specs. + items: + $ref: "#/components/schemas/SpecData" + type: array + type: object SplitAPIKey: description: The definition of the `SplitAPIKey` object. properties: @@ -137984,6 +138042,43 @@ paths: cursorPath: meta.page.after limitParam: body.data.attributes.page.limit resultsPath: data + /api/v2/specs: + get: + description: Returns a list of API specs stored in the system. + operationId: ListSpecs + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + name: pets-api + status: published + version: "2.1.0" + id: d5e5d5a0-1234-5678-9abc-def012345678 + type: spec + - attributes: + name: users-api + status: draft + version: "1.0.0" + id: a1b2c3d4-5678-9abc-def0-123456789abc + type: spec + schema: + $ref: "#/components/schemas/SpecsListResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List API specs + tags: + - Specs /api/v2/static-analysis-sca/dependencies: post: operationId: CreateSCAResult @@ -148377,6 +148472,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/metrics/metrics_namespace/ name: Spans Metrics + - description: |- + View API specs stored in the system. + name: Specs - description: API for static analysis name: Static Analysis - description: Manage your status pages and communicate service disruptions to stakeholders via Datadog's API. See the [Status Pages documentation](https://docs.datadoghq.com/incident_response/status_pages/) for more information. diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index 6863171396..b1041d62f2 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -697,6 +697,13 @@ datadog\_api\_client.v2.api.spans\_metrics\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.specs\_api module +--------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.specs_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.static\_analysis\_api module -------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index e6cb85d7d6..c1262e623c 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -31777,6 +31777,41 @@ datadog\_api\_client.v2.model.spec module :members: :show-inheritance: +datadog\_api\_client.v2.model.spec\_attributes module +----------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.spec_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.spec\_attributes\_status module +------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.spec_attributes_status + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.spec\_data module +----------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.spec_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.spec\_type module +----------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.spec_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.specs\_list\_response module +---------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.specs_list_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.split\_api\_key module ---------------------------------------------------- diff --git a/examples/v2/specs/ListSpecs.py b/examples/v2/specs/ListSpecs.py new file mode 100644 index 0000000000..d7c7f7ac9b --- /dev/null +++ b/examples/v2/specs/ListSpecs.py @@ -0,0 +1,13 @@ +""" +List API specs returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.specs_api import SpecsApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = SpecsApi(api_client) + response = api_instance.list_specs() + + print(response) diff --git a/src/datadog_api_client/v2/api/specs_api.py b/src/datadog_api_client/v2/api/specs_api.py new file mode 100644 index 0000000000..229d981a68 --- /dev/null +++ b/src/datadog_api_client/v2/api/specs_api.py @@ -0,0 +1,49 @@ +# 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 Any, Dict + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.v2.model.specs_list_response import SpecsListResponse + + +class SpecsApi: + """ + View API specs stored in the system. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._list_specs_endpoint = _Endpoint( + settings={ + "response_type": (SpecsListResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/specs", + "operation_id": "list_specs", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + def list_specs( + self, + ) -> SpecsListResponse: + """List API specs. + + Returns a list of API specs stored in the system. + + :rtype: SpecsListResponse + """ + kwargs: Dict[str, Any] = {} + return self._list_specs_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index f8a5950df2..d68779b836 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -97,6 +97,7 @@ from datadog_api_client.v2.api.spa_api import SpaApi from datadog_api_client.v2.api.spans_api import SpansApi from datadog_api_client.v2.api.spans_metrics_api import SpansMetricsApi +from datadog_api_client.v2.api.specs_api import SpecsApi from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi from datadog_api_client.v2.api.status_pages_api import StatusPagesApi from datadog_api_client.v2.api.storage_management_api import StorageManagementApi @@ -210,6 +211,7 @@ "SpaApi", "SpansApi", "SpansMetricsApi", + "SpecsApi", "StaticAnalysisApi", "StatusPagesApi", "StorageManagementApi", diff --git a/src/datadog_api_client/v2/model/spec_attributes.py b/src/datadog_api_client/v2/model/spec_attributes.py new file mode 100644 index 0000000000..ff0f8f962b --- /dev/null +++ b/src/datadog_api_client/v2/model/spec_attributes.py @@ -0,0 +1,62 @@ +# 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.spec_attributes_status import SpecAttributesStatus + + +class SpecAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.spec_attributes_status import SpecAttributesStatus + + return { + "name": (str,), + "status": (SpecAttributesStatus,), + "version": (str,), + } + + attribute_map = { + "name": "name", + "status": "status", + "version": "version", + } + + def __init__( + self_, + name: Union[str, UnsetType] = unset, + status: Union[SpecAttributesStatus, UnsetType] = unset, + version: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Attributes of an API spec. + + :param name: The name of the spec. + :type name: str, optional + + :param status: The publication status of the spec. + :type status: SpecAttributesStatus, optional + + :param version: The version of the spec. + :type version: str, optional + """ + if name is not unset: + kwargs["name"] = name + if status is not unset: + kwargs["status"] = status + if version is not unset: + kwargs["version"] = version + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/spec_attributes_status.py b/src/datadog_api_client/v2/model/spec_attributes_status.py new file mode 100644 index 0000000000..031ca61854 --- /dev/null +++ b/src/datadog_api_client/v2/model/spec_attributes_status.py @@ -0,0 +1,41 @@ +# 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 SpecAttributesStatus(ModelSimple): + """ + The publication status of the spec. + + :param value: Must be one of ["published", "draft", "deprecated"]. + :type value: str + """ + + allowed_values = { + "published", + "draft", + "deprecated", + } + PUBLISHED: ClassVar["SpecAttributesStatus"] + DRAFT: ClassVar["SpecAttributesStatus"] + DEPRECATED: ClassVar["SpecAttributesStatus"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +SpecAttributesStatus.PUBLISHED = SpecAttributesStatus("published") +SpecAttributesStatus.DRAFT = SpecAttributesStatus("draft") +SpecAttributesStatus.DEPRECATED = SpecAttributesStatus("deprecated") diff --git a/src/datadog_api_client/v2/model/spec_data.py b/src/datadog_api_client/v2/model/spec_data.py new file mode 100644 index 0000000000..c1c41f6286 --- /dev/null +++ b/src/datadog_api_client/v2/model/spec_data.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, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.spec_attributes import SpecAttributes + from datadog_api_client.v2.model.spec_type import SpecType + + +class SpecData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.spec_attributes import SpecAttributes + from datadog_api_client.v2.model.spec_type import SpecType + + return { + "attributes": (SpecAttributes,), + "id": (str,), + "type": (SpecType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + type: SpecType, + attributes: Union[SpecAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A single API spec resource. + + :param attributes: Attributes of an API spec. + :type attributes: SpecAttributes, optional + + :param id: The unique identifier of the spec. + :type id: str, optional + + :param type: Type of the spec resource. + :type type: SpecType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/spec_type.py b/src/datadog_api_client/v2/model/spec_type.py new file mode 100644 index 0000000000..501fa8585a --- /dev/null +++ b/src/datadog_api_client/v2/model/spec_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 SpecType(ModelSimple): + """ + Type of the spec resource. + + :param value: If omitted defaults to "spec". Must be one of ["spec"]. + :type value: str + """ + + allowed_values = { + "spec", + } + SPEC: ClassVar["SpecType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +SpecType.SPEC = SpecType("spec") diff --git a/src/datadog_api_client/v2/model/specs_list_response.py b/src/datadog_api_client/v2/model/specs_list_response.py new file mode 100644 index 0000000000..eb5c085360 --- /dev/null +++ b/src/datadog_api_client/v2/model/specs_list_response.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 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.spec_data import SpecData + + +class SpecsListResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.spec_data import SpecData + + return { + "data": ([SpecData],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: Union[List[SpecData], UnsetType] = unset, **kwargs): + """ + Response containing a list of specs. + + :param data: List of specs. + :type data: [SpecData], optional + """ + if data is not unset: + kwargs["data"] = data + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 26fdc85362..526bbac555 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -6467,7 +6467,12 @@ from datadog_api_client.v2.model.spans_type import SpansType from datadog_api_client.v2.model.spans_warning import SpansWarning from datadog_api_client.v2.model.spec import Spec +from datadog_api_client.v2.model.spec_attributes import SpecAttributes +from datadog_api_client.v2.model.spec_attributes_status import SpecAttributesStatus +from datadog_api_client.v2.model.spec_data import SpecData +from datadog_api_client.v2.model.spec_type import SpecType from datadog_api_client.v2.model.spec_version import SpecVersion +from datadog_api_client.v2.model.specs_list_response import SpecsListResponse from datadog_api_client.v2.model.split_api_key import SplitAPIKey from datadog_api_client.v2.model.split_api_key_type import SplitAPIKeyType from datadog_api_client.v2.model.split_api_key_update import SplitAPIKeyUpdate @@ -12145,7 +12150,12 @@ "SpansType", "SpansWarning", "Spec", + "SpecAttributes", + "SpecAttributesStatus", + "SpecData", + "SpecType", "SpecVersion", + "SpecsListResponse", "SplitAPIKey", "SplitAPIKeyType", "SplitAPIKeyUpdate", diff --git a/tests/v2/features/specs.feature b/tests/v2/features/specs.feature new file mode 100644 index 0000000000..830e1d6f6c --- /dev/null +++ b/tests/v2/features/specs.feature @@ -0,0 +1,12 @@ +@endpoint(specs) @endpoint(specs-v2) +Feature: Specs + View API specs stored in the system. + + @generated @skip @team:DataDog/web-frameworks-test + Scenario: List API specs returns "OK" response + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Specs" API + And new "ListSpecs" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index dc1a8b2fbb..1a41e1001b 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -6252,6 +6252,12 @@ "type": "safe" } }, + "ListSpecs": { + "tag": "Specs", + "undo": { + "type": "safe" + } + }, "CreateSCAResult": { "tag": "Static Analysis", "undo": {