Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

opensearch_config.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from enum import Enum
  2. from typing import Literal
  3. from pydantic import Field, PositiveInt
  4. from pydantic_settings import BaseSettings
  5. class OpenSearchConfig(BaseSettings):
  6. """
  7. Configuration settings for OpenSearch
  8. """
  9. class AuthMethod(Enum):
  10. """
  11. Authentication method for OpenSearch
  12. """
  13. BASIC = "basic"
  14. AWS_MANAGED_IAM = "aws_managed_iam"
  15. OPENSEARCH_HOST: str | None = Field(
  16. description="Hostname or IP address of the OpenSearch server (e.g., 'localhost' or 'opensearch.example.com')",
  17. default=None,
  18. )
  19. OPENSEARCH_PORT: PositiveInt = Field(
  20. description="Port number on which the OpenSearch server is listening (default is 9200)",
  21. default=9200,
  22. )
  23. OPENSEARCH_SECURE: bool = Field(
  24. description="Whether to use SSL/TLS encrypted connection for OpenSearch (True for HTTPS, False for HTTP)",
  25. default=False,
  26. )
  27. OPENSEARCH_VERIFY_CERTS: bool = Field(
  28. description="Whether to verify SSL certificates for HTTPS connections (recommended to set True in production)",
  29. default=True,
  30. )
  31. OPENSEARCH_AUTH_METHOD: AuthMethod = Field(
  32. description="Authentication method for OpenSearch connection (default is 'basic')",
  33. default=AuthMethod.BASIC,
  34. )
  35. OPENSEARCH_USER: str | None = Field(
  36. description="Username for authenticating with OpenSearch",
  37. default=None,
  38. )
  39. OPENSEARCH_PASSWORD: str | None = Field(
  40. description="Password for authenticating with OpenSearch",
  41. default=None,
  42. )
  43. OPENSEARCH_AWS_REGION: str | None = Field(
  44. description="AWS region for OpenSearch (e.g. 'us-west-2')",
  45. default=None,
  46. )
  47. OPENSEARCH_AWS_SERVICE: Literal["es", "aoss"] | None = Field(
  48. description="AWS service for OpenSearch (e.g. 'aoss' for OpenSearch Serverless)", default=None
  49. )