diff --git a/.stats.yml b/.stats.yml index de479128..af63a6f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 9 +configured_endpoints: 10 diff --git a/api.md b/api.md index 92cf0fb4..7e5089e9 100644 --- a/api.md +++ b/api.md @@ -75,3 +75,15 @@ Types: Methods: - client.inferencePipelines.testResults.list(inferencePipelineId, { ...params }) -> TestResultListResponse + +# Storage + +## PresignedURL + +Types: + +- PresignedURLCreateResponse + +Methods: + +- client.storage.presignedURL.create({ ...params }) -> PresignedURLCreateResponse diff --git a/src/index.ts b/src/index.ts index ca4d7420..66454352 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,6 +116,7 @@ export class Openlayer extends Core.APIClient { projects: API.Projects = new API.Projects(this); commits: API.Commits = new API.Commits(this); inferencePipelines: API.InferencePipelines = new API.InferencePipelines(this); + storage: API.Storage = new API.Storage(this); protected override defaultQuery(): Core.DefaultQuery | undefined { return this._options.defaultQuery; @@ -199,6 +200,8 @@ export namespace Openlayer { export import Commits = API.Commits; export import InferencePipelines = API.InferencePipelines; + + export import Storage = API.Storage; } export default Openlayer; diff --git a/src/resources/index.ts b/src/resources/index.ts index e22e510a..ac10cad0 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -9,3 +9,4 @@ export { ProjectListParams, Projects, } from './projects/projects'; +export { Storage } from './storage/storage'; diff --git a/src/resources/storage/index.ts b/src/resources/storage/index.ts new file mode 100644 index 00000000..97760a20 --- /dev/null +++ b/src/resources/storage/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { PresignedURLCreateResponse, PresignedURLCreateParams, PresignedURL } from './presigned-url'; +export { Storage } from './storage'; diff --git a/src/resources/storage/presigned-url.ts b/src/resources/storage/presigned-url.ts new file mode 100644 index 00000000..694ae329 --- /dev/null +++ b/src/resources/storage/presigned-url.ts @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as PresignedURLAPI from './presigned-url'; + +export class PresignedURL extends APIResource { + /** + * Retrieve a presigned url to post storage artifacts. + */ + create( + params: PresignedURLCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { objectName } = params; + return this._client.post('/storage/presigned-url', { query: { objectName }, ...options }); + } +} + +export interface PresignedURLCreateResponse { + /** + * The storage URI to send back to the backend after the upload was completed. + */ + storageUri: string; + + /** + * The presigned url. + */ + url: string; + + /** + * Fields to include in the body of the upload. Only needed by s3. + */ + fields?: unknown; +} + +export interface PresignedURLCreateParams { + /** + * The name of the object. + */ + objectName: string; +} + +export namespace PresignedURL { + export import PresignedURLCreateResponse = PresignedURLAPI.PresignedURLCreateResponse; + export import PresignedURLCreateParams = PresignedURLAPI.PresignedURLCreateParams; +} diff --git a/src/resources/storage/storage.ts b/src/resources/storage/storage.ts new file mode 100644 index 00000000..85b28887 --- /dev/null +++ b/src/resources/storage/storage.ts @@ -0,0 +1,14 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as PresignedURLAPI from './presigned-url'; + +export class Storage extends APIResource { + presignedURL: PresignedURLAPI.PresignedURL = new PresignedURLAPI.PresignedURL(this._client); +} + +export namespace Storage { + export import PresignedURL = PresignedURLAPI.PresignedURL; + export import PresignedURLCreateResponse = PresignedURLAPI.PresignedURLCreateResponse; + export import PresignedURLCreateParams = PresignedURLAPI.PresignedURLCreateParams; +} diff --git a/tests/api-resources/storage/presigned-url.test.ts b/tests/api-resources/storage/presigned-url.test.ts new file mode 100644 index 00000000..0ab5a04a --- /dev/null +++ b/tests/api-resources/storage/presigned-url.test.ts @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Openlayer from 'openlayer'; +import { Response } from 'node-fetch'; + +const openlayer = new Openlayer({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource presignedURL', () => { + test('create: only required params', async () => { + const responsePromise = openlayer.storage.presignedURL.create({ objectName: 'objectName' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await openlayer.storage.presignedURL.create({ objectName: 'objectName' }); + }); +});