diff --git a/sdk-endpoints.txt b/sdk-endpoints.txt index 61be008e..53ea0957 100644 --- a/sdk-endpoints.txt +++ b/sdk-endpoints.txt @@ -146,6 +146,10 @@ DELETE /api/v1/auth/session # dashboard-only # flow. An SDK authenticates with the master key or an API key and never holds # a password, so there is nothing here for one to wrap. PUT /api/v1/auth/password # dashboard-only +# The name the signed-in identity goes by: the account page's own write, beside +# the credential ones. An SDK authenticates as a key rather than as a person and +# has no account page to render, so there is nothing here for one to wrap. +PATCH /api/v1/auth/profile # dashboard-only # Signup, email verification, and password reset (otari#650): claiming a # roster identity's dashboard login and recovering it, the same browser-only # credential flow PUT /api/v1/auth/password is. No SDK caller holds a password. diff --git a/src/otari/_client/__init__.py b/src/otari/_client/__init__.py index 47c4596a..e498368a 100644 --- a/src/otari/_client/__init__.py +++ b/src/otari/_client/__init__.py @@ -533,6 +533,7 @@ "UpdateKeyRequest", "UpdateMaintenanceModeRequest", "UpdateOwnKeyRequest", + "UpdateProfileRequest", "UpdateScopedBudgetRequest", "UpdateSearchToolRequest", "UpdateSettingsRequest", @@ -1116,6 +1117,7 @@ from otari._client.models.update_key_request import UpdateKeyRequest as UpdateKeyRequest from otari._client.models.update_maintenance_mode_request import UpdateMaintenanceModeRequest as UpdateMaintenanceModeRequest from otari._client.models.update_own_key_request import UpdateOwnKeyRequest as UpdateOwnKeyRequest +from otari._client.models.update_profile_request import UpdateProfileRequest as UpdateProfileRequest from otari._client.models.update_scoped_budget_request import UpdateScopedBudgetRequest as UpdateScopedBudgetRequest from otari._client.models.update_search_tool_request import UpdateSearchToolRequest as UpdateSearchToolRequest from otari._client.models.update_settings_request import UpdateSettingsRequest as UpdateSettingsRequest diff --git a/src/otari/_client/api/auth_api.py b/src/otari/_client/api/auth_api.py index 421ecc0b..a4a93553 100644 --- a/src/otari/_client/api/auth_api.py +++ b/src/otari/_client/api/auth_api.py @@ -21,6 +21,7 @@ from uuid import UUID from otari._client.models.authenticate_passkey_request import AuthenticatePasskeyRequest from otari._client.models.authorize_response import AuthorizeResponse +from otari._client.models.caller_identity_public import CallerIdentityPublic from otari._client.models.create_session_request import CreateSessionRequest from otari._client.models.o_auth_callback_request import OAuthCallbackRequest from otari._client.models.o_auth_session_response import OAuthSessionResponse @@ -36,6 +37,7 @@ from otari._client.models.set_password_request import SetPasswordRequest from otari._client.models.signup_request import SignupRequest from otari._client.models.signup_response import SignupResponse +from otari._client.models.update_profile_request import UpdateProfileRequest from otari._client.models.verify_email_request import VerifyEmailRequest from otari._client.models.verify_email_response import VerifyEmailResponse from otari._client.models.web_authn_credential_public import WebAuthnCredentialPublic @@ -4361,6 +4363,284 @@ def _auth_signup_serialize( + @validate_call + def auth_update_own_profile( + self, + update_profile_request: UpdateProfileRequest, + _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, + ) -> CallerIdentityPublic: + """Update Own Profile + + Change the name the caller is known by on this deployment. Always the caller's own identity. The same shape ``GET /api/v1/organizations/me`` carries as ``caller`` comes back, so a client can seat the answer where it read the old value rather than refetch the whole membership context. + + :param update_profile_request: (required) + :type update_profile_request: UpdateProfileRequest + :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._auth_update_own_profile_serialize( + update_profile_request=update_profile_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CallerIdentityPublic", + '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 auth_update_own_profile_with_http_info( + self, + update_profile_request: UpdateProfileRequest, + _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[CallerIdentityPublic]: + """Update Own Profile + + Change the name the caller is known by on this deployment. Always the caller's own identity. The same shape ``GET /api/v1/organizations/me`` carries as ``caller`` comes back, so a client can seat the answer where it read the old value rather than refetch the whole membership context. + + :param update_profile_request: (required) + :type update_profile_request: UpdateProfileRequest + :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._auth_update_own_profile_serialize( + update_profile_request=update_profile_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CallerIdentityPublic", + '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 auth_update_own_profile_without_preload_content( + self, + update_profile_request: UpdateProfileRequest, + _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 Own Profile + + Change the name the caller is known by on this deployment. Always the caller's own identity. The same shape ``GET /api/v1/organizations/me`` carries as ``caller`` comes back, so a client can seat the answer where it read the old value rather than refetch the whole membership context. + + :param update_profile_request: (required) + :type update_profile_request: UpdateProfileRequest + :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._auth_update_own_profile_serialize( + update_profile_request=update_profile_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "CallerIdentityPublic", + '422': "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _auth_update_own_profile_serialize( + self, + update_profile_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 update_profile_request is not None: + _body_params = update_profile_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/auth/profile', + 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 auth_verify_email_route( self, diff --git a/src/otari/_client/models/__init__.py b/src/otari/_client/models/__init__.py index ea90e622..85119890 100644 --- a/src/otari/_client/models/__init__.py +++ b/src/otari/_client/models/__init__.py @@ -471,6 +471,7 @@ from otari._client.models.update_key_request import UpdateKeyRequest from otari._client.models.update_maintenance_mode_request import UpdateMaintenanceModeRequest from otari._client.models.update_own_key_request import UpdateOwnKeyRequest +from otari._client.models.update_profile_request import UpdateProfileRequest from otari._client.models.update_scoped_budget_request import UpdateScopedBudgetRequest from otari._client.models.update_search_tool_request import UpdateSearchToolRequest from otari._client.models.update_settings_request import UpdateSettingsRequest diff --git a/src/otari/_client/models/update_profile_request.py b/src/otari/_client/models/update_profile_request.py new file mode 100644 index 00000000..62e96c29 --- /dev/null +++ b/src/otari/_client/models/update_profile_request.py @@ -0,0 +1,94 @@ +# 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 UpdateProfileRequest(BaseModel): + """ + The caller's own display name, or ``null`` to go back to having none. + """ # noqa: E501 + full_name: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(description="The name to be known by on this deployment, or null to have none. Whitespace is collapsed, and a value with nothing else in it is stored as null, which leaves every surface naming this identity by its address again.") + __properties: ClassVar[List[str]] = ["full_name"] + + 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 UpdateProfileRequest 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 full_name (nullable) is None + # and model_fields_set contains the field + if self.full_name is None and "full_name" in self.model_fields_set: + _dict['full_name'] = None + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpdateProfileRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "full_name": obj.get("full_name") + }) + return _obj + +