|
| 1 | +"""Models for connector metadata.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from enum import Enum |
| 6 | +from typing import Optional |
| 7 | + |
| 8 | +from pydantic import BaseModel, Field |
| 9 | + |
| 10 | + |
| 11 | +class ConnectorLanguage(str, Enum): |
| 12 | + """Connector implementation language.""" |
| 13 | + |
| 14 | + PYTHON = "python" |
| 15 | + JAVA = "java" |
| 16 | + LOW_CODE = "low-code" |
| 17 | + MANIFEST_ONLY = "manifest-only" |
| 18 | + UNKNOWN = "unknown" |
| 19 | + |
| 20 | + |
| 21 | +class ConnectorBuildOptions(BaseModel): |
| 22 | + """Connector build options from metadata.yaml.""" |
| 23 | + |
| 24 | + model_config = {"extra": "allow"} |
| 25 | + |
| 26 | + baseImage: Optional[str] = Field( |
| 27 | + None, description="Base image to use for building the connector" |
| 28 | + ) |
| 29 | + path: Optional[str] = Field( |
| 30 | + None, description="Path to the connector code within the repository" |
| 31 | + ) |
| 32 | + |
| 33 | + |
| 34 | +class ConnectorMetadata(BaseModel): |
| 35 | + """Connector metadata from metadata.yaml.""" |
| 36 | + |
| 37 | + model_config = {"extra": "allow"} |
| 38 | + |
| 39 | + dockerRepository: str = Field(..., description="Docker repository for the connector image") |
| 40 | + dockerImageTag: str = Field(..., description="Docker image tag for the connector") |
| 41 | + language: Optional[ConnectorLanguage] = Field( |
| 42 | + None, description="Language of the connector implementation" |
| 43 | + ) |
| 44 | + connectorBuildOptions: Optional[ConnectorBuildOptions] = Field( |
| 45 | + None, description="Options for building the connector" |
| 46 | + ) |
| 47 | + |
| 48 | + |
| 49 | +class MetadataFile(BaseModel): |
| 50 | + """Represents the structure of a metadata.yaml file.""" |
| 51 | + |
| 52 | + model_config = {"extra": "allow"} |
| 53 | + |
| 54 | + data: ConnectorMetadata = Field(..., description="Connector metadata") |
0 commit comments