| 1 | from datetime import datetime |
| 2 | from typing import Dict |
| 3 | |
| 4 | from pydantic import BaseModel |
| 5 | from pydantic import Field |
| 6 | |
| 7 | |
| 8 | # ! Organization ! # |
| 9 | class GrafanaOrganizationCreation(BaseModel): |
| 10 | message: str = Field( |
| 11 | ..., |
| 12 | description="Message detailing the outcome of the request", |
| 13 | ) |
| 14 | orgId: int = Field(..., description="ID of the created organization") |
| 15 | |
| 16 | |
| 17 | # ! Data Source ! # |
| 18 | class GrafanaSecureJsonData(BaseModel): |
| 19 | basicAuthPassword: str = Field(..., alias="basicAuthPassword") |
| 20 | |
| 21 | |
| 22 | class GrafanaJsonData(BaseModel): |
| 23 | database: str = Field(..., alias="database") |
| 24 | flavor: str = Field(..., alias="flavor") |
| 25 | version: str = Field(..., alias="version") |
| 26 | includeFrozen: bool = Field(False, alias="includeFrozen") |
| 27 | logLevelField: str = Field(..., alias="logLevelField") |
| 28 | logMessageField: str = Field(..., alias="logMessageField") |
| 29 | maxConcurrentShardRequests: int = Field(5, alias="maxConcurrentShardRequests") |
| 30 | timeField: str = Field(..., alias="timeField") |
| 31 | tlsSkipVerify: bool = Field(True, alias="tlsSkipVerify") |
| 32 | dataLinks: list = Field( |
| 33 | [ |
| 34 | { |
| 35 | "field": "^data_vulnerability_cve$", |
| 36 | "url": "https://nvd.nist.gov/vuln/detail", |
| 37 | }, |
| 38 | ], |
| 39 | alias="dataLinks", |
| 40 | ) |
| 41 | |
| 42 | |
| 43 | class GrafanaDatasource(BaseModel): |
| 44 | name: str |
| 45 | type: str |
| 46 | typeName: str = Field(..., alias="typeName") |
| 47 | access: str |
| 48 | url: str |
| 49 | database: str |
| 50 | basicAuth: bool = Field(True, alias="basicAuth") |
| 51 | basicAuthUser: str = Field(..., alias="basicAuthUser") |
| 52 | secureJsonData: GrafanaSecureJsonData |
| 53 | isDefault: bool = Field(False, alias="isDefault") |
| 54 | jsonData: GrafanaJsonData |
| 55 | readOnly: bool = Field(True, alias="readOnly") |
| 56 | |
| 57 | |
| 58 | # ! Datasource Creation Response! # |
| 59 | class DataSourceCreationJsonData(BaseModel): |
| 60 | database: str = Field(..., alias="database") |
| 61 | flavor: str = Field(..., alias="flavor") |
| 62 | includeFrozen: bool = Field(..., alias="includeFrozen") |
| 63 | logLevelField: str = Field(..., alias="logLevelField") |
| 64 | logMessageField: str = Field(..., alias="logMessageField") |
| 65 | maxConcurrentShardRequests: int = Field(..., alias="maxConcurrentShardRequests") |
| 66 | timeField: str = Field(..., alias="timeField") |
| 67 | tlsSkipVerify: bool = Field(..., alias="tlsSkipVerify") |
| 68 | version: str |
| 69 | |
| 70 | |
| 71 | class DataSourceCreationSecureJsonFields(BaseModel): |
| 72 | basicAuthPassword: bool = Field(..., alias="basicAuthPassword") |
| 73 | |
| 74 | |
| 75 | class DataSourceCreationDatasource(BaseModel): |
| 76 | id: int |
| 77 | uid: str |
| 78 | orgId: int = Field(..., alias="orgId") |
| 79 | name: str |
| 80 | type: str |
| 81 | typeLogoUrl: str = Field(..., alias="typeLogoUrl") |
| 82 | access: str |
| 83 | url: str |
| 84 | user: str |
| 85 | database: str |
| 86 | basicAuth: bool = Field(..., alias="basicAuth") |
| 87 | basicAuthUser: str = Field(..., alias="basicAuthUser") |
| 88 | withCredentials: bool = Field(..., alias="withCredentials") |
| 89 | isDefault: bool = Field(..., alias="isDefault") |
| 90 | jsonData: DataSourceCreationJsonData |
| 91 | secureJsonFields: DataSourceCreationSecureJsonFields = Field( |
| 92 | ..., |
| 93 | alias="secureJsonFields", |
| 94 | ) |
| 95 | version: int |
| 96 | readOnly: bool = Field(..., alias="readOnly") |
| 97 | |
| 98 | |
| 99 | class GrafanaDataSourceCreationResponse(BaseModel): |
| 100 | datasource: DataSourceCreationDatasource |
| 101 | id: int |
| 102 | message: str |
| 103 | name: str |
| 104 | |
| 105 | |
| 106 | # ! Folder Creation Response! # |
| 107 | class GrafanaFolderCreationResponse(BaseModel): |
| 108 | id: int |
| 109 | uid: str |
| 110 | title: str |
| 111 | url: str |
| 112 | hasAcl: bool = Field(..., alias="hasAcl") |
| 113 | canSave: bool = Field(..., alias="canSave") |
| 114 | canEdit: bool = Field(..., alias="canEdit") |
| 115 | canAdmin: bool = Field(..., alias="canAdmin") |
| 116 | canDelete: bool = Field(..., alias="canDelete") |
| 117 | createdBy: str = Field(..., alias="createdBy") |
| 118 | created: datetime |
| 119 | updatedBy: str = Field(..., alias="updatedBy") |
| 120 | updated: datetime |
| 121 | version: int |
| 122 | |
| 123 | |
| 124 | # ! OpenSearch Version ! # |
| 125 | class NodeInfo(BaseModel): |
| 126 | version: str |
| 127 | |
| 128 | |
| 129 | class NodesVersionResponse(BaseModel): |
| 130 | nodes: Dict[str, NodeInfo] |