mirror of
https://github.com/apidoorman/doorman.git
synced 2026-04-26 02:28:54 -05:00
201 lines
7.6 KiB
Python
201 lines
7.6 KiB
Python
"""
|
|
The contents of this file are property of Doorman Dev, LLC
|
|
Review the Apache License 2.0 for valid authorization of use
|
|
See https://github.com/pypeople-dev/doorman for more information
|
|
"""
|
|
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class UpdateApiModel(BaseModel):
|
|
api_name: str | None = Field(
|
|
None, min_length=1, max_length=25, description='Name of the API', example='customer'
|
|
)
|
|
api_version: str | None = Field(
|
|
None, min_length=1, max_length=8, description='Version of the API', example='v1'
|
|
)
|
|
api_description: str | None = Field(
|
|
None,
|
|
max_length=127,
|
|
description='Description of the API',
|
|
example='New customer onboarding API',
|
|
)
|
|
api_allowed_roles: list[str] | None = Field(
|
|
None, description='Allowed user roles for the API', example=['admin', 'user']
|
|
)
|
|
api_allowed_groups: list[str] | None = Field(
|
|
None, description='Allowed user groups for the API', example=['admin', 'client-1-group']
|
|
)
|
|
api_servers: list[str] | None = Field(
|
|
None,
|
|
description='List of backend servers for the API',
|
|
example=['http://localhost:8080', 'http://localhost:8081'],
|
|
)
|
|
api_type: str | None = Field(
|
|
None, description="Type of the API. Valid values: 'REST', 'SOAP', 'GRAPHQL', 'GRPC'", example='REST'
|
|
)
|
|
api_authorization_field_swap: str | None = Field(
|
|
None,
|
|
description='Header to swap for backend authorization header',
|
|
example='backend-auth-header',
|
|
)
|
|
api_allowed_headers: list[str] | None = Field(
|
|
None, description='Allowed headers for the API', example=['Content-Type', 'Authorization']
|
|
)
|
|
api_allowed_retry_count: int | None = Field(
|
|
None, description='Number of allowed retries for the API', example=0
|
|
)
|
|
api_grpc_package: str | None = Field(
|
|
None,
|
|
description='Optional gRPC Python package to use for this API (e.g., "my.pkg"). When set, overrides request package and default.',
|
|
example='my.pkg',
|
|
)
|
|
api_grpc_allowed_packages: list[str] | None = Field(
|
|
None,
|
|
description='Allow-list of gRPC package/module base names (no dots). If set, requests must match one of these.',
|
|
example=['customer_v1'],
|
|
)
|
|
api_grpc_allowed_services: list[str] | None = Field(
|
|
None,
|
|
description='Allow-list of gRPC service names (e.g., Greeter). If set, only these services are permitted.',
|
|
example=['Greeter'],
|
|
)
|
|
api_grpc_allowed_methods: list[str] | None = Field(
|
|
None,
|
|
description='Allow-list of gRPC methods as Service.Method strings. If set, only these methods are permitted.',
|
|
example=['Greeter.SayHello'],
|
|
)
|
|
api_credits_enabled: bool | None = Field(
|
|
None, description='Enable credit-based authentication for the API', example=True
|
|
)
|
|
api_credit_group: str | None = Field(
|
|
None, description='API credit group for the API credits', example='ai-group-1'
|
|
)
|
|
active: bool | None = Field(None, description='Whether the API is active (enabled)')
|
|
api_id: str | None = Field(
|
|
None, description='Unique identifier for the API, auto-generated', example=None
|
|
)
|
|
api_path: str | None = Field(
|
|
None, description='Unqiue path for the API, auto-generated', example=None
|
|
)
|
|
|
|
api_cors_allow_origins: list[str] | None = Field(
|
|
None,
|
|
description="Allowed origins for CORS (e.g., ['http://localhost:3000']). Use ['*'] to allow all.",
|
|
)
|
|
api_cors_allow_methods: list[str] | None = Field(
|
|
None,
|
|
description="Allowed methods for CORS preflight (e.g., ['GET','POST','PUT','DELETE','OPTIONS'])",
|
|
)
|
|
api_cors_allow_headers: list[str] | None = Field(
|
|
None,
|
|
description="Allowed request headers for CORS preflight (e.g., ['Content-Type','Authorization'])",
|
|
)
|
|
api_cors_allow_credentials: bool | None = Field(
|
|
None, description='Whether to include Access-Control-Allow-Credentials=true in responses'
|
|
)
|
|
api_cors_expose_headers: list[str] | None = Field(
|
|
None,
|
|
description='Response headers to expose to the browser via Access-Control-Expose-Headers',
|
|
)
|
|
|
|
api_public: bool | None = Field(
|
|
None, description='If true, this API can be called without authentication or subscription'
|
|
)
|
|
|
|
api_auth_required: bool | None = Field(
|
|
None,
|
|
description='If true (default), JWT auth is required for this API when not public. If false, requests may be unauthenticated but must meet other checks as configured.',
|
|
)
|
|
|
|
api_ip_mode: str | None = Field(None, description="IP policy mode: 'allow_all' or 'whitelist'")
|
|
api_ip_whitelist: list[str] | None = Field(
|
|
None, description='Allowed IPs/CIDRs when api_ip_mode=whitelist'
|
|
)
|
|
api_ip_blacklist: list[str] | None = Field(
|
|
None, description='IPs/CIDRs denied regardless of mode'
|
|
)
|
|
api_trust_x_forwarded_for: bool | None = Field(
|
|
None, description='Override: trust X-Forwarded-For for this API'
|
|
)
|
|
|
|
# Request/Response Transformation
|
|
api_request_transform: dict | None = Field(
|
|
None,
|
|
description='Request transformation config. Supports headers, body (JSONPath), query transforms.',
|
|
)
|
|
api_response_transform: dict | None = Field(
|
|
None,
|
|
description='Response transformation config. Supports headers, body (JSONPath), status mapping.',
|
|
)
|
|
|
|
# OpenAPI Auto-Discovery
|
|
api_openapi_url: str | None = Field(
|
|
None,
|
|
description='URL path to fetch OpenAPI spec from upstream (e.g., /openapi.json)',
|
|
)
|
|
api_openapi_auto_discover: bool | None = Field(
|
|
None,
|
|
description='If true, automatically discover and sync endpoints from upstream OpenAPI spec',
|
|
)
|
|
|
|
# SOAP/WSDL Configuration
|
|
api_wsdl_url: str | None = Field(
|
|
None,
|
|
description='URL to fetch WSDL from upstream (e.g., /service?wsdl)',
|
|
)
|
|
api_soap_version: str | None = Field(
|
|
None,
|
|
description='SOAP version: "1.1" or "1.2". If not set, auto-detects from envelope.',
|
|
)
|
|
api_ws_security: dict | None = Field(
|
|
None,
|
|
description='WS-Security configuration for SOAP requests',
|
|
)
|
|
|
|
# GraphQL Configuration
|
|
api_graphql_max_depth: int | None = Field(
|
|
None,
|
|
description='Maximum allowed query depth for GraphQL queries',
|
|
)
|
|
api_graphql_schema_url: str | None = Field(
|
|
None,
|
|
description='GraphQL endpoint path for introspection',
|
|
)
|
|
api_graphql_subscriptions: bool | None = Field(
|
|
None,
|
|
description='Enable WebSocket subscription proxy for this API',
|
|
)
|
|
|
|
# gRPC Configuration
|
|
api_grpc_web_enabled: bool | None = Field(
|
|
None,
|
|
description='Enable gRPC-Web proxy for browser clients',
|
|
)
|
|
api_grpc_reflection_url: str | None = Field(
|
|
None,
|
|
description='Upstream URL for gRPC Server Reflection',
|
|
)
|
|
|
|
api_is_crud: bool | None = Field(
|
|
None,
|
|
description='If true, this API is a CRUD builder API and stores data in Doorman database',
|
|
)
|
|
api_crud_collection: str | None = Field(
|
|
None,
|
|
description='Dynamic collection name for custom CRUD data',
|
|
example='crud_data_my_collection',
|
|
)
|
|
api_crud_schema: Optional[dict] = Field(
|
|
None,
|
|
description="Schema definition for CRUD validation. Dict of field_name -> rules.",
|
|
)
|
|
api_crud_bindings: Optional[list[dict]] = Field(
|
|
None,
|
|
description='Optional multi-table CRUD bindings with per-resource schema',
|
|
)
|
|
|
|
class Config:
|
|
arbitrary_types_allowed = True
|