Skip to content

Add support for API management ListAPIs #1995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:14.314414",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:50.078498",
"spec_repo_commit": "71f2f0da"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-11 09:38:14.335187",
"spec_repo_commit": "cee92551"
"regenerated": "2024-06-11 14:30:50.097371",
"spec_repo_commit": "71f2f0da"
}
}
}
103 changes: 103 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10554,6 +10554,52 @@ components:
description: Jira project key
type: string
type: object
ListAPIsResponse:
description: Response for `ListAPIs`.
properties:
data:
description: List of API items.
items:
$ref: '#/components/schemas/ListAPIsResponseData'
type: array
meta:
$ref: '#/components/schemas/ListAPIsResponseMeta'
type: object
ListAPIsResponseData:
description: Data envelope for `ListAPIsResponse`.
properties:
id:
$ref: '#/components/schemas/ApiID'
name:
description: API name.
example: Payments API
type: string
type: object
ListAPIsResponseMeta:
description: Metadata for `ListAPIsResponse`.
properties:
pagination:
$ref: '#/components/schemas/ListAPIsResponseMetaPagination'
type: object
ListAPIsResponseMetaPagination:
description: Pagination metadata information for `ListAPIsResponse`.
properties:
limit:
description: Number of items in the current page.
example: 20
format: int64
type: integer
offset:
description: Offset for pagination.
example: 0
format: int64
type: integer
total_count:
description: Total number of items.
example: 35
format: int64
type: integer
type: object
ListApplicationKeysResponse:
description: Response for a list of application keys.
properties:
Expand Down Expand Up @@ -23350,6 +23396,63 @@ paths:
tags:
- Key Management
x-codegen-request-body-name: body
/api/v2/apicatalog/api:
get:
description: List APIs and their IDs.
operationId: ListAPIs
parameters:
- description: Filter APIs by name
in: query
name: query
required: false
schema:
example: payments
type: string
- description: Number of items per page.
in: query
name: page[limit]
required: false
schema:
default: 20
format: int64
minimum: 1
type: integer
- description: Offset for pagination.
in: query
name: page[offset]
required: false
schema:
default: 0
format: int64
minimum: 0
type: integer
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ListAPIsResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Bad request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: Forbidden
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: List APIs
tags:
- API Management
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/apicatalog/api/{id}:
delete:
description: Delete a specific API by ID.
Expand Down
28 changes: 28 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4481,6 +4481,34 @@ jsonapi\_error\_response
:members:
:show-inheritance:

list\_ap\_is\_response
----------------------

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

list\_ap\_is\_response\_data
----------------------------

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

list\_ap\_is\_response\_meta
----------------------------

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

list\_ap\_is\_response\_meta\_pagination
----------------------------------------

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

list\_application\_keys\_response
---------------------------------

Expand Down
14 changes: 14 additions & 0 deletions examples/v2/api-management/ListAPIs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
List APIs returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.api_management_api import APIManagementApi

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

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 @@ -239,6 +239,7 @@ def __init__(
"v2.create_open_api": False,
"v2.delete_open_api": False,
"v2.get_open_api": False,
"v2.list_ap_is": False,
"v2.update_open_api": False,
"v2.get_active_billing_dimensions": False,
"v2.get_monthly_cost_attribution": False,
Expand Down
70 changes: 70 additions & 0 deletions src/datadog_api_client/v2/api/api_management_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
unset,
UUID,
)
from datadog_api_client.v2.model.list_ap_is_response import ListAPIsResponse
from datadog_api_client.v2.model.update_open_api_response import UpdateOpenAPIResponse
from datadog_api_client.v2.model.create_open_api_response import CreateOpenAPIResponse

Expand Down Expand Up @@ -93,6 +94,44 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._list_ap_is_endpoint = _Endpoint(
settings={
"response_type": (ListAPIsResponse,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/apicatalog/api",
"operation_id": "list_ap_is",
"http_method": "GET",
"version": "v2",
},
params_map={
"query": {
"openapi_types": (str,),
"attribute": "query",
"location": "query",
},
"page_limit": {
"validation": {
"inclusive_minimum": 1,
},
"openapi_types": (int,),
"attribute": "page[limit]",
"location": "query",
},
"page_offset": {
"validation": {
"inclusive_minimum": 0,
},
"openapi_types": (int,),
"attribute": "page[offset]",
"location": "query",
},
},
headers_map={
"accept": ["application/json"],
},
api_client=api_client,
)

self._update_open_api_endpoint = _Endpoint(
settings={
"response_type": (UpdateOpenAPIResponse,),
Expand Down Expand Up @@ -175,6 +214,37 @@ def get_open_api(

return self._get_open_api_endpoint.call_with_http_info(**kwargs)

def list_ap_is(
self,
*,
query: Union[str, UnsetType] = unset,
page_limit: Union[int, UnsetType] = unset,
page_offset: Union[int, UnsetType] = unset,
) -> ListAPIsResponse:
"""List APIs.

List APIs and their IDs.

:param query: Filter APIs by name
:type query: str, optional
:param page_limit: Number of items per page.
:type page_limit: int, optional
:param page_offset: Offset for pagination.
:type page_offset: int, optional
:rtype: ListAPIsResponse
"""
kwargs: Dict[str, Any] = {}
if query is not unset:
kwargs["query"] = query

if page_limit is not unset:
kwargs["page_limit"] = page_limit

if page_offset is not unset:
kwargs["page_offset"] = page_offset

return self._list_ap_is_endpoint.call_with_http_info(**kwargs)

def update_open_api(
self,
id: UUID,
Expand Down
56 changes: 56 additions & 0 deletions src/datadog_api_client/v2/model/list_ap_is_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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.list_ap_is_response_data import ListAPIsResponseData
from datadog_api_client.v2.model.list_ap_is_response_meta import ListAPIsResponseMeta


class ListAPIsResponse(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.list_ap_is_response_data import ListAPIsResponseData
from datadog_api_client.v2.model.list_ap_is_response_meta import ListAPIsResponseMeta

return {
"data": ([ListAPIsResponseData],),
"meta": (ListAPIsResponseMeta,),
}

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

def __init__(
self_,
data: Union[List[ListAPIsResponseData], UnsetType] = unset,
meta: Union[ListAPIsResponseMeta, UnsetType] = unset,
**kwargs,
):
"""
Response for ``ListAPIs``.

:param data: List of API items.
:type data: [ListAPIsResponseData], optional

:param meta: Metadata for ``ListAPIsResponse``.
:type meta: ListAPIsResponseMeta, optional
"""
if data is not unset:
kwargs["data"] = data
if meta is not unset:
kwargs["meta"] = meta
super().__init__(kwargs)
44 changes: 44 additions & 0 deletions src/datadog_api_client/v2/model/list_ap_is_response_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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,
UUID,
)


class ListAPIsResponseData(ModelNormal):
@cached_property
def openapi_types(_):
return {
"id": (UUID,),
"name": (str,),
}

attribute_map = {
"id": "id",
"name": "name",
}

def __init__(self_, id: Union[UUID, UnsetType] = unset, name: Union[str, UnsetType] = unset, **kwargs):
"""
Data envelope for ``ListAPIsResponse``.

:param id: API identifier.
:type id: UUID, optional

:param name: API name.
:type name: str, optional
"""
if id is not unset:
kwargs["id"] = id
if name is not unset:
kwargs["name"] = name
super().__init__(kwargs)
Loading
Loading