"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from .observabilityfilterrulesconfig import ( ObservabilityFilterRulesConfig, ObservabilityFilterRulesConfigTypedDict, ) from openrouter.types import ( BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL, UnrecognizedStr, ) from pydantic import model_serializer from typing import Any, Dict, List, Literal, Optional, Union from typing_extensions import NotRequired, TypedDict CreateObservabilityDestinationRequestType = Union[ Literal[ "arize", "braintrust", "clickhouse", "datadog", "grafana", "langfuse", "langsmith", "newrelic", "opik", "otel-collector", "posthog", "ramp", "s3", "sentry", "snowflake", "weave", "webhook", ], UnrecognizedStr, ] r"""The destination type. Only stable destination types are accepted.""" class CreateObservabilityDestinationRequestTypedDict(TypedDict): config: Dict[str, Nullable[Any]] r"""Provider-specific configuration. The shape depends on `type` and is validated server-side.""" name: str r"""Human-readable name for the destination.""" type: CreateObservabilityDestinationRequestType r"""The destination type. Only stable destination types are accepted.""" api_key_hashes: NotRequired[Nullable[List[str]]] r"""Optional allowlist of OpenRouter API key hashes whose traffic is forwarded. `null` or omitted means all keys. Must contain at least one hash if provided.""" enabled: NotRequired[bool] r"""Whether this destination should be enabled immediately.""" filter_rules: NotRequired[Nullable[ObservabilityFilterRulesConfigTypedDict]] r"""Optional structured filter rules controlling which events are forwarded.""" privacy_mode: NotRequired[bool] r"""When true, request/response bodies are not forwarded — only metadata.""" sampling_rate: NotRequired[float] r"""Sampling rate between 0.0001 and 1 (1 = 100%).""" workspace_id: NotRequired[str] r"""Optional workspace ID. Defaults to the authenticated entity's default workspace.""" class CreateObservabilityDestinationRequest(BaseModel): config: Dict[str, Nullable[Any]] r"""Provider-specific configuration. The shape depends on `type` and is validated server-side.""" name: str r"""Human-readable name for the destination.""" type: CreateObservabilityDestinationRequestType r"""The destination type. Only stable destination types are accepted.""" api_key_hashes: OptionalNullable[List[str]] = UNSET r"""Optional allowlist of OpenRouter API key hashes whose traffic is forwarded. `null` or omitted means all keys. Must contain at least one hash if provided.""" enabled: Optional[bool] = True r"""Whether this destination should be enabled immediately.""" filter_rules: OptionalNullable[ObservabilityFilterRulesConfig] = UNSET r"""Optional structured filter rules controlling which events are forwarded.""" privacy_mode: Optional[bool] = False r"""When true, request/response bodies are not forwarded — only metadata.""" sampling_rate: Optional[float] = None r"""Sampling rate between 0.0001 and 1 (1 = 100%).""" workspace_id: Optional[str] = None r"""Optional workspace ID. Defaults to the authenticated entity's default workspace.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "api_key_hashes", "enabled", "filter_rules", "privacy_mode", "sampling_rate", "workspace_id", ] ) nullable_fields = set(["api_key_hashes", "filter_rules"]) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) is_nullable_and_explicitly_set = ( k in nullable_fields and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member ) if val != UNSET_SENTINEL: if ( val is not None or k not in optional_fields or is_nullable_and_explicitly_set ): m[k] = val return m