diff --git a/sdk-endpoints.txt b/sdk-endpoints.txt index 1db4c6c4..19c749fa 100644 --- a/sdk-endpoints.txt +++ b/sdk-endpoints.txt @@ -304,6 +304,8 @@ GET /api/v1/tools # not yet wrapped GET /api/v1/tool-settings # not yet wrapped PATCH /api/v1/tool-settings # not yet wrapped POST /api/v1/tool-settings/{service}/test # not yet wrapped +PUT /api/v1/tool-settings/sandbox/credential # not yet wrapped +DELETE /api/v1/tool-settings/sandbox/credential # not yet wrapped GET /api/v1/tool-settings/guardrails/profiles # not yet wrapped GET /api/v1/tool-settings/guardrails/catalog # not yet wrapped POST /api/v1/search # not yet wrapped diff --git a/src/otari/_client/__init__.py b/src/otari/_client/__init__.py index 929f35c6..cdaf782a 100644 --- a/src/otari/_client/__init__.py +++ b/src/otari/_client/__init__.py @@ -665,6 +665,8 @@ "ResponsesRequest", "RotateMasterKeyResponse", "RouterStatus", + "SandboxCredentialPublic", + "SandboxCredentialRequest", "SandboxProvider", "ScopedBudgetResponse", "ScoreQuestion", @@ -1441,6 +1443,8 @@ from otari._client.models.responses_request import ResponsesRequest as ResponsesRequest from otari._client.models.rotate_master_key_response import RotateMasterKeyResponse as RotateMasterKeyResponse from otari._client.models.router_status import RouterStatus as RouterStatus +from otari._client.models.sandbox_credential_public import SandboxCredentialPublic as SandboxCredentialPublic +from otari._client.models.sandbox_credential_request import SandboxCredentialRequest as SandboxCredentialRequest from otari._client.models.sandbox_provider import SandboxProvider as SandboxProvider from otari._client.models.scoped_budget_response import ScopedBudgetResponse as ScopedBudgetResponse from otari._client.models.score_question import ScoreQuestion as ScoreQuestion diff --git a/src/otari/_client/api/tool_settings_api.py b/src/otari/_client/api/tool_settings_api.py index c84eaaeb..46132948 100644 --- a/src/otari/_client/api/tool_settings_api.py +++ b/src/otari/_client/api/tool_settings_api.py @@ -18,6 +18,8 @@ from pydantic import StrictStr from otari._client.models.built_in_guardrail_catalog import BuiltInGuardrailCatalog from otari._client.models.guardrail_catalog import GuardrailCatalog +from otari._client.models.sandbox_credential_public import SandboxCredentialPublic +from otari._client.models.sandbox_credential_request import SandboxCredentialRequest from otari._client.models.test_service_request import TestServiceRequest from otari._client.models.test_service_response import TestServiceResponse from otari._client.models.tool_settings_response import ToolSettingsResponse @@ -41,6 +43,253 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client + @validate_call + def tool_settings_clear_sandbox_credential( + 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, + ) -> SandboxCredentialPublic: + """Clear Sandbox Credential + + Delete the stored sandbox key, so sandboxes are leased with the environment's key again. Clearing a key that was never stored is not an error. Operator-gated. + + :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._tool_settings_clear_sandbox_credential_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + } + 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 tool_settings_clear_sandbox_credential_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[SandboxCredentialPublic]: + """Clear Sandbox Credential + + Delete the stored sandbox key, so sandboxes are leased with the environment's key again. Clearing a key that was never stored is not an error. Operator-gated. + + :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._tool_settings_clear_sandbox_credential_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + } + 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 tool_settings_clear_sandbox_credential_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: + """Clear Sandbox Credential + + Delete the stored sandbox key, so sandboxes are leased with the environment's key again. Clearing a key that was never stored is not an error. Operator-gated. + + :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._tool_settings_clear_sandbox_credential_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _tool_settings_clear_sandbox_credential_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/tool-settings/sandbox/credential', + 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 tool_settings_get_tool_settings( self, @@ -782,6 +1031,284 @@ def _tool_settings_list_guardrail_profiles_serialize( + @validate_call + def tool_settings_set_sandbox_credential( + self, + sandbox_credential_request: SandboxCredentialRequest, + _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, + ) -> SandboxCredentialPublic: + """Set Sandbox Credential + + Store the key this deployment's hosted sandbox provider leases sandboxes with. Wins over the provider's environment variable (``E2B_API_KEY``), on this worker at once and on every other within 30 seconds, so a rotated key needs no redeploy. Refused for the ``protocol`` provider, which takes no key of its own. Operator-gated. + + :param sandbox_credential_request: (required) + :type sandbox_credential_request: SandboxCredentialRequest + :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._tool_settings_set_sandbox_credential_serialize( + sandbox_credential_request=sandbox_credential_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + '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 tool_settings_set_sandbox_credential_with_http_info( + self, + sandbox_credential_request: SandboxCredentialRequest, + _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[SandboxCredentialPublic]: + """Set Sandbox Credential + + Store the key this deployment's hosted sandbox provider leases sandboxes with. Wins over the provider's environment variable (``E2B_API_KEY``), on this worker at once and on every other within 30 seconds, so a rotated key needs no redeploy. Refused for the ``protocol`` provider, which takes no key of its own. Operator-gated. + + :param sandbox_credential_request: (required) + :type sandbox_credential_request: SandboxCredentialRequest + :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._tool_settings_set_sandbox_credential_serialize( + sandbox_credential_request=sandbox_credential_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + '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 tool_settings_set_sandbox_credential_without_preload_content( + self, + sandbox_credential_request: SandboxCredentialRequest, + _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: + """Set Sandbox Credential + + Store the key this deployment's hosted sandbox provider leases sandboxes with. Wins over the provider's environment variable (``E2B_API_KEY``), on this worker at once and on every other within 30 seconds, so a rotated key needs no redeploy. Refused for the ``protocol`` provider, which takes no key of its own. Operator-gated. + + :param sandbox_credential_request: (required) + :type sandbox_credential_request: SandboxCredentialRequest + :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._tool_settings_set_sandbox_credential_serialize( + sandbox_credential_request=sandbox_credential_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SandboxCredentialPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _tool_settings_set_sandbox_credential_serialize( + self, + sandbox_credential_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 sandbox_credential_request is not None: + _body_params = sandbox_credential_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='PUT', + resource_path='/api/v1/tool-settings/sandbox/credential', + 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 tool_settings_test_service( self, diff --git a/src/otari/_client/models/__init__.py b/src/otari/_client/models/__init__.py index ee52916f..c7c02d94 100644 --- a/src/otari/_client/models/__init__.py +++ b/src/otari/_client/models/__init__.py @@ -589,6 +589,8 @@ from otari._client.models.responses_request import ResponsesRequest from otari._client.models.rotate_master_key_response import RotateMasterKeyResponse from otari._client.models.router_status import RouterStatus +from otari._client.models.sandbox_credential_public import SandboxCredentialPublic +from otari._client.models.sandbox_credential_request import SandboxCredentialRequest from otari._client.models.sandbox_provider import SandboxProvider from otari._client.models.scoped_budget_response import ScopedBudgetResponse from otari._client.models.score_question import ScoreQuestion diff --git a/src/otari/_client/models/sandbox_credential_public.py b/src/otari/_client/models/sandbox_credential_public.py new file mode 100644 index 00000000..fd467341 --- /dev/null +++ b/src/otari/_client/models/sandbox_credential_public.py @@ -0,0 +1,112 @@ +# 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 +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class SandboxCredentialPublic(BaseModel): + """ + Where the key a hosted sandbox provider leases with comes from. Never the key itself. + """ # noqa: E501 + env_var: StrictStr = Field(description="The environment variable a deployment that stores no key is read from.") + last4: Optional[StrictStr] = Field(default=None, description="The key's last four characters, to tell keys apart.") + source: Optional[StrictStr] = Field(description="'stored' for a key set here, which wins; 'environment' for the provider's own environment variable; null when there is neither and code execution fails until one is set.") + __properties: ClassVar[List[str]] = ["env_var", "last4", "source"] + + @field_validator('source') + def source_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['stored', 'environment']): + raise ValueError("must be one of enum values ('stored', 'environment')") + 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 SandboxCredentialPublic 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 last4 (nullable) is None + # and model_fields_set contains the field + if self.last4 is None and "last4" in self.model_fields_set: + _dict['last4'] = None + + # set to None if source (nullable) is None + # and model_fields_set contains the field + if self.source is None and "source" in self.model_fields_set: + _dict['source'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SandboxCredentialPublic from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "env_var": obj.get("env_var"), + "last4": obj.get("last4"), + "source": obj.get("source") + }) + return _obj + + diff --git a/src/otari/_client/models/sandbox_credential_request.py b/src/otari/_client/models/sandbox_credential_request.py new file mode 100644 index 00000000..d9f506a2 --- /dev/null +++ b/src/otari/_client/models/sandbox_credential_request.py @@ -0,0 +1,89 @@ +# 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 +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class SandboxCredentialRequest(BaseModel): + """ + The key to lease hosted sandboxes with. + """ # noqa: E501 + api_key: Annotated[str, Field(min_length=1, strict=True)] + __properties: ClassVar[List[str]] = ["api_key"] + + 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 SandboxCredentialRequest 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 SandboxCredentialRequest 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": obj.get("api_key") + }) + return _obj + + diff --git a/src/otari/_client/models/tool_settings_response.py b/src/otari/_client/models/tool_settings_response.py index d16830b0..664c23e5 100644 --- a/src/otari/_client/models/tool_settings_response.py +++ b/src/otari/_client/models/tool_settings_response.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional +from otari._client.models.sandbox_credential_public import SandboxCredentialPublic from otari._client.models.sandbox_provider import SandboxProvider from otari._client.models.tool_setting_field import ToolSettingField from typing import Optional, Set @@ -30,8 +31,9 @@ class ToolSettingsResponse(BaseModel): The effective value of every editable tool/guardrail field. """ # noqa: E501 fields: List[ToolSettingField] + sandbox_credential: Optional[SandboxCredentialPublic] = Field(default=None, description="The key a hosted sandbox_provider leases with. Null for the protocol provider, which takes none, and for a reader who does not operate the deployment.") sandbox_provider: Optional[SandboxProvider] = Field(default=None, description="What runs generated code: 'protocol' (a sandbox at sandbox_url) or 'e2b'. Set at startup, not editable here. Null for a reader who does not operate the deployment.") - __properties: ClassVar[List[str]] = ["fields", "sandbox_provider"] + __properties: ClassVar[List[str]] = ["fields", "sandbox_credential", "sandbox_provider"] model_config = ConfigDict( validate_by_name=True, @@ -79,6 +81,14 @@ def to_dict(self) -> Dict[str, Any]: if _item_fields: _items.append(_item_fields.to_dict()) _dict['fields'] = _items + # override the default output from pydantic by calling `to_dict()` of sandbox_credential + if self.sandbox_credential: + _dict['sandbox_credential'] = self.sandbox_credential.to_dict() + # set to None if sandbox_credential (nullable) is None + # and model_fields_set contains the field + if self.sandbox_credential is None and "sandbox_credential" in self.model_fields_set: + _dict['sandbox_credential'] = None + # set to None if sandbox_provider (nullable) is None # and model_fields_set contains the field if self.sandbox_provider is None and "sandbox_provider" in self.model_fields_set: @@ -97,6 +107,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "fields": [ToolSettingField.from_dict(_item) for _item in obj["fields"]] if obj.get("fields") is not None else None, + "sandbox_credential": SandboxCredentialPublic.from_dict(obj["sandbox_credential"]) if obj.get("sandbox_credential") is not None else None, "sandbox_provider": obj.get("sandbox_provider") }) return _obj