1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

111 lines
3.6 KiB
Python
Raw Normal View History

2020-01-21 02:38:04 -07:00
"""Configuration for API docs feature."""
2020-02-03 02:35:11 -07:00
# Third Party
from pydantic import Field, HttpUrl, StrictStr, StrictBool, constr
2020-01-20 10:19:27 -07:00
2020-02-03 02:35:11 -07:00
# Project
2020-04-16 09:29:57 -07:00
from hyperglass.models import AnyUri, HyperglassModel
2020-01-20 10:19:27 -07:00
DocsMode = constr(regex=r"(swagger|redoc)")
2020-01-20 10:19:27 -07:00
2020-04-16 09:29:57 -07:00
class EndpointConfig(HyperglassModel):
2020-02-01 12:50:12 -10:00
"""Validation model for per API endpoint documentation."""
2020-02-01 16:11:01 -10:00
title: StrictStr = Field(
...,
title="Endpoint Title",
description="Displayed as the header text above the API endpoint section.",
)
description: StrictStr = Field(
...,
title="Endpoint Description",
description="Displayed inside each API endpoint section.",
)
summary: StrictStr = Field(
...,
title="Endpoint Summary",
description="Displayed beside the API endpoint URI.",
)
2020-02-01 12:50:12 -10:00
2020-01-20 10:19:27 -07:00
class Docs(HyperglassModel):
2020-01-28 08:59:27 -07:00
"""Validation model for params.docs."""
2020-01-20 10:19:27 -07:00
2020-02-01 16:11:01 -10:00
enable: StrictBool = Field(
True, title="Enable", description="Enable or disable API documentation."
)
mode: DocsMode = Field(
2020-02-03 02:35:11 -07:00
"redoc",
2020-02-01 16:11:01 -10:00
title="Docs Mode",
description="OpenAPI UI library to use for the hyperglass API docs. Currently, the options are [Swagger UI](/fixme) and [Redoc](/fixme).",
)
2020-02-03 02:35:11 -07:00
base_url: HttpUrl = Field(
"https://lg.example.net",
title="Base URL",
description="Base URL used in request samples.",
)
2020-02-01 16:11:01 -10:00
uri: AnyUri = Field(
"/api/docs",
title="URI",
description="HTTP URI/path where API documentation can be accessed.",
)
openapi_uri: AnyUri = Field(
"/openapi.json",
title="OpenAPI URI",
description="Path to the automatically generated `openapi.json` file.",
)
2020-02-03 02:35:11 -07:00
title: StrictStr = Field(
"{site_title} API Documentation",
title="Title",
description="API documentation title. `{site_title}` may be used to display the `site_title` parameter.",
)
description: StrictStr = Field(
"",
title="Description",
description="API documentation description appearing below the title.",
)
2020-02-01 16:11:01 -10:00
query: EndpointConfig = EndpointConfig(
title="Submit Query",
description="Request a query response per-location.",
summary="Query the Looking Glass",
)
2020-02-01 12:50:12 -10:00
devices: EndpointConfig = EndpointConfig(
title="Devices",
description="List of all devices/locations with associated identifiers, display names, networks, & VRFs.",
summary="Devices List",
)
queries: EndpointConfig = EndpointConfig(
title="Supported Queries",
description="List of supported query types.",
summary="Query Types",
)
2020-04-18 11:34:23 -07:00
communities: EndpointConfig = EndpointConfig(
title="BGP Communities",
description="List of BGP communities.",
summary="BGP Communities List",
)
2020-02-01 16:11:01 -10:00
class Config:
"""Pydantic model configuration."""
title = "API Docs"
description = "API documentation configuration parameters"
fields = {
"query": {
"title": "Query API Endpoint",
"description": "`/api/query/` API documentation options.",
},
"devices": {
"title": "Devices API Endpoint",
"description": "`/api/devices` API documentation options.",
},
"queries": {
"title": "Queries API Endpoint",
"description": "`/api/devices` API documentation options.",
},
2020-04-18 11:34:23 -07:00
"communities": {
"title": "BGP Communities API Endpoint",
"description": "`/api/communities` API documentation options.",
},
2020-02-01 16:11:01 -10:00
}