diff --git a/sdk-endpoints.txt b/sdk-endpoints.txt index bc140282..1db18b5d 100644 --- a/sdk-endpoints.txt +++ b/sdk-endpoints.txt @@ -69,6 +69,10 @@ POST /api/v1/audio/speech POST /api/v1/audio/transcriptions [excluded] +# The RFC 7523 token exchange the Anthropic SDKs and Claude Code already speak +# when ANTHROPIC_BASE_URL points at Otari. A client that wants workload identity +# uses that implementation; an Otari SDK wrapper would be a second one. +POST /api/v1/oauth/token # protocol endpoint, spoken by the Anthropic SDKs GET /api/v1/models/{model_id} # redundant, list_models covers discovery # Caller-orchestrated MCP is public, but no SDK shell wraps it yet. Typed # mcp.list_tools and mcp.execute methods are the next step for the SDKs, and @@ -124,6 +128,19 @@ POST /api/v1/provider-endpoints # not yet wrapped GET /api/v1/provider-endpoints/{endpoint_id} # not yet wrapped PATCH /api/v1/provider-endpoints/{endpoint_id} # not yet wrapped DELETE /api/v1/provider-endpoints/{endpoint_id} # not yet wrapped +# Hosted providers (the deployment's own upstream credentials, operator-only) +GET /api/v1/hosted-providers # dashboard-only +POST /api/v1/hosted-providers # dashboard-only +GET /api/v1/hosted-providers/refresh/preview # dashboard-only +POST /api/v1/hosted-providers/refresh # dashboard-only +PATCH /api/v1/hosted-providers/{provider} # dashboard-only +DELETE /api/v1/hosted-providers/{provider} # dashboard-only +GET /api/v1/hosted-providers/{provider}/models # dashboard-only +POST /api/v1/hosted-providers/{provider}/models # dashboard-only +POST /api/v1/hosted-providers/{provider}/models/refresh # dashboard-only +GET /api/v1/hosted-providers/{provider}/available-models # dashboard-only +PATCH /api/v1/hosted-providers/{provider}/models/{model_id} # dashboard-only +DELETE /api/v1/hosted-providers/{provider}/models/{model_id} # dashboard-only # Provider credentials (runtime provider management) GET /api/v1/provider-credentials # not yet wrapped POST /api/v1/provider-credentials # not yet wrapped @@ -172,6 +189,9 @@ PATCH /api/v1/keys/{key_id}/end-users # not yet wrapped GET /api/v1/keys/{key_id}/end-users/{external_id} # not yet wrapped PUT /api/v1/keys/{key_id}/end-users/{external_id} # not yet wrapped PATCH /api/v1/keys/{key_id}/end-users/{external_id} # not yet wrapped +POST /api/v1/keys/{key_id}/federation-rules # not yet wrapped +GET /api/v1/keys/{key_id}/federation-rules # not yet wrapped +DELETE /api/v1/keys/{key_id}/federation-rules/{rule_id} # not yet wrapped # A service key managing its own end users, authenticated with that key GET /api/v1/end-users # not yet wrapped PUT /api/v1/end-users # not yet wrapped @@ -316,6 +336,7 @@ POST /api/v1/admin/users/{user_id}/password-link # dashboard-only POST /api/v1/organizations # dashboard-only GET /api/v1/organizations/me # dashboard-only PATCH /api/v1/organizations/me # dashboard-only +DELETE /api/v1/organizations/me # dashboard-only GET /api/v1/organizations/me/memberships # dashboard-only POST /api/v1/organizations/me/switch # dashboard-only GET /api/v1/organizations/me/members # dashboard-only @@ -354,6 +375,7 @@ DELETE /api/v1/organizations/me/routing-policies/{name} # dashboard-only GET /api/v1/organizations/me/aliases # dashboard-only POST /api/v1/organizations/me/aliases # dashboard-only DELETE /api/v1/organizations/me/aliases/{name} # dashboard-only +GET /api/v1/organizations/me/automatic-fallbacks # dashboard-only # The member's own keys (otari-ai#1941), excluded for the same reason as the # usage reads above: scoped by the caller's dashboard session, which an SDK # caller does not hold. @@ -444,6 +466,7 @@ DELETE /api/v1/organizations/me/provider-keys/{key_id} # POST /api/v1/organizations/me/provider-keys/{key_id}/archive # dashboard-only POST /api/v1/organizations/me/provider-keys/{key_id}/restore # dashboard-only POST /api/v1/organizations/me/provider-keys/{key_id}/default # dashboard-only +DELETE /api/v1/organizations/me/provider-keys/{key_id}/default # dashboard-only # The models offered on one of those keys, their rates and their serving # switches (otari#643 follow-up). Same surface, same reason: an SDK caller sends # a model and a key, and which of an organization's adopted models are served diff --git a/src/otari/_client/__init__.py b/src/otari/_client/__init__.py index 375c6af2..440127d2 100644 --- a/src/otari/_client/__init__.py +++ b/src/otari/_client/__init__.py @@ -35,6 +35,7 @@ "FilesApi", "HealthApi", "HooksApi", + "HostedProvidersApi", "ImagesApi", "InvitationsApi", "KeysApi", @@ -43,6 +44,7 @@ "MessagesApi", "ModelsApi", "ModerationsApi", + "OauthApi", "OrganizationBudgetsApi", "OrganizationGuardrailDefinitionsApi", "OrganizationGuardrailsApi", @@ -127,6 +129,8 @@ "AudioSpeechRequest", "AuthenticatePasskeyRequest", "AuthorizeResponse", + "AutomaticFallbackPublic", + "AutomaticFallbacksResponse", "BATCHBatchError", "BATCHBatchRequestCounts", "BATCHBatchUsage", @@ -282,6 +286,11 @@ "ExternalIngestError", "ExternalIngestResult", "ExternalUsageEvent", + "FallbackOfferingPublic", + "FederationRuleCreate", + "FederationRulePublic", + "FederationTokenRequest", + "FederationTokenResponse", "FeedbackSubmission", "GateResultResponse", "GatewaySettings", @@ -292,6 +301,19 @@ "GuardrailProfileSpec", "GuardrailStage", "HTTPValidationError", + "HostedAvailableModelsPublic", + "HostedCatalogKeptGroupPublic", + "HostedCatalogProviderRefreshPublic", + "HostedCatalogRefreshPublic", + "HostedModelCreateRequest", + "HostedModelPublic", + "HostedModelUpdateRequest", + "HostedModelsPublic", + "HostedModelsRefreshPublic", + "HostedProviderCreateRequest", + "HostedProviderPublic", + "HostedProviderUpdateRequest", + "HostedProvidersPublic", "IMGImage", "IMGUsage", "IMGUsageInputTokensDetails", @@ -488,6 +510,7 @@ "NoulCriteria", "NoulQuestion", "OAuthCallbackRequest", + "OAuthErrorResponse", "OAuthSessionResponse", "OfferingUsage", "OpenAIFileDeleted", @@ -765,6 +788,7 @@ from otari._client.api.files_api import FilesApi as FilesApi from otari._client.api.health_api import HealthApi as HealthApi from otari._client.api.hooks_api import HooksApi as HooksApi +from otari._client.api.hosted_providers_api import HostedProvidersApi as HostedProvidersApi from otari._client.api.images_api import ImagesApi as ImagesApi from otari._client.api.invitations_api import InvitationsApi as InvitationsApi from otari._client.api.keys_api import KeysApi as KeysApi @@ -773,6 +797,7 @@ from otari._client.api.messages_api import MessagesApi as MessagesApi from otari._client.api.models_api import ModelsApi as ModelsApi from otari._client.api.moderations_api import ModerationsApi as ModerationsApi +from otari._client.api.oauth_api import OauthApi as OauthApi from otari._client.api.organization_budgets_api import OrganizationBudgetsApi as OrganizationBudgetsApi from otari._client.api.organization_guardrail_definitions_api import OrganizationGuardrailDefinitionsApi as OrganizationGuardrailDefinitionsApi from otari._client.api.organization_guardrails_api import OrganizationGuardrailsApi as OrganizationGuardrailsApi @@ -861,6 +886,8 @@ from otari._client.models.audio_speech_request import AudioSpeechRequest as AudioSpeechRequest from otari._client.models.authenticate_passkey_request import AuthenticatePasskeyRequest as AuthenticatePasskeyRequest from otari._client.models.authorize_response import AuthorizeResponse as AuthorizeResponse +from otari._client.models.automatic_fallback_public import AutomaticFallbackPublic as AutomaticFallbackPublic +from otari._client.models.automatic_fallbacks_response import AutomaticFallbacksResponse as AutomaticFallbacksResponse from otari._client.models.batch_batch_error import BATCHBatchError as BATCHBatchError from otari._client.models.batch_batch_request_counts import BATCHBatchRequestCounts as BATCHBatchRequestCounts from otari._client.models.batch_batch_usage import BATCHBatchUsage as BATCHBatchUsage @@ -1016,6 +1043,11 @@ from otari._client.models.external_ingest_error import ExternalIngestError as ExternalIngestError from otari._client.models.external_ingest_result import ExternalIngestResult as ExternalIngestResult from otari._client.models.external_usage_event import ExternalUsageEvent as ExternalUsageEvent +from otari._client.models.fallback_offering_public import FallbackOfferingPublic as FallbackOfferingPublic +from otari._client.models.federation_rule_create import FederationRuleCreate as FederationRuleCreate +from otari._client.models.federation_rule_public import FederationRulePublic as FederationRulePublic +from otari._client.models.federation_token_request import FederationTokenRequest as FederationTokenRequest +from otari._client.models.federation_token_response import FederationTokenResponse as FederationTokenResponse from otari._client.models.feedback_submission import FeedbackSubmission as FeedbackSubmission from otari._client.models.gate_result_response import GateResultResponse as GateResultResponse from otari._client.models.gateway_settings import GatewaySettings as GatewaySettings @@ -1026,6 +1058,19 @@ from otari._client.models.guardrail_profile_spec import GuardrailProfileSpec as GuardrailProfileSpec from otari._client.models.guardrail_stage import GuardrailStage as GuardrailStage from otari._client.models.http_validation_error import HTTPValidationError as HTTPValidationError +from otari._client.models.hosted_available_models_public import HostedAvailableModelsPublic as HostedAvailableModelsPublic +from otari._client.models.hosted_catalog_kept_group_public import HostedCatalogKeptGroupPublic as HostedCatalogKeptGroupPublic +from otari._client.models.hosted_catalog_provider_refresh_public import HostedCatalogProviderRefreshPublic as HostedCatalogProviderRefreshPublic +from otari._client.models.hosted_catalog_refresh_public import HostedCatalogRefreshPublic as HostedCatalogRefreshPublic +from otari._client.models.hosted_model_create_request import HostedModelCreateRequest as HostedModelCreateRequest +from otari._client.models.hosted_model_public import HostedModelPublic as HostedModelPublic +from otari._client.models.hosted_model_update_request import HostedModelUpdateRequest as HostedModelUpdateRequest +from otari._client.models.hosted_models_public import HostedModelsPublic as HostedModelsPublic +from otari._client.models.hosted_models_refresh_public import HostedModelsRefreshPublic as HostedModelsRefreshPublic +from otari._client.models.hosted_provider_create_request import HostedProviderCreateRequest as HostedProviderCreateRequest +from otari._client.models.hosted_provider_public import HostedProviderPublic as HostedProviderPublic +from otari._client.models.hosted_provider_update_request import HostedProviderUpdateRequest as HostedProviderUpdateRequest +from otari._client.models.hosted_providers_public import HostedProvidersPublic as HostedProvidersPublic from otari._client.models.img_image import IMGImage as IMGImage from otari._client.models.img_usage import IMGUsage as IMGUsage from otari._client.models.img_usage_input_tokens_details import IMGUsageInputTokensDetails as IMGUsageInputTokensDetails @@ -1222,6 +1267,7 @@ from otari._client.models.noul_criteria import NoulCriteria as NoulCriteria from otari._client.models.noul_question import NoulQuestion as NoulQuestion from otari._client.models.o_auth_callback_request import OAuthCallbackRequest as OAuthCallbackRequest +from otari._client.models.o_auth_error_response import OAuthErrorResponse as OAuthErrorResponse from otari._client.models.o_auth_session_response import OAuthSessionResponse as OAuthSessionResponse from otari._client.models.offering_usage import OfferingUsage as OfferingUsage from otari._client.models.open_ai_file_deleted import OpenAIFileDeleted as OpenAIFileDeleted diff --git a/src/otari/_client/api/__init__.py b/src/otari/_client/api/__init__.py index 4514cf4d..485f52e2 100644 --- a/src/otari/_client/api/__init__.py +++ b/src/otari/_client/api/__init__.py @@ -18,6 +18,7 @@ from otari._client.api.files_api import FilesApi from otari._client.api.health_api import HealthApi from otari._client.api.hooks_api import HooksApi +from otari._client.api.hosted_providers_api import HostedProvidersApi from otari._client.api.images_api import ImagesApi from otari._client.api.invitations_api import InvitationsApi from otari._client.api.keys_api import KeysApi @@ -26,6 +27,7 @@ from otari._client.api.messages_api import MessagesApi from otari._client.api.models_api import ModelsApi from otari._client.api.moderations_api import ModerationsApi +from otari._client.api.oauth_api import OauthApi from otari._client.api.organization_budgets_api import OrganizationBudgetsApi from otari._client.api.organization_guardrail_definitions_api import OrganizationGuardrailDefinitionsApi from otari._client.api.organization_guardrails_api import OrganizationGuardrailsApi diff --git a/src/otari/_client/api/catalog_api.py b/src/otari/_client/api/catalog_api.py index c68ae931..0098d8fb 100644 --- a/src/otari/_client/api/catalog_api.py +++ b/src/otari/_client/api/catalog_api.py @@ -341,7 +341,7 @@ def catalog_list_catalog( ) -> CatalogResponse: """List Catalog - The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models at the deployment's rates, and nothing that belongs to a tenant. + The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models every organization reaches, at the deployment's rates, and nothing that belongs to a tenant. :param at_context: Compare prices for a request of this many input tokens: each model's minimum is taken from the pricing tier that request would settle at. Omitted, the base rates compare. :type at_context: int @@ -473,7 +473,7 @@ def catalog_list_catalog_with_http_info( ) -> ApiResponse[CatalogResponse]: """List Catalog - The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models at the deployment's rates, and nothing that belongs to a tenant. + The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models every organization reaches, at the deployment's rates, and nothing that belongs to a tenant. :param at_context: Compare prices for a request of this many input tokens: each model's minimum is taken from the pricing tier that request would settle at. Omitted, the base rates compare. :type at_context: int @@ -605,7 +605,7 @@ def catalog_list_catalog_without_preload_content( ) -> RESTResponseType: """List Catalog - The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models at the deployment's rates, and nothing that belongs to a tenant. + The models this caller may use, one entry each however many providers serve it. Prices are the caller's: an organization's override where one applies, else the deployment's row, else the models.dev default. Aliases and routing policies are not models and are not listed; see Routing. A visitor, where the catalog is public, sees the configured instances and the hosted models every organization reaches, at the deployment's rates, and nothing that belongs to a tenant. :param at_context: Compare prices for a request of this many input tokens: each model's minimum is taken from the pricing tier that request would settle at. Omitted, the base rates compare. :type at_context: int diff --git a/src/otari/_client/api/chat_api.py b/src/otari/_client/api/chat_api.py index 8516e406..857a117c 100644 --- a/src/otari/_client/api/chat_api.py +++ b/src/otari/_client/api/chat_api.py @@ -44,6 +44,7 @@ def chat_chat_completions( self, chat_completion_request: ChatCompletionRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -65,6 +66,8 @@ def chat_chat_completions( :type chat_completion_request: ChatCompletionRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -90,6 +93,7 @@ def chat_chat_completions( _param = self._chat_chat_completions_serialize( chat_completion_request=chat_completion_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -116,6 +120,7 @@ def chat_chat_completions_with_http_info( self, chat_completion_request: ChatCompletionRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -137,6 +142,8 @@ def chat_chat_completions_with_http_info( :type chat_completion_request: ChatCompletionRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -162,6 +169,7 @@ def chat_chat_completions_with_http_info( _param = self._chat_chat_completions_serialize( chat_completion_request=chat_completion_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -188,6 +196,7 @@ def chat_chat_completions_without_preload_content( self, chat_completion_request: ChatCompletionRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -209,6 +218,8 @@ def chat_chat_completions_without_preload_content( :type chat_completion_request: ChatCompletionRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -234,6 +245,7 @@ def chat_chat_completions_without_preload_content( _param = self._chat_chat_completions_serialize( chat_completion_request=chat_completion_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -255,6 +267,7 @@ def _chat_chat_completions_serialize( self, chat_completion_request, idempotency_key, + otari_tags, _request_auth, _content_type, _headers, @@ -280,6 +293,8 @@ def _chat_chat_completions_serialize( # process the header parameters if idempotency_key is not None: _header_params['Idempotency-Key'] = idempotency_key + if otari_tags is not None: + _header_params['Otari-Tags'] = otari_tags # process the form parameters # process the body parameter if chat_completion_request is not None: diff --git a/src/otari/_client/api/hosted_providers_api.py b/src/otari/_client/api/hosted_providers_api.py new file mode 100644 index 00000000..a8649784 --- /dev/null +++ b/src/otari/_client/api/hosted_providers_api.py @@ -0,0 +1,3374 @@ +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictStr +from typing import Optional +from typing_extensions import Annotated +from uuid import UUID +from otari._client.models.hosted_available_models_public import HostedAvailableModelsPublic +from otari._client.models.hosted_catalog_refresh_public import HostedCatalogRefreshPublic +from otari._client.models.hosted_model_create_request import HostedModelCreateRequest +from otari._client.models.hosted_model_public import HostedModelPublic +from otari._client.models.hosted_model_update_request import HostedModelUpdateRequest +from otari._client.models.hosted_models_public import HostedModelsPublic +from otari._client.models.hosted_models_refresh_public import HostedModelsRefreshPublic +from otari._client.models.hosted_provider_create_request import HostedProviderCreateRequest +from otari._client.models.hosted_provider_public import HostedProviderPublic +from otari._client.models.hosted_provider_update_request import HostedProviderUpdateRequest +from otari._client.models.hosted_providers_public import HostedProvidersPublic +from otari._client.models.message import Message + +from otari._client.api_client import ApiClient, RequestSerialized +from otari._client.api_response import ApiResponse +from otari._client.rest import RESTResponseType + + +class HostedProvidersApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def hosted_providers_add_hosted_model( + self, + provider: StrictStr, + hosted_model_create_request: HostedModelCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedModelPublic: + """Add Hosted Model + + Offer a model on a provider, optionally at a custom price. + + :param provider: (required) + :type provider: str + :param hosted_model_create_request: (required) + :type hosted_model_create_request: HostedModelCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_add_hosted_model_serialize( + provider=provider, + hosted_model_create_request=hosted_model_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_add_hosted_model_with_http_info( + self, + provider: StrictStr, + hosted_model_create_request: HostedModelCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedModelPublic]: + """Add Hosted Model + + Offer a model on a provider, optionally at a custom price. + + :param provider: (required) + :type provider: str + :param hosted_model_create_request: (required) + :type hosted_model_create_request: HostedModelCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_add_hosted_model_serialize( + provider=provider, + hosted_model_create_request=hosted_model_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_add_hosted_model_without_preload_content( + self, + provider: StrictStr, + hosted_model_create_request: HostedModelCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Add Hosted Model + + Offer a model on a provider, optionally at a custom price. + + :param provider: (required) + :type provider: str + :param hosted_model_create_request: (required) + :type hosted_model_create_request: HostedModelCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_add_hosted_model_serialize( + provider=provider, + hosted_model_create_request=hosted_model_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_add_hosted_model_serialize( + self, + provider, + hosted_model_create_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if hosted_model_create_request is not None: + _body_params = hosted_model_create_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/hosted-providers/{provider}/models', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_create_hosted_provider( + self, + hosted_provider_create_request: HostedProviderCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedProviderPublic: + """Create Hosted Provider + + Configure a provider with the key this deployment will serve it on. Everything the provider lists on that key is offered at once; a provider that will not say yields a provider with no models, not an error. A provider the configuration defines may be created too, and the stored one then serves instead. + + :param hosted_provider_create_request: (required) + :type hosted_provider_create_request: HostedProviderCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_create_hosted_provider_serialize( + hosted_provider_create_request=hosted_provider_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_create_hosted_provider_with_http_info( + self, + hosted_provider_create_request: HostedProviderCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedProviderPublic]: + """Create Hosted Provider + + Configure a provider with the key this deployment will serve it on. Everything the provider lists on that key is offered at once; a provider that will not say yields a provider with no models, not an error. A provider the configuration defines may be created too, and the stored one then serves instead. + + :param hosted_provider_create_request: (required) + :type hosted_provider_create_request: HostedProviderCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_create_hosted_provider_serialize( + hosted_provider_create_request=hosted_provider_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_create_hosted_provider_without_preload_content( + self, + hosted_provider_create_request: HostedProviderCreateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create Hosted Provider + + Configure a provider with the key this deployment will serve it on. Everything the provider lists on that key is offered at once; a provider that will not say yields a provider with no models, not an error. A provider the configuration defines may be created too, and the stored one then serves instead. + + :param hosted_provider_create_request: (required) + :type hosted_provider_create_request: HostedProviderCreateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_create_hosted_provider_serialize( + hosted_provider_create_request=hosted_provider_create_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_create_hosted_provider_serialize( + self, + hosted_provider_create_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if hosted_provider_create_request is not None: + _body_params = hosted_provider_create_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/hosted-providers', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_delete_hosted_provider( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Message: + """Delete Hosted Provider + + Remove a provider and its roster, leaving the runtime with no hosted path for it. A provider defined in configuration answers 409. A stored provider that overrides a configured one keeps the roster, which the configured one serves again. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_delete_hosted_provider_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_delete_hosted_provider_with_http_info( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Message]: + """Delete Hosted Provider + + Remove a provider and its roster, leaving the runtime with no hosted path for it. A provider defined in configuration answers 409. A stored provider that overrides a configured one keeps the roster, which the configured one serves again. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_delete_hosted_provider_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_delete_hosted_provider_without_preload_content( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Hosted Provider + + Remove a provider and its roster, leaving the runtime with no hosted path for it. A provider defined in configuration answers 409. A stored provider that overrides a configured one keeps the roster, which the configured one serves again. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_delete_hosted_provider_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_delete_hosted_provider_serialize( + self, + provider, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/api/v1/hosted-providers/{provider}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_list_available_models( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedAvailableModelsPublic: + """List Available Models + + Ask the provider what it serves on its credential. Dials the upstream on every call rather than caching: the caller is the admin form's model picker, opened rarely and entitled to a current answer. Failure comes back in the body, so the picker can fall back to a text box. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_available_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedAvailableModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_list_available_models_with_http_info( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedAvailableModelsPublic]: + """List Available Models + + Ask the provider what it serves on its credential. Dials the upstream on every call rather than caching: the caller is the admin form's model picker, opened rarely and entitled to a current answer. Failure comes back in the body, so the picker can fall back to a text box. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_available_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedAvailableModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_list_available_models_without_preload_content( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Available Models + + Ask the provider what it serves on its credential. Dials the upstream on every call rather than caching: the caller is the admin form's model picker, opened rarely and entitled to a current answer. Failure comes back in the body, so the picker can fall back to a text box. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_available_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedAvailableModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_list_available_models_serialize( + self, + provider, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/hosted-providers/{provider}/available-models', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_list_hosted_models( + self, + provider: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedModelsPublic: + """List Hosted Models + + List the models offered on one provider, with the price each currently serves at. + + :param provider: (required) + :type provider: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_models_serialize( + provider=provider, + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_list_hosted_models_with_http_info( + self, + provider: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedModelsPublic]: + """List Hosted Models + + List the models offered on one provider, with the price each currently serves at. + + :param provider: (required) + :type provider: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_models_serialize( + provider=provider, + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_list_hosted_models_without_preload_content( + self, + provider: StrictStr, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Hosted Models + + List the models offered on one provider, with the price each currently serves at. + + :param provider: (required) + :type provider: str + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_models_serialize( + provider=provider, + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_list_hosted_models_serialize( + self, + provider, + skip, + limit, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/hosted-providers/{provider}/models', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_list_hosted_providers( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedProvidersPublic: + """List Hosted Providers + + List the providers this deployment serves hosted inference on. Stored providers and those defined in the configuration's ``hosted_providers:`` block alike, each marked with its ``source``. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_providers_serialize( + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProvidersPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_list_hosted_providers_with_http_info( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedProvidersPublic]: + """List Hosted Providers + + List the providers this deployment serves hosted inference on. Stored providers and those defined in the configuration's ``hosted_providers:`` block alike, each marked with its ``source``. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_providers_serialize( + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProvidersPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_list_hosted_providers_without_preload_content( + self, + skip: Optional[Annotated[int, Field(strict=True, ge=0)]] = None, + limit: Optional[Annotated[int, Field(le=1000, strict=True, ge=1)]] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Hosted Providers + + List the providers this deployment serves hosted inference on. Stored providers and those defined in the configuration's ``hosted_providers:`` block alike, each marked with its ``source``. + + :param skip: + :type skip: int + :param limit: + :type limit: int + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_list_hosted_providers_serialize( + skip=skip, + limit=limit, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProvidersPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_list_hosted_providers_serialize( + self, + skip, + limit, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if skip is not None: + + _query_params.append(('skip', skip)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/hosted-providers', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_preview_catalog_refresh( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedCatalogRefreshPublic: + """Preview Catalog Refresh + + What a catalog sweep would remove, without removing it. A GET, and a truthful one: it writes nothing. It does dial every enabled provider, as ``available-models`` does, because a model the provider still lists would survive the sweep and previewing it as doomed would be a lie. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_preview_catalog_refresh_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_preview_catalog_refresh_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedCatalogRefreshPublic]: + """Preview Catalog Refresh + + What a catalog sweep would remove, without removing it. A GET, and a truthful one: it writes nothing. It does dial every enabled provider, as ``available-models`` does, because a model the provider still lists would survive the sweep and previewing it as doomed would be a lie. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_preview_catalog_refresh_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_preview_catalog_refresh_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Preview Catalog Refresh + + What a catalog sweep would remove, without removing it. A GET, and a truthful one: it writes nothing. It does dial every enabled provider, as ``available-models`` does, because a model the provider still lists would survive the sweep and previewing it as doomed would be a lie. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_preview_catalog_refresh_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_preview_catalog_refresh_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/hosted-providers/refresh/preview', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_refresh_catalog( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedCatalogRefreshPublic: + """Refresh Catalog + + Re-ask every enabled provider what it lists, then take the rest off the catalog. The whole deployment rather than one provider: a stored price is what puts a model on a tenant's Models page, and a price under a provider nothing here serves cannot be reached by a per-provider refresh. A model list whose provider nothing defines any more, such as a removed ``config.yml`` entry, goes too, and is named in ``orphaned_rosters``. Where no provider offers a model, only those lists go and every price stays; with none of them either, the sweep answers 409. Declared before the ``/{provider}`` paths to read in the order the surface is used; no method collides in any case. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_catalog_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_refresh_catalog_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedCatalogRefreshPublic]: + """Refresh Catalog + + Re-ask every enabled provider what it lists, then take the rest off the catalog. The whole deployment rather than one provider: a stored price is what puts a model on a tenant's Models page, and a price under a provider nothing here serves cannot be reached by a per-provider refresh. A model list whose provider nothing defines any more, such as a removed ``config.yml`` entry, goes too, and is named in ``orphaned_rosters``. Where no provider offers a model, only those lists go and every price stays; with none of them either, the sweep answers 409. Declared before the ``/{provider}`` paths to read in the order the surface is used; no method collides in any case. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_catalog_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_refresh_catalog_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Refresh Catalog + + Re-ask every enabled provider what it lists, then take the rest off the catalog. The whole deployment rather than one provider: a stored price is what puts a model on a tenant's Models page, and a price under a provider nothing here serves cannot be reached by a per-provider refresh. A model list whose provider nothing defines any more, such as a removed ``config.yml`` entry, goes too, and is named in ``orphaned_rosters``. Where no provider offers a model, only those lists go and every price stays; with none of them either, the sweep answers 409. Declared before the ``/{provider}`` paths to read in the order the surface is used; no method collides in any case. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_catalog_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedCatalogRefreshPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_refresh_catalog_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/hosted-providers/refresh', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_refresh_hosted_models( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedModelsRefreshPublic: + """Refresh Hosted Models + + Ask the provider again and offer whatever is newly listed. Nothing already offered is removed, even when the provider no longer lists it. New models follow the offer rule, seeded with the community default price and off when nothing prices them. A seeded price nobody changed moves with the default. An offered model whose stored price has since been deleted is seeded again, or switched off where the default does not price it, even one an operator switched on: a refresh never switches a model on. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_hosted_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsRefreshPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_refresh_hosted_models_with_http_info( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedModelsRefreshPublic]: + """Refresh Hosted Models + + Ask the provider again and offer whatever is newly listed. Nothing already offered is removed, even when the provider no longer lists it. New models follow the offer rule, seeded with the community default price and off when nothing prices them. A seeded price nobody changed moves with the default. An offered model whose stored price has since been deleted is seeded again, or switched off where the default does not price it, even one an operator switched on: a refresh never switches a model on. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_hosted_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsRefreshPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_refresh_hosted_models_without_preload_content( + self, + provider: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Refresh Hosted Models + + Ask the provider again and offer whatever is newly listed. Nothing already offered is removed, even when the provider no longer lists it. New models follow the offer rule, seeded with the community default price and off when nothing prices them. A seeded price nobody changed moves with the default. An offered model whose stored price has since been deleted is seeded again, or switched off where the default does not price it, even one an operator switched on: a refresh never switches a model on. + + :param provider: (required) + :type provider: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_refresh_hosted_models_serialize( + provider=provider, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelsRefreshPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_refresh_hosted_models_serialize( + self, + provider, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/hosted-providers/{provider}/models/refresh', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_remove_hosted_model( + self, + provider: StrictStr, + model_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> Message: + """Remove Hosted Model + + Stop offering a model on a provider. Its pricing history stays. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_remove_hosted_model_serialize( + provider=provider, + model_id=model_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_remove_hosted_model_with_http_info( + self, + provider: StrictStr, + model_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[Message]: + """Remove Hosted Model + + Stop offering a model on a provider. Its pricing history stays. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_remove_hosted_model_serialize( + provider=provider, + model_id=model_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_remove_hosted_model_without_preload_content( + self, + provider: StrictStr, + model_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Remove Hosted Model + + Stop offering a model on a provider. Its pricing history stays. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_remove_hosted_model_serialize( + provider=provider, + model_id=model_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "Message", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_remove_hosted_model_serialize( + self, + provider, + model_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + if model_id is not None: + _path_params['model_id'] = model_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/api/v1/hosted-providers/{provider}/models/{model_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_update_hosted_model( + self, + provider: StrictStr, + model_id: UUID, + hosted_model_update_request: HostedModelUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedModelPublic: + """Update Hosted Model + + Reprice one offered model, toggle whether it is served, or both. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param hosted_model_update_request: (required) + :type hosted_model_update_request: HostedModelUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_model_serialize( + provider=provider, + model_id=model_id, + hosted_model_update_request=hosted_model_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_update_hosted_model_with_http_info( + self, + provider: StrictStr, + model_id: UUID, + hosted_model_update_request: HostedModelUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedModelPublic]: + """Update Hosted Model + + Reprice one offered model, toggle whether it is served, or both. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param hosted_model_update_request: (required) + :type hosted_model_update_request: HostedModelUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_model_serialize( + provider=provider, + model_id=model_id, + hosted_model_update_request=hosted_model_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_update_hosted_model_without_preload_content( + self, + provider: StrictStr, + model_id: UUID, + hosted_model_update_request: HostedModelUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update Hosted Model + + Reprice one offered model, toggle whether it is served, or both. + + :param provider: (required) + :type provider: str + :param model_id: (required) + :type model_id: UUID + :param hosted_model_update_request: (required) + :type hosted_model_update_request: HostedModelUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_model_serialize( + provider=provider, + model_id=model_id, + hosted_model_update_request=hosted_model_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedModelPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_update_hosted_model_serialize( + self, + provider, + model_id, + hosted_model_update_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + if model_id is not None: + _path_params['model_id'] = model_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if hosted_model_update_request is not None: + _body_params = hosted_model_update_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='PATCH', + resource_path='/api/v1/hosted-providers/{provider}/models/{model_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def hosted_providers_update_hosted_provider( + self, + provider: StrictStr, + hosted_provider_update_request: HostedProviderUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> HostedProviderPublic: + """Update Hosted Provider + + Rotate the key, repoint the base, or turn a provider off. A provider defined in configuration answers 409: it is changed there. + + :param provider: (required) + :type provider: str + :param hosted_provider_update_request: (required) + :type hosted_provider_update_request: HostedProviderUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_provider_serialize( + provider=provider, + hosted_provider_update_request=hosted_provider_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def hosted_providers_update_hosted_provider_with_http_info( + self, + provider: StrictStr, + hosted_provider_update_request: HostedProviderUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[HostedProviderPublic]: + """Update Hosted Provider + + Rotate the key, repoint the base, or turn a provider off. A provider defined in configuration answers 409: it is changed there. + + :param provider: (required) + :type provider: str + :param hosted_provider_update_request: (required) + :type hosted_provider_update_request: HostedProviderUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_provider_serialize( + provider=provider, + hosted_provider_update_request=hosted_provider_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def hosted_providers_update_hosted_provider_without_preload_content( + self, + provider: StrictStr, + hosted_provider_update_request: HostedProviderUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Update Hosted Provider + + Rotate the key, repoint the base, or turn a provider off. A provider defined in configuration answers 409: it is changed there. + + :param provider: (required) + :type provider: str + :param hosted_provider_update_request: (required) + :type hosted_provider_update_request: HostedProviderUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._hosted_providers_update_hosted_provider_serialize( + provider=provider, + hosted_provider_update_request=hosted_provider_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "HostedProviderPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _hosted_providers_update_hosted_provider_serialize( + self, + provider, + hosted_provider_update_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if provider is not None: + _path_params['provider'] = provider + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if hosted_provider_update_request is not None: + _body_params = hosted_provider_update_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='PATCH', + resource_path='/api/v1/hosted-providers/{provider}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/src/otari/_client/api/keys_api.py b/src/otari/_client/api/keys_api.py index 8332e024..bdee0922 100644 --- a/src/otari/_client/api/keys_api.py +++ b/src/otari/_client/api/keys_api.py @@ -24,6 +24,8 @@ from otari._client.models.end_user_public import EndUserPublic from otari._client.models.end_user_put import EndUserPut from otari._client.models.end_user_update import EndUserUpdate +from otari._client.models.federation_rule_create import FederationRuleCreate +from otari._client.models.federation_rule_public import FederationRulePublic from otari._client.models.key_info import KeyInfo from otari._client.models.update_key_request import UpdateKeyRequest @@ -45,6 +47,299 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client + @validate_call + def keys_create_federation_rule( + self, + key_id: StrictStr, + federation_rule_create: FederationRuleCreate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> FederationRulePublic: + """Create Federation Rule + + Let an OpenID Connect identity token authenticate as this key, in place of its secret. The issuer must be one of the deployment's ``federation_issuers``, else 400. A token authenticates when it is signed by that issuer, its ``aud`` contains ``audience``, and it carries the rule's ``subject`` and verified ``email``, whichever the rule sets. A rule naming the identity of an existing rule answers 409: the same issuer, audience, subject and email on this key, or on another key the same issuer and audience with a subject or email in common and no contradicting value. + + :param key_id: (required) + :type key_id: str + :param federation_rule_create: (required) + :type federation_rule_create: FederationRuleCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_create_federation_rule_serialize( + key_id=key_id, + federation_rule_create=federation_rule_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "FederationRulePublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def keys_create_federation_rule_with_http_info( + self, + key_id: StrictStr, + federation_rule_create: FederationRuleCreate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[FederationRulePublic]: + """Create Federation Rule + + Let an OpenID Connect identity token authenticate as this key, in place of its secret. The issuer must be one of the deployment's ``federation_issuers``, else 400. A token authenticates when it is signed by that issuer, its ``aud`` contains ``audience``, and it carries the rule's ``subject`` and verified ``email``, whichever the rule sets. A rule naming the identity of an existing rule answers 409: the same issuer, audience, subject and email on this key, or on another key the same issuer and audience with a subject or email in common and no contradicting value. + + :param key_id: (required) + :type key_id: str + :param federation_rule_create: (required) + :type federation_rule_create: FederationRuleCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_create_federation_rule_serialize( + key_id=key_id, + federation_rule_create=federation_rule_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "FederationRulePublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def keys_create_federation_rule_without_preload_content( + self, + key_id: StrictStr, + federation_rule_create: FederationRuleCreate, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create Federation Rule + + Let an OpenID Connect identity token authenticate as this key, in place of its secret. The issuer must be one of the deployment's ``federation_issuers``, else 400. A token authenticates when it is signed by that issuer, its ``aud`` contains ``audience``, and it carries the rule's ``subject`` and verified ``email``, whichever the rule sets. A rule naming the identity of an existing rule answers 409: the same issuer, audience, subject and email on this key, or on another key the same issuer and audience with a subject or email in common and no contradicting value. + + :param key_id: (required) + :type key_id: str + :param federation_rule_create: (required) + :type federation_rule_create: FederationRuleCreate + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_create_federation_rule_serialize( + key_id=key_id, + federation_rule_create=federation_rule_create, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': "FederationRulePublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _keys_create_federation_rule_serialize( + self, + key_id, + federation_rule_create, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if key_id is not None: + _path_params['key_id'] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if federation_rule_create is not None: + _body_params = federation_rule_create + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/keys/{key_id}/federation-rules', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def keys_create_key( self, @@ -296,8 +591,288 @@ def _keys_create_key_serialize( ] ) ) - if _default_content_type is not None: - _header_params['Content-Type'] = _default_content_type + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/keys', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def keys_delete_federation_rule( + self, + key_id: StrictStr, + rule_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Delete Federation Rule + + Remove a federation rule. Tokens it matched stop authenticating with the next request. + + :param key_id: (required) + :type key_id: str + :param rule_id: (required) + :type rule_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_delete_federation_rule_serialize( + key_id=key_id, + rule_id=rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def keys_delete_federation_rule_with_http_info( + self, + key_id: StrictStr, + rule_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Delete Federation Rule + + Remove a federation rule. Tokens it matched stop authenticating with the next request. + + :param key_id: (required) + :type key_id: str + :param rule_id: (required) + :type rule_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_delete_federation_rule_serialize( + key_id=key_id, + rule_id=rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def keys_delete_federation_rule_without_preload_content( + self, + key_id: StrictStr, + rule_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Federation Rule + + Remove a federation rule. Tokens it matched stop authenticating with the next request. + + :param key_id: (required) + :type key_id: str + :param rule_id: (required) + :type rule_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_delete_federation_rule_serialize( + key_id=key_id, + rule_id=rule_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _keys_delete_federation_rule_serialize( + self, + key_id, + rule_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if key_id is not None: + _path_params['key_id'] = key_id + if rule_id is not None: + _path_params['rule_id'] = rule_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + # authentication setting _auth_settings: List[str] = [ @@ -306,8 +881,8 @@ def _keys_create_key_serialize( ] return self.api_client.param_serialize( - method='POST', - resource_path='/api/v1/keys', + method='DELETE', + resource_path='/api/v1/keys/{key_id}/federation-rules/{rule_id}', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1500,6 +2075,271 @@ def _keys_list_end_users_serialize( + @validate_call + def keys_list_federation_rules( + self, + key_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> List[FederationRulePublic]: + """List Federation Rules + + List the identities that may authenticate as this key, oldest first. + + :param key_id: (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_list_federation_rules_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[FederationRulePublic]", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def keys_list_federation_rules_with_http_info( + self, + key_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[List[FederationRulePublic]]: + """List Federation Rules + + List the identities that may authenticate as this key, oldest first. + + :param key_id: (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_list_federation_rules_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[FederationRulePublic]", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def keys_list_federation_rules_without_preload_content( + self, + key_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Federation Rules + + List the identities that may authenticate as this key, oldest first. + + :param key_id: (required) + :type key_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._keys_list_federation_rules_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[FederationRulePublic]", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _keys_list_federation_rules_serialize( + self, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if key_id is not None: + _path_params['key_id'] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/keys/{key_id}/federation-rules', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def keys_list_keys( self, diff --git a/src/otari/_client/api/messages_api.py b/src/otari/_client/api/messages_api.py index 7cb5eb90..3924ca0f 100644 --- a/src/otari/_client/api/messages_api.py +++ b/src/otari/_client/api/messages_api.py @@ -324,6 +324,7 @@ def messages_create_message( self, messages_request: MessagesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -345,6 +346,8 @@ def messages_create_message( :type messages_request: MessagesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -370,6 +373,7 @@ def messages_create_message( _param = self._messages_create_message_serialize( messages_request=messages_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -396,6 +400,7 @@ def messages_create_message_with_http_info( self, messages_request: MessagesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -417,6 +422,8 @@ def messages_create_message_with_http_info( :type messages_request: MessagesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -442,6 +449,7 @@ def messages_create_message_with_http_info( _param = self._messages_create_message_serialize( messages_request=messages_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -468,6 +476,7 @@ def messages_create_message_without_preload_content( self, messages_request: MessagesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -489,6 +498,8 @@ def messages_create_message_without_preload_content( :type messages_request: MessagesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -514,6 +525,7 @@ def messages_create_message_without_preload_content( _param = self._messages_create_message_serialize( messages_request=messages_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -535,6 +547,7 @@ def _messages_create_message_serialize( self, messages_request, idempotency_key, + otari_tags, _request_auth, _content_type, _headers, @@ -560,6 +573,8 @@ def _messages_create_message_serialize( # process the header parameters if idempotency_key is not None: _header_params['Idempotency-Key'] = idempotency_key + if otari_tags is not None: + _header_params['Otari-Tags'] = otari_tags # process the form parameters # process the body parameter if messages_request is not None: diff --git a/src/otari/_client/api/models_api.py b/src/otari/_client/api/models_api.py index 6cf1e53d..15b5f9cd 100644 --- a/src/otari/_client/api/models_api.py +++ b/src/otari/_client/api/models_api.py @@ -325,7 +325,7 @@ def models_list_discoverable_models( ) -> DiscoverableModelsResponse: """List Discoverable Models - List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. + List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Covers the configured provider instances and every hosted provider switched on, whatever organization it is restricted to. A hosted provider that a configured instance of the same name shadows is not listed. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. :param refresh: Re-dial every provider instead of answering from the discovery cache. :type refresh: bool @@ -393,7 +393,7 @@ def models_list_discoverable_models_with_http_info( ) -> ApiResponse[DiscoverableModelsResponse]: """List Discoverable Models - List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. + List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Covers the configured provider instances and every hosted provider switched on, whatever organization it is restricted to. A hosted provider that a configured instance of the same name shadows is not listed. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. :param refresh: Re-dial every provider instead of answering from the discovery cache. :type refresh: bool @@ -461,7 +461,7 @@ def models_list_discoverable_models_without_preload_content( ) -> RESTResponseType: """List Discoverable Models - List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. + List every model the configured provider credentials can reach. Operator-facing counterpart to GET /api/v1/models, which serves a curated catalog to API callers. This reports each provider separately and keeps its error, so a provider with a bad key is distinguishable from one with no models. It is operator-gated because a provider error message describes the gateway's own configuration. Covers the configured provider instances and every hosted provider switched on, whatever organization it is restricted to. A hosted provider that a configured instance of the same name shadows is not listed. Answers from the discovery cache, which a background refresher keeps warm, so the call does not wait on a slow or unreachable provider. Each provider carries the ``checked_at`` its result was produced at; a null one has not been dialed yet. Pass ``refresh=true`` to force a live re-dial of every provider. :param refresh: Re-dial every provider instead of answering from the discovery cache. :type refresh: bool diff --git a/src/otari/_client/api/oauth_api.py b/src/otari/_client/api/oauth_api.py new file mode 100644 index 00000000..645c3abe --- /dev/null +++ b/src/otari/_client/api/oauth_api.py @@ -0,0 +1,323 @@ +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from otari._client.models.federation_token_request import FederationTokenRequest +from otari._client.models.federation_token_response import FederationTokenResponse + +from otari._client.api_client import ApiClient, RequestSerialized +from otari._client.api_response import ApiResponse +from otari._client.rest import RESTResponseType + + +class OauthApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def oauth_exchange_token( + self, + federation_token_request: FederationTokenRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> FederationTokenResponse: + """Exchange Token + + Exchange an identity token for an access token (the RFC 7523 ``jwt-bearer`` grant). The identity token must verify against an issuer on ``federation_issuers`` and match the federation rule ``federation_rule_id`` names. ``organization_id``, ``workspace_id`` and ``service_account_id``, where set, must be the UUIDs of the rule's key's organization and workspace and the key's id. The access token authenticates as that key until ``expires_in`` runs out, the rule is deleted or the key stops passing its checks. Every refusal of the identity token answers 401 ``invalid_grant`` with the same description. + + :param federation_token_request: (required) + :type federation_token_request: FederationTokenRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._oauth_exchange_token_serialize( + federation_token_request=federation_token_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FederationTokenResponse", + '400': "OAuthErrorResponse", + '401': "OAuthErrorResponse", + '422': "HTTPValidationError", + '503': "OAuthErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def oauth_exchange_token_with_http_info( + self, + federation_token_request: FederationTokenRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[FederationTokenResponse]: + """Exchange Token + + Exchange an identity token for an access token (the RFC 7523 ``jwt-bearer`` grant). The identity token must verify against an issuer on ``federation_issuers`` and match the federation rule ``federation_rule_id`` names. ``organization_id``, ``workspace_id`` and ``service_account_id``, where set, must be the UUIDs of the rule's key's organization and workspace and the key's id. The access token authenticates as that key until ``expires_in`` runs out, the rule is deleted or the key stops passing its checks. Every refusal of the identity token answers 401 ``invalid_grant`` with the same description. + + :param federation_token_request: (required) + :type federation_token_request: FederationTokenRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._oauth_exchange_token_serialize( + federation_token_request=federation_token_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FederationTokenResponse", + '400': "OAuthErrorResponse", + '401': "OAuthErrorResponse", + '422': "HTTPValidationError", + '503': "OAuthErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def oauth_exchange_token_without_preload_content( + self, + federation_token_request: FederationTokenRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Exchange Token + + Exchange an identity token for an access token (the RFC 7523 ``jwt-bearer`` grant). The identity token must verify against an issuer on ``federation_issuers`` and match the federation rule ``federation_rule_id`` names. ``organization_id``, ``workspace_id`` and ``service_account_id``, where set, must be the UUIDs of the rule's key's organization and workspace and the key's id. The access token authenticates as that key until ``expires_in`` runs out, the rule is deleted or the key stops passing its checks. Every refusal of the identity token answers 401 ``invalid_grant`` with the same description. + + :param federation_token_request: (required) + :type federation_token_request: FederationTokenRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._oauth_exchange_token_serialize( + federation_token_request=federation_token_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "FederationTokenResponse", + '400': "OAuthErrorResponse", + '401': "OAuthErrorResponse", + '422': "HTTPValidationError", + '503': "OAuthErrorResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _oauth_exchange_token_serialize( + self, + federation_token_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if federation_token_request is not None: + _body_params = federation_token_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/oauth/token', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/src/otari/_client/api/organization_pricing_api.py b/src/otari/_client/api/organization_pricing_api.py index 70ec7021..d4b5eef9 100644 --- a/src/otari/_client/api/organization_pricing_api.py +++ b/src/otari/_client/api/organization_pricing_api.py @@ -97,6 +97,8 @@ def organization_pricing_create_organization_pricing( _response_types_map: Dict[str, Optional[str]] = { '201': "OrganizationModelPricingPublic", + '403': None, + '409': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -165,6 +167,8 @@ def organization_pricing_create_organization_pricing_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '201': "OrganizationModelPricingPublic", + '403': None, + '409': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -233,6 +237,8 @@ def organization_pricing_create_organization_pricing_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '201': "OrganizationModelPricingPublic", + '403': None, + '409': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -339,7 +345,7 @@ def organization_pricing_delete_organization_pricing( ) -> None: """Delete Organization Pricing - Remove an override, returning the model to the deployment price list. + Remove an override, returning the model to the deployment price list. Refused with a 403 for a rate the deployment operator set, which only the operator may remove. :param pricing_id: (required) :type pricing_id: UUID @@ -375,6 +381,7 @@ def organization_pricing_delete_organization_pricing( _response_types_map: Dict[str, Optional[str]] = { '204': None, + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -407,7 +414,7 @@ def organization_pricing_delete_organization_pricing_with_http_info( ) -> ApiResponse[None]: """Delete Organization Pricing - Remove an override, returning the model to the deployment price list. + Remove an override, returning the model to the deployment price list. Refused with a 403 for a rate the deployment operator set, which only the operator may remove. :param pricing_id: (required) :type pricing_id: UUID @@ -443,6 +450,7 @@ def organization_pricing_delete_organization_pricing_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '204': None, + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -475,7 +483,7 @@ def organization_pricing_delete_organization_pricing_without_preload_content( ) -> RESTResponseType: """Delete Organization Pricing - Remove an override, returning the model to the deployment price list. + Remove an override, returning the model to the deployment price list. Refused with a 403 for a rate the deployment operator set, which only the operator may remove. :param pricing_id: (required) :type pricing_id: UUID @@ -511,6 +519,7 @@ def organization_pricing_delete_organization_pricing_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '204': None, + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -906,7 +915,7 @@ def organization_pricing_replace_organization_pricing( ) -> OrganizationModelPricingPublic: """Replace Organization Pricing - Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today. + Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today, and with a 403 for a rate the deployment operator set, which only the operator may change. :param pricing_id: (required) :type pricing_id: UUID @@ -945,6 +954,7 @@ def organization_pricing_replace_organization_pricing( _response_types_map: Dict[str, Optional[str]] = { '200': "OrganizationModelPricingPublic", + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -978,7 +988,7 @@ def organization_pricing_replace_organization_pricing_with_http_info( ) -> ApiResponse[OrganizationModelPricingPublic]: """Replace Organization Pricing - Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today. + Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today, and with a 403 for a rate the deployment operator set, which only the operator may change. :param pricing_id: (required) :type pricing_id: UUID @@ -1017,6 +1027,7 @@ def organization_pricing_replace_organization_pricing_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "OrganizationModelPricingPublic", + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1050,7 +1061,7 @@ def organization_pricing_replace_organization_pricing_without_preload_content( ) -> RESTResponseType: """Replace Organization Pricing - Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today. + Replace an override's rates and period. Future requests in the period price at the new rate; usage already settled keeps the cost it was billed, because a settled cost is stored on the usage row rather than recomputed. Refused with a 403 on the same deployment-supplied-model rule the create path carries, so a row stored before that rule existed cannot be edited into a rate nobody could create today, and with a 403 for a rate the deployment operator set, which only the operator may change. :param pricing_id: (required) :type pricing_id: UUID @@ -1089,6 +1100,7 @@ def organization_pricing_replace_organization_pricing_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "OrganizationModelPricingPublic", + '403': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( diff --git a/src/otari/_client/api/organizations_api.py b/src/otari/_client/api/organizations_api.py index 2e59f2f3..7bccdf35 100644 --- a/src/otari/_client/api/organizations_api.py +++ b/src/otari/_client/api/organizations_api.py @@ -1705,6 +1705,262 @@ def _organizations_decline_caller_pending_membership_serialize( + @validate_call + def organizations_delete_active_organization( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> OrganizationMembershipContextPublic: + """Delete Active Organization + + Delete the caller's active organization, if it has no usage, and move the caller out of it. Owners and admins only. Its workspaces, memberships, invitations and organization-level settings go with it. Refused for the deployment's default organization, for the only organization the caller belongs to, and for one whose workspaces still hold usage, API keys, aliases or routing policies, so a deletion never takes spend history with it. Answers with the caller's context in the organization they are moved to, their oldest other one. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._organizations_delete_active_organization_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrganizationMembershipContextPublic", + '400': "OrganizationRefusal", + '403': "OrganizationRefusal", + '409': "OrganizationRefusal", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def organizations_delete_active_organization_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[OrganizationMembershipContextPublic]: + """Delete Active Organization + + Delete the caller's active organization, if it has no usage, and move the caller out of it. Owners and admins only. Its workspaces, memberships, invitations and organization-level settings go with it. Refused for the deployment's default organization, for the only organization the caller belongs to, and for one whose workspaces still hold usage, API keys, aliases or routing policies, so a deletion never takes spend history with it. Answers with the caller's context in the organization they are moved to, their oldest other one. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._organizations_delete_active_organization_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrganizationMembershipContextPublic", + '400': "OrganizationRefusal", + '403': "OrganizationRefusal", + '409': "OrganizationRefusal", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def organizations_delete_active_organization_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Delete Active Organization + + Delete the caller's active organization, if it has no usage, and move the caller out of it. Owners and admins only. Its workspaces, memberships, invitations and organization-level settings go with it. Refused for the deployment's default organization, for the only organization the caller belongs to, and for one whose workspaces still hold usage, API keys, aliases or routing policies, so a deletion never takes spend history with it. Answers with the caller's context in the organization they are moved to, their oldest other one. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._organizations_delete_active_organization_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrganizationMembershipContextPublic", + '400': "OrganizationRefusal", + '403': "OrganizationRefusal", + '409': "OrganizationRefusal", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _organizations_delete_active_organization_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/api/v1/organizations/me', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def organizations_delete_active_organization_domain( self, diff --git a/src/otari/_client/api/pricing_api.py b/src/otari/_client/api/pricing_api.py index 8ec6c2ce..acec0c93 100644 --- a/src/otari/_client/api/pricing_api.py +++ b/src/otari/_client/api/pricing_api.py @@ -870,7 +870,7 @@ def pricing_get_pricing( ) -> PricingResponse: """Get Pricing - Get pricing for a specific model as of a timestamp. + Get pricing for a specific model as of a timestamp. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -909,6 +909,7 @@ def pricing_get_pricing( _response_types_map: Dict[str, Optional[str]] = { '200': "PricingResponse", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -942,7 +943,7 @@ def pricing_get_pricing_with_http_info( ) -> ApiResponse[PricingResponse]: """Get Pricing - Get pricing for a specific model as of a timestamp. + Get pricing for a specific model as of a timestamp. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -981,6 +982,7 @@ def pricing_get_pricing_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "PricingResponse", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1014,7 +1016,7 @@ def pricing_get_pricing_without_preload_content( ) -> RESTResponseType: """Get Pricing - Get pricing for a specific model as of a timestamp. + Get pricing for a specific model as of a timestamp. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -1053,6 +1055,7 @@ def pricing_get_pricing_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "PricingResponse", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1160,7 +1163,7 @@ def pricing_get_pricing_history( ) -> List[PricingResponse]: """Get Pricing History - Return the full pricing history for a model. + Return the full pricing history for a model. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -1196,6 +1199,7 @@ def pricing_get_pricing_history( _response_types_map: Dict[str, Optional[str]] = { '200': "List[PricingResponse]", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1228,7 +1232,7 @@ def pricing_get_pricing_history_with_http_info( ) -> ApiResponse[List[PricingResponse]]: """Get Pricing History - Return the full pricing history for a model. + Return the full pricing history for a model. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -1264,6 +1268,7 @@ def pricing_get_pricing_history_with_http_info( _response_types_map: Dict[str, Optional[str]] = { '200': "List[PricingResponse]", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1296,7 +1301,7 @@ def pricing_get_pricing_history_without_preload_content( ) -> RESTResponseType: """Get Pricing History - Return the full pricing history for a model. + Return the full pricing history for a model. A 404 for a model of a hosted provider restricted to another organization than the caller's. :param model_key: (required) :type model_key: str @@ -1332,6 +1337,7 @@ def pricing_get_pricing_history_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { '200': "List[PricingResponse]", + '404': None, '422': "HTTPValidationError", } response_data = self.api_client.call_api( @@ -1426,7 +1432,7 @@ def pricing_list_current_pricing( ) -> CurrentPricingPage: """List Current Pricing - List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. + List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. A hosted provider restricted to another organization than the caller's is left out of both. :param skip: :type skip: int @@ -1498,7 +1504,7 @@ def pricing_list_current_pricing_with_http_info( ) -> ApiResponse[CurrentPricingPage]: """List Current Pricing - List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. + List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. A hosted provider restricted to another organization than the caller's is left out of both. :param skip: :type skip: int @@ -1570,7 +1576,7 @@ def pricing_list_current_pricing_without_preload_content( ) -> RESTResponseType: """List Current Pricing - List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. + List the rate each priced model is metered at, one row per model key. Listing prices answers the stored history, one row per ``effective_at``, so a page of that is a page of revisions rather than a page of models. This answers one row per key: the newest rate that has taken effect, or the earliest scheduled rate for a key that has none yet. ``count`` is the number of priced models, so a caller can page without reading the collection to learn how long it is. A hosted provider restricted to another organization than the caller's is left out of both. :param skip: :type skip: int @@ -1710,7 +1716,7 @@ def pricing_list_pricing( ) -> List[PricingResponse]: """List Pricing - List all model pricing. + List all model pricing. A hosted provider restricted to another organization than the caller's is left out, as it is from the catalog. :param skip: :type skip: int @@ -1782,7 +1788,7 @@ def pricing_list_pricing_with_http_info( ) -> ApiResponse[List[PricingResponse]]: """List Pricing - List all model pricing. + List all model pricing. A hosted provider restricted to another organization than the caller's is left out, as it is from the catalog. :param skip: :type skip: int @@ -1854,7 +1860,7 @@ def pricing_list_pricing_without_preload_content( ) -> RESTResponseType: """List Pricing - List all model pricing. + List all model pricing. A hosted provider restricted to another organization than the caller's is left out, as it is from the catalog. :param skip: :type skip: int diff --git a/src/otari/_client/api/provider_keys_api.py b/src/otari/_client/api/provider_keys_api.py index a65e13ad..500f394d 100644 --- a/src/otari/_client/api/provider_keys_api.py +++ b/src/otari/_client/api/provider_keys_api.py @@ -5404,6 +5404,271 @@ def _provider_keys_set_workspace_provider_key_override_serialize( + @validate_call + def provider_keys_unset_org_provider_key_default( + self, + key_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> OrgProviderKeyPublic: + """Unset Org Provider Key Default + + Stop a key being the organization's default for its provider. Organization owners and admins only. Idempotent: a key that is not the default is returned unchanged. With no default, a request that names no instance gets the provider's earliest-created key the workspace has not disabled. + + :param key_id: (required) + :type key_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._provider_keys_unset_org_provider_key_default_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrgProviderKeyPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def provider_keys_unset_org_provider_key_default_with_http_info( + self, + key_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[OrgProviderKeyPublic]: + """Unset Org Provider Key Default + + Stop a key being the organization's default for its provider. Organization owners and admins only. Idempotent: a key that is not the default is returned unchanged. With no default, a request that names no instance gets the provider's earliest-created key the workspace has not disabled. + + :param key_id: (required) + :type key_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._provider_keys_unset_org_provider_key_default_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrgProviderKeyPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def provider_keys_unset_org_provider_key_default_without_preload_content( + self, + key_id: UUID, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Unset Org Provider Key Default + + Stop a key being the organization's default for its provider. Organization owners and admins only. Idempotent: a key that is not the default is returned unchanged. With no default, a request that names no instance gets the provider's earliest-created key the workspace has not disabled. + + :param key_id: (required) + :type key_id: UUID + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._provider_keys_unset_org_provider_key_default_serialize( + key_id=key_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OrgProviderKeyPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _provider_keys_unset_org_provider_key_default_serialize( + self, + key_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if key_id is not None: + _path_params['key_id'] = key_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/api/v1/organizations/me/provider-keys/{key_id}/default', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def provider_keys_update_org_provider_key( self, diff --git a/src/otari/_client/api/providers_api.py b/src/otari/_client/api/providers_api.py index cf6232c9..7f76ac30 100644 --- a/src/otari/_client/api/providers_api.py +++ b/src/otari/_client/api/providers_api.py @@ -1614,7 +1614,7 @@ def providers_provider_health( ) -> ProviderHealthResponse: """Provider Health - Report every configured provider's reachability, with a last-checked time. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. + Report every configured provider's reachability, with a last-checked time. Covers the configured provider instances and every hosted provider switched on, each hosted provider under its provider name. A hosted provider that a configured instance of the same name shadows is not reported. One whose stored key cannot be decrypted with the configured `OTARI_SECRET_KEY` is reported unreachable with that reason. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. :param refresh: :type refresh: bool @@ -1682,7 +1682,7 @@ def providers_provider_health_with_http_info( ) -> ApiResponse[ProviderHealthResponse]: """Provider Health - Report every configured provider's reachability, with a last-checked time. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. + Report every configured provider's reachability, with a last-checked time. Covers the configured provider instances and every hosted provider switched on, each hosted provider under its provider name. A hosted provider that a configured instance of the same name shadows is not reported. One whose stored key cannot be decrypted with the configured `OTARI_SECRET_KEY` is reported unreachable with that reason. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. :param refresh: :type refresh: bool @@ -1750,7 +1750,7 @@ def providers_provider_health_without_preload_content( ) -> RESTResponseType: """Provider Health - Report every configured provider's reachability, with a last-checked time. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. + Report every configured provider's reachability, with a last-checked time. Covers the configured provider instances and every hosted provider switched on, each hosted provider under its provider name. A hosted provider that a configured instance of the same name shadows is not reported. One whose stored key cannot be decrypted with the configured `OTARI_SECRET_KEY` is reported unreachable with that reason. Reuses the per-provider model-discovery test path, so a provider is healthy when its credentials can list models. Results are served from the discovery cache (cheap enough to poll), so ``checked_at`` reflects when each provider was actually dialed. Pass ``refresh=true`` to force a live re-dial of every provider. A provider whose backend serves no model-listing endpoint cannot be verified this way, but it is not unreachable either: it is reported with ``discovery_unsupported`` and counted under ``degraded`` rather than as a reachability failure. :param refresh: :type refresh: bool diff --git a/src/otari/_client/api/responses_api.py b/src/otari/_client/api/responses_api.py index fe68b771..d4996d3d 100644 --- a/src/otari/_client/api/responses_api.py +++ b/src/otari/_client/api/responses_api.py @@ -43,6 +43,7 @@ def responses_create_response( self, responses_request: ResponsesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -64,6 +65,8 @@ def responses_create_response( :type responses_request: ResponsesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -89,6 +92,7 @@ def responses_create_response( _param = self._responses_create_response_serialize( responses_request=responses_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -115,6 +119,7 @@ def responses_create_response_with_http_info( self, responses_request: ResponsesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -136,6 +141,8 @@ def responses_create_response_with_http_info( :type responses_request: ResponsesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -161,6 +168,7 @@ def responses_create_response_with_http_info( _param = self._responses_create_response_serialize( responses_request=responses_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -187,6 +195,7 @@ def responses_create_response_without_preload_content( self, responses_request: ResponsesRequest, idempotency_key: Annotated[Optional[StrictStr], Field(description="A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response.")] = None, + otari_tags: Annotated[Optional[StrictStr], Field(description="Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -208,6 +217,8 @@ def responses_create_response_without_preload_content( :type responses_request: ResponsesRequest :param idempotency_key: A unique value, such as a UUID, that makes a non-streaming request safe to retry. A retry with the same key and body returns the original response, request ID and cost without calling the provider or billing again. A retry while the original is still running is answered 409 with Retry-After. Reusing a key for a different body is refused with 422. Ignored for streaming requests, in hybrid mode, and on a deployment without OTARI_SECRET_KEY, which encrypts the stored response. :type idempotency_key: str + :param otari_tags: Tags for cost attribution, as comma-separated `key=value` pairs (`agent=bug-fix,run=1234`), for a client that cannot set the body's `metadata`. Keys and values are percent-decoded, so either may carry an encoded `,` or `=`, and a non-ASCII character must be encoded. Whitespace around a pair is ignored, and a repeated header is read as one list. The bounds are the body's: up to 16 pairs, keys up to 64 characters and values up to 512, counted after merging with the body's tags, which win on the same key. Never forwarded to the provider. + :type otari_tags: str :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -233,6 +244,7 @@ def responses_create_response_without_preload_content( _param = self._responses_create_response_serialize( responses_request=responses_request, idempotency_key=idempotency_key, + otari_tags=otari_tags, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -254,6 +266,7 @@ def _responses_create_response_serialize( self, responses_request, idempotency_key, + otari_tags, _request_auth, _content_type, _headers, @@ -279,6 +292,8 @@ def _responses_create_response_serialize( # process the header parameters if idempotency_key is not None: _header_params['Idempotency-Key'] = idempotency_key + if otari_tags is not None: + _header_params['Otari-Tags'] = otari_tags # process the form parameters # process the body parameter if responses_request is not None: diff --git a/src/otari/_client/api/routing_api.py b/src/otari/_client/api/routing_api.py index 9d998da2..711853aa 100644 --- a/src/otari/_client/api/routing_api.py +++ b/src/otari/_client/api/routing_api.py @@ -21,6 +21,7 @@ from uuid import UUID from otari._client.models.agent_model_recommendation import AgentModelRecommendation from otari._client.models.agent_model_recommendation_request import AgentModelRecommendationRequest +from otari._client.models.automatic_fallbacks_response import AutomaticFallbacksResponse from otari._client.models.explain_request import ExplainRequest from otari._client.models.explain_response import ExplainResponse from otari._client.models.policy_request import PolicyRequest @@ -906,6 +907,253 @@ def _routing_explain_policy_serialize( + @validate_call + def routing_list_automatic_fallbacks( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AutomaticFallbacksResponse: + """List Automatic Fallbacks + + The models the caller's organization sent requests to in the last 30 days, and the fallback each gets. A request that sends a model's catalog ID moves to the model's next offering when one fails, with no policy. Each model lists its offerings in the order such a request tries them, priced for this organization, with who runs the built-in tools on each, beside its traffic: how many requests a backup served, and how many named one offering and so had no fallback. The traffic is the workspaces the caller may see in their active organization, by the rule the organization's usage reads use. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._routing_list_automatic_fallbacks_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AutomaticFallbacksResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def routing_list_automatic_fallbacks_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AutomaticFallbacksResponse]: + """List Automatic Fallbacks + + The models the caller's organization sent requests to in the last 30 days, and the fallback each gets. A request that sends a model's catalog ID moves to the model's next offering when one fails, with no policy. Each model lists its offerings in the order such a request tries them, priced for this organization, with who runs the built-in tools on each, beside its traffic: how many requests a backup served, and how many named one offering and so had no fallback. The traffic is the workspaces the caller may see in their active organization, by the rule the organization's usage reads use. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._routing_list_automatic_fallbacks_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AutomaticFallbacksResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def routing_list_automatic_fallbacks_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List Automatic Fallbacks + + The models the caller's organization sent requests to in the last 30 days, and the fallback each gets. A request that sends a model's catalog ID moves to the model's next offering when one fails, with no policy. Each model lists its offerings in the order such a request tries them, priced for this organization, with who runs the built-in tools on each, beside its traffic: how many requests a backup served, and how many named one offering and so had no fallback. The traffic is the workspaces the caller may see in their active organization, by the rule the organization's usage reads use. + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._routing_list_automatic_fallbacks_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AutomaticFallbacksResponse", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _routing_list_automatic_fallbacks_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'XApiKeyAuth', + 'ApiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/organizations/me/automatic-fallbacks', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def routing_list_policies( self, diff --git a/src/otari/_client/models/__init__.py b/src/otari/_client/models/__init__.py index 3b8620fe..4ae9ab97 100644 --- a/src/otari/_client/models/__init__.py +++ b/src/otari/_client/models/__init__.py @@ -53,6 +53,8 @@ from otari._client.models.audio_speech_request import AudioSpeechRequest from otari._client.models.authenticate_passkey_request import AuthenticatePasskeyRequest from otari._client.models.authorize_response import AuthorizeResponse +from otari._client.models.automatic_fallback_public import AutomaticFallbackPublic +from otari._client.models.automatic_fallbacks_response import AutomaticFallbacksResponse from otari._client.models.batch_batch_error import BATCHBatchError from otari._client.models.batch_batch_request_counts import BATCHBatchRequestCounts from otari._client.models.batch_batch_usage import BATCHBatchUsage @@ -208,6 +210,11 @@ from otari._client.models.external_ingest_error import ExternalIngestError from otari._client.models.external_ingest_result import ExternalIngestResult from otari._client.models.external_usage_event import ExternalUsageEvent +from otari._client.models.fallback_offering_public import FallbackOfferingPublic +from otari._client.models.federation_rule_create import FederationRuleCreate +from otari._client.models.federation_rule_public import FederationRulePublic +from otari._client.models.federation_token_request import FederationTokenRequest +from otari._client.models.federation_token_response import FederationTokenResponse from otari._client.models.feedback_submission import FeedbackSubmission from otari._client.models.gate_result_response import GateResultResponse from otari._client.models.gateway_settings import GatewaySettings @@ -218,6 +225,19 @@ from otari._client.models.guardrail_profile_spec import GuardrailProfileSpec from otari._client.models.guardrail_stage import GuardrailStage from otari._client.models.http_validation_error import HTTPValidationError +from otari._client.models.hosted_available_models_public import HostedAvailableModelsPublic +from otari._client.models.hosted_catalog_kept_group_public import HostedCatalogKeptGroupPublic +from otari._client.models.hosted_catalog_provider_refresh_public import HostedCatalogProviderRefreshPublic +from otari._client.models.hosted_catalog_refresh_public import HostedCatalogRefreshPublic +from otari._client.models.hosted_model_create_request import HostedModelCreateRequest +from otari._client.models.hosted_model_public import HostedModelPublic +from otari._client.models.hosted_model_update_request import HostedModelUpdateRequest +from otari._client.models.hosted_models_public import HostedModelsPublic +from otari._client.models.hosted_models_refresh_public import HostedModelsRefreshPublic +from otari._client.models.hosted_provider_create_request import HostedProviderCreateRequest +from otari._client.models.hosted_provider_public import HostedProviderPublic +from otari._client.models.hosted_provider_update_request import HostedProviderUpdateRequest +from otari._client.models.hosted_providers_public import HostedProvidersPublic from otari._client.models.img_image import IMGImage from otari._client.models.img_usage import IMGUsage from otari._client.models.img_usage_input_tokens_details import IMGUsageInputTokensDetails @@ -414,6 +434,7 @@ from otari._client.models.noul_criteria import NoulCriteria from otari._client.models.noul_question import NoulQuestion from otari._client.models.o_auth_callback_request import OAuthCallbackRequest +from otari._client.models.o_auth_error_response import OAuthErrorResponse from otari._client.models.o_auth_session_response import OAuthSessionResponse from otari._client.models.offering_usage import OfferingUsage from otari._client.models.open_ai_file_deleted import OpenAIFileDeleted diff --git a/src/otari/_client/models/automatic_fallback_public.py b/src/otari/_client/models/automatic_fallback_public.py new file mode 100644 index 00000000..0723634b --- /dev/null +++ b/src/otari/_client/models/automatic_fallback_public.py @@ -0,0 +1,113 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from otari._client.models.fallback_offering_public import FallbackOfferingPublic +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class AutomaticFallbackPublic(BaseModel): + """ + One model the caller's organization used in the window, and the fallback a catalog ID gives it. + """ # noqa: E501 + fell_back: StrictInt = Field(description="Of `requests`, the successful ones a later offering served.") + id: StrictStr = Field(description="The catalog ID a caller sends to get the fallback, e.g. `anthropic/claude-sonnet-5`.") + name: StrictStr + offerings: List[FallbackOfferingPublic] = Field(description="What a request sent by catalog ID tries, first first. One entry means no backup.") + pinned: StrictInt = Field(description="Of `requests`, those that named an offering or a policy rather than the catalog ID, and so got no automatic fallback.") + pinned_provider: Optional[StrictStr] = Field(description="The instance most pinned requests reached.") + requests: StrictInt = Field(description="Requests served in the window, each counted once however many attempts.") + __properties: ClassVar[List[str]] = ["fell_back", "id", "name", "offerings", "pinned", "pinned_provider", "requests"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutomaticFallbackPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in offerings (list) + _items = [] + if self.offerings: + for _item_offerings in self.offerings: + if _item_offerings: + _items.append(_item_offerings.to_dict()) + _dict['offerings'] = _items + # set to None if pinned_provider (nullable) is None + # and model_fields_set contains the field + if self.pinned_provider is None and "pinned_provider" in self.model_fields_set: + _dict['pinned_provider'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutomaticFallbackPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "fell_back": obj.get("fell_back"), + "id": obj.get("id"), + "name": obj.get("name"), + "offerings": [FallbackOfferingPublic.from_dict(_item) for _item in obj["offerings"]] if obj.get("offerings") is not None else None, + "pinned": obj.get("pinned"), + "pinned_provider": obj.get("pinned_provider"), + "requests": obj.get("requests") + }) + return _obj + + diff --git a/src/otari/_client/models/automatic_fallbacks_response.py b/src/otari/_client/models/automatic_fallbacks_response.py new file mode 100644 index 00000000..562a837b --- /dev/null +++ b/src/otari/_client/models/automatic_fallbacks_response.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List +from otari._client.models.automatic_fallback_public import AutomaticFallbackPublic +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class AutomaticFallbacksResponse(BaseModel): + """ + The automatic fallbacks the caller's organization used. + """ # noqa: E501 + models: List[AutomaticFallbackPublic] = Field(description="Most requested first.") + window_days: StrictInt = Field(description="How many days of traffic the counts cover.") + __properties: ClassVar[List[str]] = ["models", "window_days"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AutomaticFallbacksResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in models (list) + _items = [] + if self.models: + for _item_models in self.models: + if _item_models: + _items.append(_item_models.to_dict()) + _dict['models'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AutomaticFallbacksResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "models": [AutomaticFallbackPublic.from_dict(_item) for _item in obj["models"]] if obj.get("models") is not None else None, + "window_days": obj.get("window_days") + }) + return _obj + + diff --git a/src/otari/_client/models/fallback_offering_public.py b/src/otari/_client/models/fallback_offering_public.py new file mode 100644 index 00000000..1022ea76 --- /dev/null +++ b/src/otari/_client/models/fallback_offering_public.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class FallbackOfferingPublic(BaseModel): + """ + One offering a catalog ID tries, and who runs the built-in tools on it. + """ # noqa: E501 + otari_tools: List[StrictStr] = Field(description="Built-in tools Otari runs in this provider's place, for that caller.") + own_tools: List[StrictStr] = Field(description="Built-in tools this provider runs itself, for a caller that declares them in the provider's own words and leaves the choice of executor to the deployment.") + provider: StrictStr = Field(description="The provider instance the selector names.") + provider_type: StrictStr = Field(description="The any-llm implementation behind the instance.") + selector: StrictStr = Field(description="The offering, in `instance:model` form.") + __properties: ClassVar[List[str]] = ["otari_tools", "own_tools", "provider", "provider_type", "selector"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FallbackOfferingPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FallbackOfferingPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "otari_tools": obj.get("otari_tools"), + "own_tools": obj.get("own_tools"), + "provider": obj.get("provider"), + "provider_type": obj.get("provider_type"), + "selector": obj.get("selector") + }) + return _obj + + diff --git a/src/otari/_client/models/federation_rule_create.py b/src/otari/_client/models/federation_rule_create.py new file mode 100644 index 00000000..281388f0 --- /dev/null +++ b/src/otari/_client/models/federation_rule_create.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class FederationRuleCreate(BaseModel): + """ + An OpenID Connect identity that may authenticate as the key, in place of its secret. A token matches when it is signed by ``issuer``, names ``audience`` among its audiences, and carries each of ``subject`` and ``email`` that the rule sets; an email matches only when the token marks it verified. At least one of the two is required. + """ # noqa: E501 + audience: Annotated[str, Field(min_length=1, strict=True, max_length=512)] = Field(description="A value the token's 'aud' must contain.") + email: Optional[Annotated[str, Field(min_length=3, strict=True, max_length=320)]] = Field(default=None, description="The token's verified 'email', when the rule names one. Compared without regard to case.") + issuer: Annotated[str, Field(min_length=1, strict=True, max_length=512)] = Field(description="The token's 'iss', one of the deployment's federation_issuers.") + subject: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=255)]] = Field(default=None, description="The token's 'sub', when the rule names one.") + __properties: ClassVar[List[str]] = ["audience", "email", "issuer", "subject"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FederationRuleCreate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if email (nullable) is None + # and model_fields_set contains the field + if self.email is None and "email" in self.model_fields_set: + _dict['email'] = None + + # set to None if subject (nullable) is None + # and model_fields_set contains the field + if self.subject is None and "subject" in self.model_fields_set: + _dict['subject'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FederationRuleCreate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "audience": obj.get("audience"), + "email": obj.get("email"), + "issuer": obj.get("issuer"), + "subject": obj.get("subject") + }) + return _obj + + diff --git a/src/otari/_client/models/federation_rule_public.py b/src/otari/_client/models/federation_rule_public.py new file mode 100644 index 00000000..bbe20897 --- /dev/null +++ b/src/otari/_client/models/federation_rule_public.py @@ -0,0 +1,111 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class FederationRulePublic(BaseModel): + """ + A federation rule of an API key. + """ # noqa: E501 + api_key_id: StrictStr + audience: StrictStr + created_at: datetime + email: Optional[StrictStr] + id: StrictStr + issuer: StrictStr + subject: Optional[StrictStr] + __properties: ClassVar[List[str]] = ["api_key_id", "audience", "created_at", "email", "id", "issuer", "subject"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FederationRulePublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if email (nullable) is None + # and model_fields_set contains the field + if self.email is None and "email" in self.model_fields_set: + _dict['email'] = None + + # set to None if subject (nullable) is None + # and model_fields_set contains the field + if self.subject is None and "subject" in self.model_fields_set: + _dict['subject'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FederationRulePublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "api_key_id": obj.get("api_key_id"), + "audience": obj.get("audience"), + "created_at": obj.get("created_at"), + "email": obj.get("email"), + "id": obj.get("id"), + "issuer": obj.get("issuer"), + "subject": obj.get("subject") + }) + return _obj + + diff --git a/src/otari/_client/models/federation_token_request.py b/src/otari/_client/models/federation_token_request.py new file mode 100644 index 00000000..e64d7345 --- /dev/null +++ b/src/otari/_client/models/federation_token_request.py @@ -0,0 +1,128 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class FederationTokenRequest(BaseModel): + """ + An RFC 7523 ``jwt-bearer`` token request, as the Anthropic SDKs and Claude Code send it. Every field is optional here so that a missing one is answered in the RFC 6749 error shape rather than as a validation error. Fields the request does not use are ignored. + """ # noqa: E501 + assertion: Optional[StrictStr] = Field(default=None, description="The identity token.") + federation_rule_id: Optional[StrictStr] = Field(default=None, description="The id of the federation rule the identity token must match.") + grant_type: Optional[StrictStr] = Field(default=None, description="urn:ietf:params:oauth:grant-type:jwt-bearer") + organization_id: Optional[StrictStr] = Field(default=None, description="When set, the UUID of the organization of the rule's key.") + service_account_id: Optional[StrictStr] = Field(default=None, description="When set, the id of the rule's key.") + workspace_id: Optional[StrictStr] = Field(default=None, description="When set, the UUID of the rule's key's workspace.") + __properties: ClassVar[List[str]] = ["assertion", "federation_rule_id", "grant_type", "organization_id", "service_account_id", "workspace_id"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FederationTokenRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if assertion (nullable) is None + # and model_fields_set contains the field + if self.assertion is None and "assertion" in self.model_fields_set: + _dict['assertion'] = None + + # set to None if federation_rule_id (nullable) is None + # and model_fields_set contains the field + if self.federation_rule_id is None and "federation_rule_id" in self.model_fields_set: + _dict['federation_rule_id'] = None + + # set to None if grant_type (nullable) is None + # and model_fields_set contains the field + if self.grant_type is None and "grant_type" in self.model_fields_set: + _dict['grant_type'] = None + + # set to None if organization_id (nullable) is None + # and model_fields_set contains the field + if self.organization_id is None and "organization_id" in self.model_fields_set: + _dict['organization_id'] = None + + # set to None if service_account_id (nullable) is None + # and model_fields_set contains the field + if self.service_account_id is None and "service_account_id" in self.model_fields_set: + _dict['service_account_id'] = None + + # set to None if workspace_id (nullable) is None + # and model_fields_set contains the field + if self.workspace_id is None and "workspace_id" in self.model_fields_set: + _dict['workspace_id'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FederationTokenRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "assertion": obj.get("assertion"), + "federation_rule_id": obj.get("federation_rule_id"), + "grant_type": obj.get("grant_type"), + "organization_id": obj.get("organization_id"), + "service_account_id": obj.get("service_account_id"), + "workspace_id": obj.get("workspace_id") + }) + return _obj + + diff --git a/src/otari/_client/models/federation_token_response.py b/src/otari/_client/models/federation_token_response.py new file mode 100644 index 00000000..4086cc2e --- /dev/null +++ b/src/otari/_client/models/federation_token_response.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class FederationTokenResponse(BaseModel): + """ + An access token, as RFC 6749 section 5.1 shapes it. Present it as a bearer token in place of the key. + """ # noqa: E501 + access_token: StrictStr + expires_in: StrictInt = Field(description="Seconds until the access token expires.") + token_type: Optional[StrictStr] = 'Bearer' + __properties: ClassVar[List[str]] = ["access_token", "expires_in", "token_type"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FederationTokenResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FederationTokenResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "access_token": obj.get("access_token"), + "expires_in": obj.get("expires_in"), + "token_type": obj.get("token_type") if obj.get("token_type") is not None else 'Bearer' + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_available_models_public.py b/src/otari/_client/models/hosted_available_models_public.py new file mode 100644 index 00000000..a38e4761 --- /dev/null +++ b/src/otari/_client/models/hosted_available_models_public.py @@ -0,0 +1,99 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedAvailableModelsPublic(BaseModel): + """ + What the provider says it serves on the stored credential. Failure is a field rather than a status: an unreachable upstream, or a provider with no model listing, is an answer about the provider rather than about this request, and the form still has to render a plain text box when the list cannot be fetched. + """ # noqa: E501 + discovery_unsupported: Optional[StrictBool] = False + error: Optional[StrictStr] = None + models: Optional[List[StrictStr]] = None + provider: StrictStr + __properties: ClassVar[List[str]] = ["discovery_unsupported", "error", "models", "provider"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedAvailableModelsPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if error (nullable) is None + # and model_fields_set contains the field + if self.error is None and "error" in self.model_fields_set: + _dict['error'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedAvailableModelsPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "discovery_unsupported": obj.get("discovery_unsupported") if obj.get("discovery_unsupported") is not None else False, + "error": obj.get("error"), + "models": obj.get("models"), + "provider": obj.get("provider") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_catalog_kept_group_public.py b/src/otari/_client/models/hosted_catalog_kept_group_public.py new file mode 100644 index 00000000..529d8fca --- /dev/null +++ b/src/otari/_client/models/hosted_catalog_kept_group_public.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedCatalogKeptGroupPublic(BaseModel): + """ + Priced models a sweep left in place, grouped by the reason it did. + """ # noqa: E501 + count: StrictInt + models: List[StrictStr] + reason: StrictStr + __properties: ClassVar[List[str]] = ["count", "models", "reason"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedCatalogKeptGroupPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedCatalogKeptGroupPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "count": obj.get("count"), + "models": obj.get("models"), + "reason": obj.get("reason") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_catalog_provider_refresh_public.py b/src/otari/_client/models/hosted_catalog_provider_refresh_public.py new file mode 100644 index 00000000..5788769b --- /dev/null +++ b/src/otari/_client/models/hosted_catalog_provider_refresh_public.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedCatalogProviderRefreshPublic(BaseModel): + """ + What one hosted provider newly lists, as a catalog sweep found it. Per provider rather than one total, because a dial that failed is a fact about that provider, and the operator has to be told which one went quiet rather than read a smaller number than they expected. + """ # noqa: E501 + added: List[StrictStr] + credential_unreadable: Optional[StrictBool] = False + discovery_unsupported: Optional[StrictBool] = False + error: Optional[StrictStr] = None + provider: StrictStr + repriced: Optional[List[StrictStr]] = None + source: Optional[StrictStr] = 'database' + __properties: ClassVar[List[str]] = ["added", "credential_unreadable", "discovery_unsupported", "error", "provider", "repriced", "source"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['database', 'config']): + raise ValueError("must be one of enum values ('database', 'config')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedCatalogProviderRefreshPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if error (nullable) is None + # and model_fields_set contains the field + if self.error is None and "error" in self.model_fields_set: + _dict['error'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedCatalogProviderRefreshPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "added": obj.get("added"), + "credential_unreadable": obj.get("credential_unreadable") if obj.get("credential_unreadable") is not None else False, + "discovery_unsupported": obj.get("discovery_unsupported") if obj.get("discovery_unsupported") is not None else False, + "error": obj.get("error"), + "provider": obj.get("provider"), + "repriced": obj.get("repriced"), + "source": obj.get("source") if obj.get("source") is not None else 'database' + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_catalog_refresh_public.py b/src/otari/_client/models/hosted_catalog_refresh_public.py new file mode 100644 index 00000000..24687570 --- /dev/null +++ b/src/otari/_client/models/hosted_catalog_refresh_public.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from otari._client.models.hosted_catalog_kept_group_public import HostedCatalogKeptGroupPublic +from otari._client.models.hosted_catalog_provider_refresh_public import HostedCatalogProviderRefreshPublic +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedCatalogRefreshPublic(BaseModel): + """ + What a catalog sweep did, or would do. ``removed`` is a sample and ``removed_count`` the total, so a deployment that has never been swept does not answer one button press with a few thousand strings. ``orphaned_rosters`` names the providers that still have a model list but nothing defining them, such as a removed ``config.yml`` entry: nothing serves them, and an apply deletes their model lists. + """ # noqa: E501 + kept: List[HostedCatalogKeptGroupPublic] + orphaned_rosters: Optional[List[StrictStr]] = None + providers: List[HostedCatalogProviderRefreshPublic] + removed: List[StrictStr] + removed_count: StrictInt + removed_override_rows: StrictInt + removed_price_rows: StrictInt + __properties: ClassVar[List[str]] = ["kept", "orphaned_rosters", "providers", "removed", "removed_count", "removed_override_rows", "removed_price_rows"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedCatalogRefreshPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in kept (list) + _items = [] + if self.kept: + for _item_kept in self.kept: + if _item_kept: + _items.append(_item_kept.to_dict()) + _dict['kept'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in providers (list) + _items = [] + if self.providers: + for _item_providers in self.providers: + if _item_providers: + _items.append(_item_providers.to_dict()) + _dict['providers'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedCatalogRefreshPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "kept": [HostedCatalogKeptGroupPublic.from_dict(_item) for _item in obj["kept"]] if obj.get("kept") is not None else None, + "orphaned_rosters": obj.get("orphaned_rosters"), + "providers": [HostedCatalogProviderRefreshPublic.from_dict(_item) for _item in obj["providers"]] if obj.get("providers") is not None else None, + "removed": obj.get("removed"), + "removed_count": obj.get("removed_count"), + "removed_override_rows": obj.get("removed_override_rows"), + "removed_price_rows": obj.get("removed_price_rows") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_model_create_request.py b/src/otari/_client/models/hosted_model_create_request.py new file mode 100644 index 00000000..f95074b2 --- /dev/null +++ b/src/otari/_client/models/hosted_model_create_request.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedModelCreateRequest(BaseModel): + """ + Offer a model on a hosted provider, optionally at a custom price. Omitting the rates means the deployment serves the model at whatever the price ladder already answers: a stored deployment price, else the community default, which the offer stores as the deployment's own rate. ``unit`` is what the rates are per, as on ``POST /pricing``: a request or image rate is still stored per million. + """ # noqa: E501 + cache_read_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + cache_write_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + input_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + model: Annotated[str, Field(min_length=1, strict=True, max_length=255)] + output_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + unit: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["cache_read_price_per_million", "cache_write_price_per_million", "input_price_per_million", "model", "output_price_per_million", "unit"] + + @field_validator('unit') + def unit_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['tokens', 'requests', 'images']): + raise ValueError("must be one of enum values ('tokens', 'requests', 'images')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedModelCreateRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if cache_read_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_read_price_per_million is None and "cache_read_price_per_million" in self.model_fields_set: + _dict['cache_read_price_per_million'] = None + + # set to None if cache_write_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_write_price_per_million is None and "cache_write_price_per_million" in self.model_fields_set: + _dict['cache_write_price_per_million'] = None + + # set to None if input_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.input_price_per_million is None and "input_price_per_million" in self.model_fields_set: + _dict['input_price_per_million'] = None + + # set to None if output_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.output_price_per_million is None and "output_price_per_million" in self.model_fields_set: + _dict['output_price_per_million'] = None + + # set to None if unit (nullable) is None + # and model_fields_set contains the field + if self.unit is None and "unit" in self.model_fields_set: + _dict['unit'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedModelCreateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cache_read_price_per_million": obj.get("cache_read_price_per_million"), + "cache_write_price_per_million": obj.get("cache_write_price_per_million"), + "input_price_per_million": obj.get("input_price_per_million"), + "model": obj.get("model"), + "output_price_per_million": obj.get("output_price_per_million"), + "unit": obj.get("unit") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_model_public.py b/src/otari/_client/models/hosted_model_public.py new file mode 100644 index 00000000..86754010 --- /dev/null +++ b/src/otari/_client/models/hosted_model_public.py @@ -0,0 +1,157 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedModelPublic(BaseModel): + """ + One offered model, with the price the deployment currently serves it at. ``price_source`` says which rung of the deployment's ladder answered: ``deployment`` for a rate an operator set, ``defaults`` for the community-maintained rate, whether this surface stored it or the fallback supplies it, and None when nothing prices the model yet. ``unit`` says what the rates are per, so a per-request rate is not read as a per-token one. ``enabled`` is the serving switch; a model offered without a discoverable price starts off. + """ # noqa: E501 + cache_read_price_per_million: Optional[Union[StrictFloat, StrictInt]] = None + cache_write_price_per_million: Optional[Union[StrictFloat, StrictInt]] = None + created_at: datetime + enabled: StrictBool + id: UUID + input_price_per_million: Optional[Union[StrictFloat, StrictInt]] = None + model: StrictStr + output_price_per_million: Optional[Union[StrictFloat, StrictInt]] = None + price_source: Optional[StrictStr] = None + provider: StrictStr + unit: Optional[StrictStr] = None + updated_at: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["cache_read_price_per_million", "cache_write_price_per_million", "created_at", "enabled", "id", "input_price_per_million", "model", "output_price_per_million", "price_source", "provider", "unit", "updated_at"] + + @field_validator('price_source') + def price_source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['organization', 'deployment', 'defaults']): + raise ValueError("must be one of enum values ('organization', 'deployment', 'defaults')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedModelPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if cache_read_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_read_price_per_million is None and "cache_read_price_per_million" in self.model_fields_set: + _dict['cache_read_price_per_million'] = None + + # set to None if cache_write_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_write_price_per_million is None and "cache_write_price_per_million" in self.model_fields_set: + _dict['cache_write_price_per_million'] = None + + # set to None if input_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.input_price_per_million is None and "input_price_per_million" in self.model_fields_set: + _dict['input_price_per_million'] = None + + # set to None if output_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.output_price_per_million is None and "output_price_per_million" in self.model_fields_set: + _dict['output_price_per_million'] = None + + # set to None if price_source (nullable) is None + # and model_fields_set contains the field + if self.price_source is None and "price_source" in self.model_fields_set: + _dict['price_source'] = None + + # set to None if unit (nullable) is None + # and model_fields_set contains the field + if self.unit is None and "unit" in self.model_fields_set: + _dict['unit'] = None + + # set to None if updated_at (nullable) is None + # and model_fields_set contains the field + if self.updated_at is None and "updated_at" in self.model_fields_set: + _dict['updated_at'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedModelPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cache_read_price_per_million": obj.get("cache_read_price_per_million"), + "cache_write_price_per_million": obj.get("cache_write_price_per_million"), + "created_at": obj.get("created_at"), + "enabled": obj.get("enabled"), + "id": obj.get("id"), + "input_price_per_million": obj.get("input_price_per_million"), + "model": obj.get("model"), + "output_price_per_million": obj.get("output_price_per_million"), + "price_source": obj.get("price_source"), + "provider": obj.get("provider"), + "unit": obj.get("unit"), + "updated_at": obj.get("updated_at") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_model_update_request.py b/src/otari/_client/models/hosted_model_update_request.py new file mode 100644 index 00000000..970233ba --- /dev/null +++ b/src/otari/_client/models/hosted_model_update_request.py @@ -0,0 +1,139 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedModelUpdateRequest(BaseModel): + """ + Reprice an offered model, toggle whether it is served, or both. A price is the input/output pair or nothing: sending the pair writes a new pricing version, and the cache rates then follow ``POST /pricing``'s own semantics (a field the caller omits inherits the most recent stored value, an explicit null clears it). An omitted ``unit`` carries the stored one forward. ``enabled`` travels alone freely, so a toggle never re-sends rates it did not change. + """ # noqa: E501 + cache_read_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + cache_write_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + enabled: Optional[StrictBool] = None + input_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + output_price_per_million: Optional[Union[Annotated[float, Field(strict=True, ge=0.0)], Annotated[int, Field(strict=True, ge=0)]]] = None + unit: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["cache_read_price_per_million", "cache_write_price_per_million", "enabled", "input_price_per_million", "output_price_per_million", "unit"] + + @field_validator('unit') + def unit_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['tokens', 'requests', 'images']): + raise ValueError("must be one of enum values ('tokens', 'requests', 'images')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedModelUpdateRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if cache_read_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_read_price_per_million is None and "cache_read_price_per_million" in self.model_fields_set: + _dict['cache_read_price_per_million'] = None + + # set to None if cache_write_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.cache_write_price_per_million is None and "cache_write_price_per_million" in self.model_fields_set: + _dict['cache_write_price_per_million'] = None + + # set to None if enabled (nullable) is None + # and model_fields_set contains the field + if self.enabled is None and "enabled" in self.model_fields_set: + _dict['enabled'] = None + + # set to None if input_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.input_price_per_million is None and "input_price_per_million" in self.model_fields_set: + _dict['input_price_per_million'] = None + + # set to None if output_price_per_million (nullable) is None + # and model_fields_set contains the field + if self.output_price_per_million is None and "output_price_per_million" in self.model_fields_set: + _dict['output_price_per_million'] = None + + # set to None if unit (nullable) is None + # and model_fields_set contains the field + if self.unit is None and "unit" in self.model_fields_set: + _dict['unit'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedModelUpdateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "cache_read_price_per_million": obj.get("cache_read_price_per_million"), + "cache_write_price_per_million": obj.get("cache_write_price_per_million"), + "enabled": obj.get("enabled"), + "input_price_per_million": obj.get("input_price_per_million"), + "output_price_per_million": obj.get("output_price_per_million"), + "unit": obj.get("unit") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_models_public.py b/src/otari/_client/models/hosted_models_public.py new file mode 100644 index 00000000..8f3443fb --- /dev/null +++ b/src/otari/_client/models/hosted_models_public.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from otari._client.models.hosted_model_public import HostedModelPublic +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedModelsPublic(BaseModel): + """ + A page of one hosted provider's offered models, and how many there are in total. + """ # noqa: E501 + count: StrictInt + data: List[HostedModelPublic] + __properties: ClassVar[List[str]] = ["count", "data"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedModelsPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in data (list) + _items = [] + if self.data: + for _item_data in self.data: + if _item_data: + _items.append(_item_data.to_dict()) + _dict['data'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedModelsPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "count": obj.get("count"), + "data": [HostedModelPublic.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_models_refresh_public.py b/src/otari/_client/models/hosted_models_refresh_public.py new file mode 100644 index 00000000..b4c72f72 --- /dev/null +++ b/src/otari/_client/models/hosted_models_refresh_public.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedModelsRefreshPublic(BaseModel): + """ + What a refresh did: the models newly offered, the seeded rates it moved, and the list's new size. Failure is a field rather than a status, for the reason ``HostedAvailableModelsPublic`` gives: the list is still standing, and the panel renders the reason beside it. + """ # noqa: E501 + added: List[StrictStr] + count: StrictInt + discovery_unsupported: Optional[StrictBool] = False + error: Optional[StrictStr] = None + repriced: List[StrictStr] + __properties: ClassVar[List[str]] = ["added", "count", "discovery_unsupported", "error", "repriced"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedModelsRefreshPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if error (nullable) is None + # and model_fields_set contains the field + if self.error is None and "error" in self.model_fields_set: + _dict['error'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedModelsRefreshPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "added": obj.get("added"), + "count": obj.get("count"), + "discovery_unsupported": obj.get("discovery_unsupported") if obj.get("discovery_unsupported") is not None else False, + "error": obj.get("error"), + "repriced": obj.get("repriced") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_provider_create_request.py b/src/otari/_client/models/hosted_provider_create_request.py new file mode 100644 index 00000000..72470f97 --- /dev/null +++ b/src/otari/_client/models/hosted_provider_create_request.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedProviderCreateRequest(BaseModel): + """ + Configure a provider this deployment will serve hosted inference on. ``client_args`` is whatever the provider's SDK client needs beyond the key (Bedrock's region and IAM pair), the same shape an organization provider key takes. Values under credential-shaped names come back masked. ``restricted_to_organization_id`` keeps the provider to one organization; every other one is served as if it were not configured. + """ # noqa: E501 + api_base: Optional[Annotated[str, Field(strict=True, max_length=1024)]] = None + api_key: Annotated[str, Field(min_length=1, strict=True, max_length=1024)] + client_args: Optional[Dict[str, Any]] = None + enabled: Optional[StrictBool] = True + provider: Annotated[str, Field(min_length=1, strict=True, max_length=64)] + restricted_to_organization_id: Optional[UUID] = None + __properties: ClassVar[List[str]] = ["api_base", "api_key", "client_args", "enabled", "provider", "restricted_to_organization_id"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedProviderCreateRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if api_base (nullable) is None + # and model_fields_set contains the field + if self.api_base is None and "api_base" in self.model_fields_set: + _dict['api_base'] = None + + # set to None if client_args (nullable) is None + # and model_fields_set contains the field + if self.client_args is None and "client_args" in self.model_fields_set: + _dict['client_args'] = None + + # set to None if restricted_to_organization_id (nullable) is None + # and model_fields_set contains the field + if self.restricted_to_organization_id is None and "restricted_to_organization_id" in self.model_fields_set: + _dict['restricted_to_organization_id'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedProviderCreateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "api_base": obj.get("api_base"), + "api_key": obj.get("api_key"), + "client_args": obj.get("client_args"), + "enabled": obj.get("enabled") if obj.get("enabled") is not None else True, + "provider": obj.get("provider"), + "restricted_to_organization_id": obj.get("restricted_to_organization_id") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_provider_public.py b/src/otari/_client/models/hosted_provider_public.py new file mode 100644 index 00000000..44c7e4b9 --- /dev/null +++ b/src/otari/_client/models/hosted_provider_public.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedProviderPublic(BaseModel): + """ + One hosted provider, named by its provider and the tail of its key. No shape in this section carries key material: a stored credential is known by its last four characters and nothing else, ``client_args`` goes out with credential-shaped values masked, and ``api_base`` with the password in its userinfo and its query values masked. ``source`` says where the provider is defined. A ``config`` provider comes from the ``hosted_providers:`` block, has no row and so no ``id`` or timestamps, and is changed by editing the configuration rather than through this API; its models are administered as a stored provider's are. ``shadows_config`` marks a stored provider that wins over a configuration entry of the same provider, which serves again once the row is deleted. + """ # noqa: E501 + api_base: Optional[StrictStr] = None + api_key_last4: Optional[StrictStr] = None + client_args: Optional[Dict[str, Any]] = None + created_at: Optional[datetime] = None + enabled: StrictBool + id: Optional[UUID] = None + provider: StrictStr + restricted_to_organization_id: Optional[UUID] = None + shadows_config: Optional[StrictBool] = False + source: Optional[StrictStr] = 'database' + updated_at: Optional[datetime] = None + __properties: ClassVar[List[str]] = ["api_base", "api_key_last4", "client_args", "created_at", "enabled", "id", "provider", "restricted_to_organization_id", "shadows_config", "source", "updated_at"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['database', 'config']): + raise ValueError("must be one of enum values ('database', 'config')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedProviderPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if api_base (nullable) is None + # and model_fields_set contains the field + if self.api_base is None and "api_base" in self.model_fields_set: + _dict['api_base'] = None + + # set to None if api_key_last4 (nullable) is None + # and model_fields_set contains the field + if self.api_key_last4 is None and "api_key_last4" in self.model_fields_set: + _dict['api_key_last4'] = None + + # set to None if client_args (nullable) is None + # and model_fields_set contains the field + if self.client_args is None and "client_args" in self.model_fields_set: + _dict['client_args'] = None + + # set to None if created_at (nullable) is None + # and model_fields_set contains the field + if self.created_at is None and "created_at" in self.model_fields_set: + _dict['created_at'] = None + + # set to None if id (nullable) is None + # and model_fields_set contains the field + if self.id is None and "id" in self.model_fields_set: + _dict['id'] = None + + # set to None if restricted_to_organization_id (nullable) is None + # and model_fields_set contains the field + if self.restricted_to_organization_id is None and "restricted_to_organization_id" in self.model_fields_set: + _dict['restricted_to_organization_id'] = None + + # set to None if updated_at (nullable) is None + # and model_fields_set contains the field + if self.updated_at is None and "updated_at" in self.model_fields_set: + _dict['updated_at'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedProviderPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "api_base": obj.get("api_base"), + "api_key_last4": obj.get("api_key_last4"), + "client_args": obj.get("client_args"), + "created_at": obj.get("created_at"), + "enabled": obj.get("enabled"), + "id": obj.get("id"), + "provider": obj.get("provider"), + "restricted_to_organization_id": obj.get("restricted_to_organization_id"), + "shadows_config": obj.get("shadows_config") if obj.get("shadows_config") is not None else False, + "source": obj.get("source") if obj.get("source") is not None else 'database', + "updated_at": obj.get("updated_at") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_provider_update_request.py b/src/otari/_client/models/hosted_provider_update_request.py new file mode 100644 index 00000000..8c934f51 --- /dev/null +++ b/src/otari/_client/models/hosted_provider_update_request.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool +from typing import Any, ClassVar, Dict, List, Optional +from typing_extensions import Annotated +from uuid import UUID +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedProviderUpdateRequest(BaseModel): + """ + Rotate the key, repoint the base, or turn a provider off. ``provider`` is immutable: changing it is a delete plus a create, because the key belongs to the provider it was issued by. Omitting ``api_key`` leaves the stored credential untouched, so a toggle never re-sends a secret the caller does not have. ``client_args`` omitted is left alone; an explicit null clears it, and an entry echoed back as the mask keeps the stored value. ``restricted_to_organization_id`` reads the same way: omitted keeps the restriction, null lifts it. + """ # noqa: E501 + api_base: Optional[Annotated[str, Field(strict=True, max_length=1024)]] = None + api_key: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=1024)]] = None + client_args: Optional[Dict[str, Any]] = None + enabled: Optional[StrictBool] = None + restricted_to_organization_id: Optional[UUID] = None + __properties: ClassVar[List[str]] = ["api_base", "api_key", "client_args", "enabled", "restricted_to_organization_id"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedProviderUpdateRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if api_base (nullable) is None + # and model_fields_set contains the field + if self.api_base is None and "api_base" in self.model_fields_set: + _dict['api_base'] = None + + # set to None if api_key (nullable) is None + # and model_fields_set contains the field + if self.api_key is None and "api_key" in self.model_fields_set: + _dict['api_key'] = None + + # set to None if client_args (nullable) is None + # and model_fields_set contains the field + if self.client_args is None and "client_args" in self.model_fields_set: + _dict['client_args'] = None + + # set to None if enabled (nullable) is None + # and model_fields_set contains the field + if self.enabled is None and "enabled" in self.model_fields_set: + _dict['enabled'] = None + + # set to None if restricted_to_organization_id (nullable) is None + # and model_fields_set contains the field + if self.restricted_to_organization_id is None and "restricted_to_organization_id" in self.model_fields_set: + _dict['restricted_to_organization_id'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedProviderUpdateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "api_base": obj.get("api_base"), + "api_key": obj.get("api_key"), + "client_args": obj.get("client_args"), + "enabled": obj.get("enabled"), + "restricted_to_organization_id": obj.get("restricted_to_organization_id") + }) + return _obj + + diff --git a/src/otari/_client/models/hosted_providers_public.py b/src/otari/_client/models/hosted_providers_public.py new file mode 100644 index 00000000..f60f5bbd --- /dev/null +++ b/src/otari/_client/models/hosted_providers_public.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictInt +from typing import Any, ClassVar, Dict, List +from otari._client.models.hosted_provider_public import HostedProviderPublic +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HostedProvidersPublic(BaseModel): + """ + A page of hosted providers, and how many there are in total. + """ # noqa: E501 + count: StrictInt + data: List[HostedProviderPublic] + __properties: ClassVar[List[str]] = ["count", "data"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HostedProvidersPublic from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in data (list) + _items = [] + if self.data: + for _item_data in self.data: + if _item_data: + _items.append(_item_data.to_dict()) + _dict['data'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HostedProvidersPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "count": obj.get("count"), + "data": [HostedProviderPublic.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None + }) + return _obj + + diff --git a/src/otari/_client/models/known_provider_schema.py b/src/otari/_client/models/known_provider_schema.py index 68c46738..4b70be1a 100644 --- a/src/otari/_client/models/known_provider_schema.py +++ b/src/otari/_client/models/known_provider_schema.py @@ -29,10 +29,10 @@ class KnownProviderSchema(BaseModel): """ # noqa: E501 default_api_base: Optional[StrictStr] = Field(default=None, description="Built-in endpoint; blank means the SDK's default.") env_key: Optional[StrictStr] = Field(default=None, description="Env var the SDK reads this provider's key from.") - env_key_present: Optional[StrictBool] = Field(default=False, description="True when env_key is already set on the server, so a pasted key is optional (env fallback).") + env_key_present: Optional[StrictBool] = Field(default=False, description="True when env_key is set on the server. Informational: a stored provider never reads it, so a key the provider requires must still be supplied.") id: StrictStr = Field(description="any-llm provider id, used as the default instance name.") name: StrictStr = Field(description="Human-friendly display name.") - requires_api_key: StrictBool = Field(description="False for keyless local backends (Ollama, llama.cpp).") + requires_api_key: StrictBool = Field(description="False for providers that need no key: keyless local backends (Ollama, llama.cpp) and ambient cloud credentials (Bedrock, Vertex AI).") __properties: ClassVar[List[str]] = ["default_api_base", "env_key", "env_key_present", "id", "name", "requires_api_key"] model_config = ConfigDict( diff --git a/src/otari/_client/models/o_auth_error_response.py b/src/otari/_client/models/o_auth_error_response.py new file mode 100644 index 00000000..69d03126 --- /dev/null +++ b/src/otari/_client/models/o_auth_error_response.py @@ -0,0 +1,90 @@ +# coding: utf-8 + +""" + otari + + Otari, an OpenAI-compatible LLM gateway with API key management + + The version of the OpenAPI document: 0.0.0-dev + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class OAuthErrorResponse(BaseModel): + """ + A refused token request, as RFC 6749 section 5.2 shapes it. + """ # noqa: E501 + error: StrictStr = Field(description="invalid_request, unsupported_grant_type, invalid_grant or temporarily_unavailable") + error_description: StrictStr + __properties: ClassVar[List[str]] = ["error", "error_description"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of OAuthErrorResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OAuthErrorResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "error": obj.get("error"), + "error_description": obj.get("error_description") + }) + return _obj + +