Skip to content
Open
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
63 changes: 63 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71497,6 +71497,39 @@ components:
$ref: "#/components/schemas/Trigger"
type: array
type: object
SpecItem:
description: A single API specification entry.
properties:
id:
description: Unique identifier for the spec.
example: "openapi-v2"
type: string
status:
$ref: "#/components/schemas/SpecItemStatus"
version:
description: The version of the spec.
example: "2.0.0"
type: string
type: object
SpecItemStatus:
description: The publication status of the spec.
enum:
- published
- draft
example: published
type: string
x-enum-varnames:
- PUBLISHED
- DRAFT
SpecListResponse:
description: Response containing a list of API specifications.
properties:
data:
description: List of spec items.
items:
$ref: "#/components/schemas/SpecItem"
type: array
type: object
SpecVersion:
description: The version of the CycloneDX specification a BOM conforms to.
enum:
Expand Down Expand Up @@ -137130,6 +137163,34 @@ paths:
cursorPath: meta.page.after
limitParam: body.data.attributes.page.limit
resultsPath: data
/api/v2/specs:
get:
description: Returns a list of available API specifications.
operationId: ListSpecs
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
- id: "openapi-v2"
status: published
version: "2.0.0"
schema:
$ref: "#/components/schemas/SpecListResponse"
description: OK
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ: []
summary: List API specifications
tags:
- Specs
x-unstable: true
/api/v2/static-analysis-sca/dependencies:
post:
operationId: CreateSCAResult
Expand Down Expand Up @@ -147523,6 +147584,8 @@ tags:
description: Find out more at
url: https://docs.datadoghq.com/tracing/metrics/metrics_namespace/
name: Spans Metrics
- description: Retrieve available API specifications.
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.
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------------------------

Expand Down
21 changes: 21 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31630,6 +31630,27 @@ datadog\_api\_client.v2.model.spec module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.spec\_item module
-----------------------------------------------

.. automodule:: datadog_api_client.v2.model.spec_item
:members:
:show-inheritance:

datadog\_api\_client.v2.model.spec\_item\_status module
-------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.spec_item_status
:members:
:show-inheritance:

datadog\_api\_client.v2.model.spec\_list\_response module
---------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.spec_list_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.split\_api\_key module
----------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions examples/v2/specs/ListSpecs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
List API specifications returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.specs_api import SpecsApi

configuration = Configuration()
configuration.unstable_operations["list_specs"] = True
with ApiClient(configuration) as api_client:
api_instance = SpecsApi(api_client)
response = api_instance.list_specs()

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ def __init__(
"v2.get_slo_status": False,
"v2.get_spa_recommendations": False,
"v2.get_spa_recommendations_with_shard": False,
"v2.list_specs": False,
"v2.create_custom_rule": False,
"v2.create_custom_rule_revision": False,
"v2.create_sca_resolve_vulnerable_symbols": False,
Expand Down
49 changes: 49 additions & 0 deletions src/datadog_api_client/v2/api/specs_api.py
Original file line number Diff line number Diff line change
@@ -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.spec_list_response import SpecListResponse


class SpecsApi:
"""
Retrieve available API specifications.
"""

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": (SpecListResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"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,
) -> SpecListResponse:
"""List API specifications.

Returns a list of available API specifications.

:rtype: SpecListResponse
"""
kwargs: Dict[str, Any] = {}
return self._list_specs_endpoint.call_with_http_info(**kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -210,6 +211,7 @@
"SpaApi",
"SpansApi",
"SpansMetricsApi",
"SpecsApi",
"StaticAnalysisApi",
"StatusPagesApi",
"StorageManagementApi",
Expand Down
62 changes: 62 additions & 0 deletions src/datadog_api_client/v2/model/spec_item.py
Original file line number Diff line number Diff line change
@@ -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_item_status import SpecItemStatus


class SpecItem(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.spec_item_status import SpecItemStatus

return {
"id": (str,),
"status": (SpecItemStatus,),
"version": (str,),
}

attribute_map = {
"id": "id",
"status": "status",
"version": "version",
}

def __init__(
self_,
id: Union[str, UnsetType] = unset,
status: Union[SpecItemStatus, UnsetType] = unset,
version: Union[str, UnsetType] = unset,
**kwargs,
):
"""
A single API specification entry.

:param id: Unique identifier for the spec.
:type id: str, optional

:param status: The publication status of the spec.
:type status: SpecItemStatus, optional

:param version: The version of the spec.
:type version: str, optional
"""
if id is not unset:
kwargs["id"] = id
if status is not unset:
kwargs["status"] = status
if version is not unset:
kwargs["version"] = version
super().__init__(kwargs)
38 changes: 38 additions & 0 deletions src/datadog_api_client/v2/model/spec_item_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 SpecItemStatus(ModelSimple):
"""
The publication status of the spec.

:param value: Must be one of ["published", "draft"].
:type value: str
"""

allowed_values = {
"published",
"draft",
}
PUBLISHED: ClassVar["SpecItemStatus"]
DRAFT: ClassVar["SpecItemStatus"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


SpecItemStatus.PUBLISHED = SpecItemStatus("published")
SpecItemStatus.DRAFT = SpecItemStatus("draft")
42 changes: 42 additions & 0 deletions src/datadog_api_client/v2/model/spec_list_response.py
Original file line number Diff line number Diff line change
@@ -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_item import SpecItem


class SpecListResponse(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.spec_item import SpecItem

return {
"data": ([SpecItem],),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: Union[List[SpecItem], UnsetType] = unset, **kwargs):
"""
Response containing a list of API specifications.

:param data: List of spec items.
:type data: [SpecItem], optional
"""
if data is not unset:
kwargs["data"] = data
super().__init__(kwargs)
6 changes: 6 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6446,6 +6446,9 @@
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_item import SpecItem
from datadog_api_client.v2.model.spec_item_status import SpecItemStatus
from datadog_api_client.v2.model.spec_list_response import SpecListResponse
from datadog_api_client.v2.model.spec_version import SpecVersion
from datadog_api_client.v2.model.split_api_key import SplitAPIKey
from datadog_api_client.v2.model.split_api_key_type import SplitAPIKeyType
Expand Down Expand Up @@ -12103,6 +12106,9 @@
"SpansType",
"SpansWarning",
"Spec",
"SpecItem",
"SpecItemStatus",
"SpecListResponse",
"SpecVersion",
"SplitAPIKey",
"SplitAPIKeyType",
Expand Down
13 changes: 13 additions & 0 deletions tests/v2/features/specs.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@endpoint(specs) @endpoint(specs-v2)
Feature: Specs
Retrieve available API specifications.

@generated @skip @team:DataDog/api-platform
Scenario: List API specifications 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 operation "ListSpecs" enabled
And new "ListSpecs" request
When the request is sent
Then the response status is 200 OK
Loading
Loading