From 562be2b3cd6c2d388deff45b94ea8bfbda09600c Mon Sep 17 00:00:00 2001 From: Borys Tkachenko Date: Thu, 12 Dec 2024 09:52:39 +0100 Subject: [PATCH] OPIK-548 Autogenerated code --- .../opik/domain/LlmProviderApiKeyService.java | 8 +- .../documentation/rest_api/opik.yaml | 123 ++++---- .../code_generation/fern/openapi/openapi.yaml | 123 ++++---- .../opik/rest_api/llm_provider_key/client.py | 267 ++++++++++++------ .../llmProviderKey/client/Client.d.ts | 39 ++- .../resources/llmProviderKey/client/Client.js | 126 ++++++--- .../llmProviderKey/client/requests/index.d.ts | 2 +- .../src/opik/rest_api/api/types/index.d.ts | 2 +- .../src/opik/rest_api/api/types/index.js | 2 +- .../llmProviderKey/client/requests/index.d.ts | 2 +- .../llmProviderKey/client/requests/index.js | 6 +- .../rest_api/serialization/types/index.d.ts | 2 +- .../rest_api/serialization/types/index.js | 2 +- 13 files changed, 444 insertions(+), 260 deletions(-) diff --git a/apps/opik-backend/src/main/java/com/comet/opik/domain/LlmProviderApiKeyService.java b/apps/opik-backend/src/main/java/com/comet/opik/domain/LlmProviderApiKeyService.java index 5b8bcac421..7a0be49362 100644 --- a/apps/opik-backend/src/main/java/com/comet/opik/domain/LlmProviderApiKeyService.java +++ b/apps/opik-backend/src/main/java/com/comet/opik/domain/LlmProviderApiKeyService.java @@ -73,7 +73,8 @@ public Page find(@NonNull String workspaceId) { } @Override - public ProviderApiKey saveApiKey(@NonNull ProviderApiKey providerApiKey, @NonNull String userName, @NonNull String workspaceId) { + public ProviderApiKey saveApiKey(@NonNull ProviderApiKey providerApiKey, @NonNull String userName, + @NonNull String workspaceId) { UUID apiKeyId = idGenerator.generateId(); var newProviderApiKey = providerApiKey.toBuilder() @@ -102,8 +103,9 @@ public ProviderApiKey saveApiKey(@NonNull ProviderApiKey providerApiKey, @NonNul } @Override - public void updateApiKey(@NonNull UUID id, @NonNull ProviderApiKeyUpdate providerApiKeyUpdate, @NonNull String userName, - @NonNull String workspaceId) { + public void updateApiKey(@NonNull UUID id, @NonNull ProviderApiKeyUpdate providerApiKeyUpdate, + @NonNull String userName, + @NonNull String workspaceId) { template.inTransaction(WRITE, handle -> { diff --git a/apps/opik-documentation/documentation/rest_api/opik.yaml b/apps/opik-documentation/documentation/rest_api/opik.yaml index 29f8366390..220336df78 100644 --- a/apps/opik-documentation/documentation/rest_api/opik.yaml +++ b/apps/opik-documentation/documentation/rest_api/opik.yaml @@ -877,6 +877,53 @@ paths: responses: "204": description: No Content + /v1/private/llm-provider-key: + get: + tags: + - LlmProviderKey + summary: Find LLM Provider's ApiKeys + description: Find LLM Provider's ApiKeys + operationId: findLlmProviderKeys + responses: + "200": + description: LLMProviderApiKey resource + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectPage_Public' + post: + tags: + - LlmProviderKey + summary: Store LLM Provider's ApiKey + description: Store LLM Provider's ApiKey + operationId: storeLlmProviderApiKey + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProviderApiKey_Write' + responses: + "201": + description: Created + headers: + Location: + required: true + style: simple + schema: + type: string + example: "${basePath}/v1/private/proxy/api_key/{apiKeyId}" + "401": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + "403": + description: Access forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' /v1/private/llm-provider-key/{id}: get: tags: @@ -893,7 +940,7 @@ paths: format: uuid responses: "200": - description: ProviderApiKey resource + description: LLMProviderApiKey resource content: application/json: schema: @@ -943,40 +990,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorMessage' - /v1/private/llm-provider-key: - post: - tags: - - LlmProviderKey - summary: Store LLM Provider's ApiKey - description: Store LLM Provider's ApiKey - operationId: storeLlmProviderApiKey - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ProviderApiKey_Write' - responses: - "201": - description: Created - headers: - Location: - required: true - style: simple - schema: - type: string - example: "${basePath}/v1/private/proxy/api_key/{apiKeyId}" - "401": - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - "403": - description: Access forbidden - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' /v1/private/projects: get: tags: @@ -3751,6 +3764,26 @@ components: type: number min: type: number + ProjectPage_Public: + type: object + properties: + page: + type: integer + format: int32 + size: + type: integer + format: int32 + total: + type: integer + format: int64 + content: + type: array + items: + $ref: '#/components/schemas/Project_Public' + sortableBy: + type: array + items: + type: string ProviderApiKey_Public: type: object properties: @@ -3863,26 +3896,6 @@ components: type: string description: type: string - ProjectPage_Public: - type: object - properties: - page: - type: integer - format: int32 - size: - type: integer - format: int32 - total: - type: integer - format: int64 - content: - type: array - items: - $ref: '#/components/schemas/Project_Public' - sortableBy: - type: array - items: - type: string Project_Public: required: - name diff --git a/sdks/code_generation/fern/openapi/openapi.yaml b/sdks/code_generation/fern/openapi/openapi.yaml index 29f8366390..220336df78 100644 --- a/sdks/code_generation/fern/openapi/openapi.yaml +++ b/sdks/code_generation/fern/openapi/openapi.yaml @@ -877,6 +877,53 @@ paths: responses: "204": description: No Content + /v1/private/llm-provider-key: + get: + tags: + - LlmProviderKey + summary: Find LLM Provider's ApiKeys + description: Find LLM Provider's ApiKeys + operationId: findLlmProviderKeys + responses: + "200": + description: LLMProviderApiKey resource + content: + application/json: + schema: + $ref: '#/components/schemas/ProjectPage_Public' + post: + tags: + - LlmProviderKey + summary: Store LLM Provider's ApiKey + description: Store LLM Provider's ApiKey + operationId: storeLlmProviderApiKey + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ProviderApiKey_Write' + responses: + "201": + description: Created + headers: + Location: + required: true + style: simple + schema: + type: string + example: "${basePath}/v1/private/proxy/api_key/{apiKeyId}" + "401": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' + "403": + description: Access forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMessage' /v1/private/llm-provider-key/{id}: get: tags: @@ -893,7 +940,7 @@ paths: format: uuid responses: "200": - description: ProviderApiKey resource + description: LLMProviderApiKey resource content: application/json: schema: @@ -943,40 +990,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorMessage' - /v1/private/llm-provider-key: - post: - tags: - - LlmProviderKey - summary: Store LLM Provider's ApiKey - description: Store LLM Provider's ApiKey - operationId: storeLlmProviderApiKey - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ProviderApiKey_Write' - responses: - "201": - description: Created - headers: - Location: - required: true - style: simple - schema: - type: string - example: "${basePath}/v1/private/proxy/api_key/{apiKeyId}" - "401": - description: Bad Request - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' - "403": - description: Access forbidden - content: - application/json: - schema: - $ref: '#/components/schemas/ErrorMessage' /v1/private/projects: get: tags: @@ -3751,6 +3764,26 @@ components: type: number min: type: number + ProjectPage_Public: + type: object + properties: + page: + type: integer + format: int32 + size: + type: integer + format: int32 + total: + type: integer + format: int64 + content: + type: array + items: + $ref: '#/components/schemas/Project_Public' + sortableBy: + type: array + items: + type: string ProviderApiKey_Public: type: object properties: @@ -3863,26 +3896,6 @@ components: type: string description: type: string - ProjectPage_Public: - type: object - properties: - page: - type: integer - format: int32 - size: - type: integer - format: int32 - total: - type: integer - format: int64 - content: - type: array - items: - $ref: '#/components/schemas/Project_Public' - sortableBy: - type: array - items: - type: string Project_Public: required: - name diff --git a/sdks/python/src/opik/rest_api/llm_provider_key/client.py b/sdks/python/src/opik/rest_api/llm_provider_key/client.py index 6c25210b67..0d534c1341 100644 --- a/sdks/python/src/opik/rest_api/llm_provider_key/client.py +++ b/sdks/python/src/opik/rest_api/llm_provider_key/client.py @@ -3,15 +3,16 @@ import typing from ..core.client_wrapper import SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.provider_api_key_public import ProviderApiKeyPublic -from ..core.jsonable_encoder import jsonable_encoder +from ..types.project_page_public import ProjectPagePublic from ..core.pydantic_utilities import parse_obj_as -from ..errors.not_found_error import NotFoundError from json.decoder import JSONDecodeError from ..core.api_error import ApiError from ..errors.unauthorized_error import UnauthorizedError from ..types.error_message import ErrorMessage from ..errors.forbidden_error import ForbiddenError +from ..types.provider_api_key_public import ProviderApiKeyPublic +from ..core.jsonable_encoder import jsonable_encoder +from ..errors.not_found_error import NotFoundError from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters @@ -22,78 +23,64 @@ class LlmProviderKeyClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def get_llm_provider_api_key_by_id( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> ProviderApiKeyPublic: + def find_llm_provider_keys( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectPagePublic: """ - Get LLM Provider's ApiKey by id + Find LLM Provider's ApiKeys Parameters ---------- - id : str - request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - ProviderApiKeyPublic - ProviderApiKey resource + ProjectPagePublic + LLMProviderApiKey resource Examples -------- from Opik import OpikApi client = OpikApi() - client.llm_provider_key.get_llm_provider_api_key_by_id( - id="id", - ) + client.llm_provider_key.find_llm_provider_keys() """ _response = self._client_wrapper.httpx_client.request( - f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + "v1/private/llm-provider-key", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: return typing.cast( - ProviderApiKeyPublic, + ProjectPagePublic, parse_obj_as( - type_=ProviderApiKeyPublic, # type: ignore + type_=ProjectPagePublic, # type: ignore object_=_response.json(), ), ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - parse_obj_as( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def update_llm_provider_api_key( + def store_llm_provider_api_key( self, - id: str, *, api_key: str, + provider: typing.Optional[typing.Literal["openai"]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Update LLM Provider's ApiKey + Store LLM Provider's ApiKey Parameters ---------- - id : str - api_key : str + provider : typing.Optional[typing.Literal["openai"]] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -106,15 +93,15 @@ def update_llm_provider_api_key( from Opik import OpikApi client = OpikApi() - client.llm_provider_key.update_llm_provider_api_key( - id="id", + client.llm_provider_key.store_llm_provider_api_key( api_key="api_key", ) """ _response = self._client_wrapper.httpx_client.request( - f"v1/private/llm-provider-key/{jsonable_encoder(id)}", - method="PATCH", + "v1/private/llm-provider-key", + method="POST", json={ + "provider": provider, "api_key": api_key, }, headers={ @@ -146,6 +133,52 @@ def update_llm_provider_api_key( ), ) ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get_llm_provider_api_key_by_id( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProviderApiKeyPublic: + """ + Get LLM Provider's ApiKey by id + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProviderApiKeyPublic + LLMProviderApiKey resource + + Examples + -------- + from Opik import OpikApi + + client = OpikApi() + client.llm_provider_key.get_llm_provider_api_key_by_id( + id="id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ProviderApiKeyPublic, + parse_obj_as( + type_=ProviderApiKeyPublic, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 404: raise NotFoundError( typing.cast( @@ -161,21 +194,21 @@ def update_llm_provider_api_key( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def store_llm_provider_api_key( + def update_llm_provider_api_key( self, + id: str, *, api_key: str, - provider: typing.Optional[typing.Literal["openai"]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Store LLM Provider's ApiKey + Update LLM Provider's ApiKey Parameters ---------- - api_key : str + id : str - provider : typing.Optional[typing.Literal["openai"]] + api_key : str request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -189,15 +222,15 @@ def store_llm_provider_api_key( from Opik import OpikApi client = OpikApi() - client.llm_provider_key.store_llm_provider_api_key( + client.llm_provider_key.update_llm_provider_api_key( + id="id", api_key="api_key", ) """ _response = self._client_wrapper.httpx_client.request( - "v1/private/llm-provider-key", - method="POST", + f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + method="PATCH", json={ - "provider": provider, "api_key": api_key, }, headers={ @@ -229,6 +262,16 @@ def store_llm_provider_api_key( ), ) ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) @@ -239,23 +282,21 @@ class AsyncLlmProviderKeyClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def get_llm_provider_api_key_by_id( - self, id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> ProviderApiKeyPublic: + async def find_llm_provider_keys( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectPagePublic: """ - Get LLM Provider's ApiKey by id + Find LLM Provider's ApiKeys Parameters ---------- - id : str - request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - ProviderApiKeyPublic - ProviderApiKey resource + ProjectPagePublic + LLMProviderApiKey resource Examples -------- @@ -267,58 +308,46 @@ async def get_llm_provider_api_key_by_id( async def main() -> None: - await client.llm_provider_key.get_llm_provider_api_key_by_id( - id="id", - ) + await client.llm_provider_key.find_llm_provider_keys() asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + "v1/private/llm-provider-key", method="GET", request_options=request_options, ) try: if 200 <= _response.status_code < 300: return typing.cast( - ProviderApiKeyPublic, + ProjectPagePublic, parse_obj_as( - type_=ProviderApiKeyPublic, # type: ignore + type_=ProjectPagePublic, # type: ignore object_=_response.json(), ), ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - parse_obj_as( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def update_llm_provider_api_key( + async def store_llm_provider_api_key( self, - id: str, *, api_key: str, + provider: typing.Optional[typing.Literal["openai"]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Update LLM Provider's ApiKey + Store LLM Provider's ApiKey Parameters ---------- - id : str - api_key : str + provider : typing.Optional[typing.Literal["openai"]] + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -336,8 +365,7 @@ async def update_llm_provider_api_key( async def main() -> None: - await client.llm_provider_key.update_llm_provider_api_key( - id="id", + await client.llm_provider_key.store_llm_provider_api_key( api_key="api_key", ) @@ -345,9 +373,10 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - f"v1/private/llm-provider-key/{jsonable_encoder(id)}", - method="PATCH", + "v1/private/llm-provider-key", + method="POST", json={ + "provider": provider, "api_key": api_key, }, headers={ @@ -379,6 +408,60 @@ async def main() -> None: ), ) ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get_llm_provider_api_key_by_id( + self, id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProviderApiKeyPublic: + """ + Get LLM Provider's ApiKey by id + + Parameters + ---------- + id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProviderApiKeyPublic + LLMProviderApiKey resource + + Examples + -------- + import asyncio + + from Opik import AsyncOpikApi + + client = AsyncOpikApi() + + + async def main() -> None: + await client.llm_provider_key.get_llm_provider_api_key_by_id( + id="id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + ProviderApiKeyPublic, + parse_obj_as( + type_=ProviderApiKeyPublic, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 404: raise NotFoundError( typing.cast( @@ -394,21 +477,21 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - async def store_llm_provider_api_key( + async def update_llm_provider_api_key( self, + id: str, *, api_key: str, - provider: typing.Optional[typing.Literal["openai"]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> None: """ - Store LLM Provider's ApiKey + Update LLM Provider's ApiKey Parameters ---------- - api_key : str + id : str - provider : typing.Optional[typing.Literal["openai"]] + api_key : str request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -427,7 +510,8 @@ async def store_llm_provider_api_key( async def main() -> None: - await client.llm_provider_key.store_llm_provider_api_key( + await client.llm_provider_key.update_llm_provider_api_key( + id="id", api_key="api_key", ) @@ -435,10 +519,9 @@ async def main() -> None: asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( - "v1/private/llm-provider-key", - method="POST", + f"v1/private/llm-provider-key/{jsonable_encoder(id)}", + method="PATCH", json={ - "provider": provider, "api_key": api_key, }, headers={ @@ -470,6 +553,16 @@ async def main() -> None: ), ) ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, body=_response.text) diff --git a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.d.ts b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.d.ts index 574d28eea6..6b6310b741 100644 --- a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.d.ts +++ b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.d.ts @@ -25,6 +25,30 @@ export declare namespace LlmProviderKey { export declare class LlmProviderKey { protected readonly _options: LlmProviderKey.Options; constructor(_options?: LlmProviderKey.Options); + /** + * Find LLM Provider's ApiKeys + * + * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.llmProviderKey.findLlmProviderKeys() + */ + findLlmProviderKeys(requestOptions?: LlmProviderKey.RequestOptions): core.APIPromise; + /** + * Store LLM Provider's ApiKey + * + * @param {OpikApi.ProviderApiKeyWrite} request + * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link OpikApi.UnauthorizedError} + * @throws {@link OpikApi.ForbiddenError} + * + * @example + * await client.llmProviderKey.storeLlmProviderApiKey({ + * apiKey: "api_key" + * }) + */ + storeLlmProviderApiKey(request: OpikApi.ProviderApiKeyWrite, requestOptions?: LlmProviderKey.RequestOptions): core.APIPromise; /** * Get LLM Provider's ApiKey by id * @@ -54,19 +78,4 @@ export declare class LlmProviderKey { * }) */ updateLlmProviderApiKey(id: string, request: OpikApi.ProviderApiKeyUpdate, requestOptions?: LlmProviderKey.RequestOptions): core.APIPromise; - /** - * Store LLM Provider's ApiKey - * - * @param {OpikApi.ProviderApiKeyWrite} request - * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link OpikApi.UnauthorizedError} - * @throws {@link OpikApi.ForbiddenError} - * - * @example - * await client.llmProviderKey.storeLlmProviderApiKey({ - * apiKey: "api_key" - * }) - */ - storeLlmProviderApiKey(request: OpikApi.ProviderApiKeyWrite, requestOptions?: LlmProviderKey.RequestOptions): core.APIPromise; } diff --git a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.js b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.js index 4a0bd45c9b..70282560bc 100644 --- a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.js +++ b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/Client.js @@ -53,21 +53,18 @@ class LlmProviderKey { this._options = _options; } /** - * Get LLM Provider's ApiKey by id + * Find LLM Provider's ApiKeys * - * @param {string} id * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. * - * @throws {@link OpikApi.NotFoundError} - * * @example - * await client.llmProviderKey.getLlmProviderApiKeyById("id") + * await client.llmProviderKey.findLlmProviderKeys() */ - getLlmProviderApiKeyById(id, requestOptions) { + findLlmProviderKeys(requestOptions) { return core.APIPromise.from((() => __awaiter(this, void 0, void 0, function* () { var _a; const _response = yield core.fetcher({ - url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, `v1/private/llm-provider-key/${encodeURIComponent(id)}`), + url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, "v1/private/llm-provider-key"), method: "GET", headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), contentType: "application/json", @@ -79,7 +76,7 @@ class LlmProviderKey { if (_response.ok) { return { ok: _response.ok, - body: serializers.ProviderApiKeyPublic.parseOrThrow(_response.body, { + body: serializers.ProjectPagePublic.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, @@ -89,15 +86,10 @@ class LlmProviderKey { }; } if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 404: - throw new OpikApi.NotFoundError(_response.error.body); - default: - throw new errors.OpikApiError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } + throw new errors.OpikApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); } switch (_response.error.reason) { case "non-json": @@ -106,7 +98,7 @@ class LlmProviderKey { body: _response.error.rawBody, }); case "timeout": - throw new errors.OpikApiTimeoutError("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}."); + throw new errors.OpikApiTimeoutError("Timeout exceeded when calling GET /v1/private/llm-provider-key."); case "unknown": throw new errors.OpikApiError({ message: _response.error.errorMessage, @@ -115,31 +107,29 @@ class LlmProviderKey { }))()); } /** - * Update LLM Provider's ApiKey + * Store LLM Provider's ApiKey * - * @param {string} id - * @param {OpikApi.ProviderApiKeyUpdate} request + * @param {OpikApi.ProviderApiKeyWrite} request * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link OpikApi.UnauthorizedError} * @throws {@link OpikApi.ForbiddenError} - * @throws {@link OpikApi.NotFoundError} * * @example - * await client.llmProviderKey.updateLlmProviderApiKey("id", { + * await client.llmProviderKey.storeLlmProviderApiKey({ * apiKey: "api_key" * }) */ - updateLlmProviderApiKey(id, request, requestOptions) { + storeLlmProviderApiKey(request, requestOptions) { return core.APIPromise.from((() => __awaiter(this, void 0, void 0, function* () { var _a; const _response = yield core.fetcher({ - url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, `v1/private/llm-provider-key/${encodeURIComponent(id)}`), - method: "PATCH", + url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, "v1/private/llm-provider-key"), + method: "POST", headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), contentType: "application/json", requestType: "json", - body: serializers.ProviderApiKeyUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: serializers.ProviderApiKeyWrite.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, @@ -167,6 +157,66 @@ class LlmProviderKey { allowUnrecognizedEnumValues: true, breadcrumbsPrefix: ["response"], })); + default: + throw new errors.OpikApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + switch (_response.error.reason) { + case "non-json": + throw new errors.OpikApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.OpikApiTimeoutError("Timeout exceeded when calling POST /v1/private/llm-provider-key."); + case "unknown": + throw new errors.OpikApiError({ + message: _response.error.errorMessage, + }); + } + }))()); + } + /** + * Get LLM Provider's ApiKey by id + * + * @param {string} id + * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link OpikApi.NotFoundError} + * + * @example + * await client.llmProviderKey.getLlmProviderApiKeyById("id") + */ + getLlmProviderApiKeyById(id, requestOptions) { + return core.APIPromise.from((() => __awaiter(this, void 0, void 0, function* () { + var _a; + const _response = yield core.fetcher({ + url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, `v1/private/llm-provider-key/${encodeURIComponent(id)}`), + method: "GET", + headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), + contentType: "application/json", + requestType: "json", + timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries, + abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, + }); + if (_response.ok) { + return { + ok: _response.ok, + body: serializers.ProviderApiKeyPublic.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }), + headers: _response.headers, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { case 404: throw new OpikApi.NotFoundError(_response.error.body); default: @@ -183,7 +233,7 @@ class LlmProviderKey { body: _response.error.rawBody, }); case "timeout": - throw new errors.OpikApiTimeoutError("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}."); + throw new errors.OpikApiTimeoutError("Timeout exceeded when calling GET /v1/private/llm-provider-key/{id}."); case "unknown": throw new errors.OpikApiError({ message: _response.error.errorMessage, @@ -192,29 +242,31 @@ class LlmProviderKey { }))()); } /** - * Store LLM Provider's ApiKey + * Update LLM Provider's ApiKey * - * @param {OpikApi.ProviderApiKeyWrite} request + * @param {string} id + * @param {OpikApi.ProviderApiKeyUpdate} request * @param {LlmProviderKey.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link OpikApi.UnauthorizedError} * @throws {@link OpikApi.ForbiddenError} + * @throws {@link OpikApi.NotFoundError} * * @example - * await client.llmProviderKey.storeLlmProviderApiKey({ + * await client.llmProviderKey.updateLlmProviderApiKey("id", { * apiKey: "api_key" * }) */ - storeLlmProviderApiKey(request, requestOptions) { + updateLlmProviderApiKey(id, request, requestOptions) { return core.APIPromise.from((() => __awaiter(this, void 0, void 0, function* () { var _a; const _response = yield core.fetcher({ - url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, "v1/private/llm-provider-key"), - method: "POST", + url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.OpikApiEnvironment.Default, `v1/private/llm-provider-key/${encodeURIComponent(id)}`), + method: "PATCH", headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), contentType: "application/json", requestType: "json", - body: serializers.ProviderApiKeyWrite.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: serializers.ProviderApiKeyUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, @@ -242,6 +294,8 @@ class LlmProviderKey { allowUnrecognizedEnumValues: true, breadcrumbsPrefix: ["response"], })); + case 404: + throw new OpikApi.NotFoundError(_response.error.body); default: throw new errors.OpikApiError({ statusCode: _response.error.statusCode, @@ -256,7 +310,7 @@ class LlmProviderKey { body: _response.error.rawBody, }); case "timeout": - throw new errors.OpikApiTimeoutError("Timeout exceeded when calling POST /v1/private/llm-provider-key."); + throw new errors.OpikApiTimeoutError("Timeout exceeded when calling PATCH /v1/private/llm-provider-key/{id}."); case "unknown": throw new errors.OpikApiError({ message: _response.error.errorMessage, diff --git a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/requests/index.d.ts b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/requests/index.d.ts index f8148e829e..c94b70e857 100644 --- a/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/requests/index.d.ts +++ b/sdks/typescript/src/opik/rest_api/api/resources/llmProviderKey/client/requests/index.d.ts @@ -1,2 +1,2 @@ -export { type ProviderApiKeyUpdate } from "./ProviderApiKeyUpdate"; export { type ProviderApiKeyWrite } from "./ProviderApiKeyWrite"; +export { type ProviderApiKeyUpdate } from "./ProviderApiKeyUpdate"; diff --git a/sdks/typescript/src/opik/rest_api/api/types/index.d.ts b/sdks/typescript/src/opik/rest_api/api/types/index.d.ts index db484b3b73..3619bbc720 100644 --- a/sdks/typescript/src/opik/rest_api/api/types/index.d.ts +++ b/sdks/typescript/src/opik/rest_api/api/types/index.d.ts @@ -90,10 +90,10 @@ export * from "./CategoricalFeedbackDetailUpdate"; export * from "./FeedbackUpdate"; export * from "./NumericalFeedbackDefinitionUpdate"; export * from "./NumericalFeedbackDetailUpdate"; +export * from "./ProjectPagePublic"; export * from "./ProviderApiKeyPublic"; export * from "./ProviderApiKey"; export * from "./Project"; -export * from "./ProjectPagePublic"; export * from "./ProjectPublic"; export * from "./DataPointNumberPublic"; export * from "./ProjectMetricResponsePublicMetricType"; diff --git a/sdks/typescript/src/opik/rest_api/api/types/index.js b/sdks/typescript/src/opik/rest_api/api/types/index.js index 9f87a98a0d..14f068c66c 100644 --- a/sdks/typescript/src/opik/rest_api/api/types/index.js +++ b/sdks/typescript/src/opik/rest_api/api/types/index.js @@ -106,10 +106,10 @@ __exportStar(require("./CategoricalFeedbackDetailUpdate"), exports); __exportStar(require("./FeedbackUpdate"), exports); __exportStar(require("./NumericalFeedbackDefinitionUpdate"), exports); __exportStar(require("./NumericalFeedbackDetailUpdate"), exports); +__exportStar(require("./ProjectPagePublic"), exports); __exportStar(require("./ProviderApiKeyPublic"), exports); __exportStar(require("./ProviderApiKey"), exports); __exportStar(require("./Project"), exports); -__exportStar(require("./ProjectPagePublic"), exports); __exportStar(require("./ProjectPublic"), exports); __exportStar(require("./DataPointNumberPublic"), exports); __exportStar(require("./ProjectMetricResponsePublicMetricType"), exports); diff --git a/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.d.ts b/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.d.ts index fe242027f8..d15e1f0272 100644 --- a/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.d.ts +++ b/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.d.ts @@ -1,2 +1,2 @@ -export { ProviderApiKeyUpdate } from "./ProviderApiKeyUpdate"; export { ProviderApiKeyWrite } from "./ProviderApiKeyWrite"; +export { ProviderApiKeyUpdate } from "./ProviderApiKeyUpdate"; diff --git a/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.js b/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.js index 6595de167d..d3e33f77fc 100644 --- a/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.js +++ b/sdks/typescript/src/opik/rest_api/serialization/resources/llmProviderKey/client/requests/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ProviderApiKeyWrite = exports.ProviderApiKeyUpdate = void 0; -var ProviderApiKeyUpdate_1 = require("./ProviderApiKeyUpdate"); -Object.defineProperty(exports, "ProviderApiKeyUpdate", { enumerable: true, get: function () { return ProviderApiKeyUpdate_1.ProviderApiKeyUpdate; } }); +exports.ProviderApiKeyUpdate = exports.ProviderApiKeyWrite = void 0; var ProviderApiKeyWrite_1 = require("./ProviderApiKeyWrite"); Object.defineProperty(exports, "ProviderApiKeyWrite", { enumerable: true, get: function () { return ProviderApiKeyWrite_1.ProviderApiKeyWrite; } }); +var ProviderApiKeyUpdate_1 = require("./ProviderApiKeyUpdate"); +Object.defineProperty(exports, "ProviderApiKeyUpdate", { enumerable: true, get: function () { return ProviderApiKeyUpdate_1.ProviderApiKeyUpdate; } }); diff --git a/sdks/typescript/src/opik/rest_api/serialization/types/index.d.ts b/sdks/typescript/src/opik/rest_api/serialization/types/index.d.ts index db484b3b73..3619bbc720 100644 --- a/sdks/typescript/src/opik/rest_api/serialization/types/index.d.ts +++ b/sdks/typescript/src/opik/rest_api/serialization/types/index.d.ts @@ -90,10 +90,10 @@ export * from "./CategoricalFeedbackDetailUpdate"; export * from "./FeedbackUpdate"; export * from "./NumericalFeedbackDefinitionUpdate"; export * from "./NumericalFeedbackDetailUpdate"; +export * from "./ProjectPagePublic"; export * from "./ProviderApiKeyPublic"; export * from "./ProviderApiKey"; export * from "./Project"; -export * from "./ProjectPagePublic"; export * from "./ProjectPublic"; export * from "./DataPointNumberPublic"; export * from "./ProjectMetricResponsePublicMetricType"; diff --git a/sdks/typescript/src/opik/rest_api/serialization/types/index.js b/sdks/typescript/src/opik/rest_api/serialization/types/index.js index 9f87a98a0d..14f068c66c 100644 --- a/sdks/typescript/src/opik/rest_api/serialization/types/index.js +++ b/sdks/typescript/src/opik/rest_api/serialization/types/index.js @@ -106,10 +106,10 @@ __exportStar(require("./CategoricalFeedbackDetailUpdate"), exports); __exportStar(require("./FeedbackUpdate"), exports); __exportStar(require("./NumericalFeedbackDefinitionUpdate"), exports); __exportStar(require("./NumericalFeedbackDetailUpdate"), exports); +__exportStar(require("./ProjectPagePublic"), exports); __exportStar(require("./ProviderApiKeyPublic"), exports); __exportStar(require("./ProviderApiKey"), exports); __exportStar(require("./Project"), exports); -__exportStar(require("./ProjectPagePublic"), exports); __exportStar(require("./ProjectPublic"), exports); __exportStar(require("./DataPointNumberPublic"), exports); __exportStar(require("./ProjectMetricResponsePublicMetricType"), exports);