|
| 1 | +# SPDX-FileCopyrightText: 2023-2024 MTS PJSC |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +from typing import Literal |
| 5 | + |
| 6 | +from pydantic import BaseModel, Field |
| 7 | + |
| 8 | +from syncmaster.schemas.v1.auth.iceberg_rest_basic import ( |
| 9 | + CreateIcebergRESTCatalogBasicAuthSchema, |
| 10 | + ReadIcebergRESTCatalogBasicAuthSchema, |
| 11 | + UpdateIcebergRESTCatalogBasicAuthSchema, |
| 12 | +) |
| 13 | +from syncmaster.schemas.v1.connection_types import ICEBERG_TYPE |
| 14 | +from syncmaster.schemas.v1.connections.connection_base import ( |
| 15 | + CreateConnectionBaseSchema, |
| 16 | + ReadConnectionBaseSchema, |
| 17 | +) |
| 18 | + |
| 19 | + |
| 20 | +class CreateIcebergRESTCatalogS3ConnectionDataSchema(BaseModel): |
| 21 | + metastore_url: str |
| 22 | + s3_warehouse_path: str |
| 23 | + s3_host: str |
| 24 | + s3_port: int | None = None |
| 25 | + s3_protocol: Literal["http", "https"] = "https" |
| 26 | + s3_bucket: str |
| 27 | + s3_region: str |
| 28 | + s3_path_style_access: bool = False |
| 29 | + |
| 30 | + |
| 31 | +class ReadIcebergRESTCatalogS3ConnectionDataSchema(BaseModel): |
| 32 | + metastore_url: str |
| 33 | + s3_warehouse_path: str |
| 34 | + s3_host: str |
| 35 | + s3_port: int | None = None |
| 36 | + s3_protocol: Literal["http", "https"] = "https" |
| 37 | + s3_bucket: str |
| 38 | + s3_region: str |
| 39 | + s3_path_style_access: bool = False |
| 40 | + |
| 41 | + |
| 42 | +class CreateIcebergConnectionSchema(CreateConnectionBaseSchema): |
| 43 | + type: ICEBERG_TYPE = Field(description="Connection type") |
| 44 | + data: CreateIcebergRESTCatalogS3ConnectionDataSchema = Field( |
| 45 | + ..., |
| 46 | + alias="connection_data", |
| 47 | + description=( |
| 48 | + "Data required to connect to the database. These are the parameters that are specified in the URL request." |
| 49 | + ), |
| 50 | + ) |
| 51 | + auth_data: CreateIcebergRESTCatalogBasicAuthSchema = Field( |
| 52 | + description="Credentials for authorization", |
| 53 | + ) |
| 54 | + |
| 55 | + |
| 56 | +class ReadIcebergConnectionSchema(ReadConnectionBaseSchema): |
| 57 | + type: ICEBERG_TYPE |
| 58 | + data: ReadIcebergRESTCatalogS3ConnectionDataSchema = Field(alias="connection_data") |
| 59 | + auth_data: ReadIcebergRESTCatalogBasicAuthSchema | None = None |
| 60 | + |
| 61 | + |
| 62 | +class UpdateIcebergConnectionSchema(CreateIcebergConnectionSchema): |
| 63 | + auth_data: UpdateIcebergRESTCatalogBasicAuthSchema = Field( |
| 64 | + description="Credentials for authorization", |
| 65 | + ) |
0 commit comments