From e9a92bb885d2f2fb2db05942ba0dc266740e4198 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Wed, 30 Oct 2024 14:56:47 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- .stats.yml | 2 +- api.md | 8 + src/index.ts | 2 + src/resources/commits/commits.ts | 200 ++++++++++++++++++++ src/resources/commits/index.ts | 2 +- src/resources/index.ts | 2 +- tests/api-resources/commits/commits.test.ts | 34 ++++ 7 files changed, 247 insertions(+), 3 deletions(-) create mode 100644 tests/api-resources/commits/commits.test.ts diff --git a/.stats.yml b/.stats.yml index 6a8c1428..dd473053 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 13 +configured_endpoints: 14 diff --git a/api.md b/api.md index 802205b4..60d83c6e 100644 --- a/api.md +++ b/api.md @@ -34,6 +34,14 @@ Methods: # Commits +Types: + +- CommitCreateResponse + +Methods: + +- client.commits.create(projectId, { ...params }) -> CommitCreateResponse + ## TestResults Types: diff --git a/src/index.ts b/src/index.ts index 051deadd..5400f802 100644 --- a/src/index.ts +++ b/src/index.ts @@ -199,6 +199,8 @@ export namespace Openlayer { export import ProjectListParams = API.ProjectListParams; export import Commits = API.Commits; + export import CommitCreateResponse = API.CommitCreateResponse; + export import CommitCreateParams = API.CommitCreateParams; export import InferencePipelines = API.InferencePipelines; export import InferencePipelineRetrieveResponse = API.InferencePipelineRetrieveResponse; diff --git a/src/resources/commits/commits.ts b/src/resources/commits/commits.ts index bc3cc40d..c5b9fb89 100644 --- a/src/resources/commits/commits.ts +++ b/src/resources/commits/commits.ts @@ -1,13 +1,213 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as CommitsAPI from './commits'; import * as TestResultsAPI from './test-results'; export class Commits extends APIResource { testResults: TestResultsAPI.TestResults = new TestResultsAPI.TestResults(this._client); + + /** + * Create a new commit (project version) in a project. + */ + create( + projectId: string, + body: CommitCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + return this._client.post(`/projects/${projectId}/versions`, { body, ...options }); + } +} + +export interface CommitCreateResponse { + /** + * The project version (commit) id. + */ + id: string; + + /** + * The details of a commit (project version). + */ + commit: CommitCreateResponse.Commit; + + /** + * The commit archive date. + */ + dateArchived: string | null; + + /** + * The project version (commit) creation date. + */ + dateCreated: string; + + /** + * The number of tests that are failing for the commit. + */ + failingGoalCount: number; + + /** + * The model id. + */ + mlModelId: string | null; + + /** + * The number of tests that are passing for the commit. + */ + passingGoalCount: number; + + /** + * The project id. + */ + projectId: string; + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to + * `running`. Finally, it can be `paused`, `failed`, or `completed`. + */ + status: 'queued' | 'running' | 'paused' | 'failed' | 'completed' | 'unknown'; + + /** + * The commit status message. + */ + statusMessage: string | null; + + /** + * The total number of tests for the commit. + */ + totalGoalCount: number; + + /** + * The training dataset id. + */ + trainingDatasetId: string | null; + + /** + * The validation dataset id. + */ + validationDatasetId: string | null; + + /** + * Whether the commit is archived. + */ + archived?: boolean | null; + + /** + * The deployment status associated with the commit's model. + */ + deploymentStatus?: string; + + links?: CommitCreateResponse.Links; +} + +export namespace CommitCreateResponse { + /** + * The details of a commit (project version). + */ + export interface Commit { + /** + * The commit id. + */ + id: string; + + /** + * The author id of the commit. + */ + authorId: string; + + /** + * The size of the commit bundle in bytes. + */ + fileSize: number | null; + + /** + * The commit message. + */ + message: string; + + /** + * The model id. + */ + mlModelId: string | null; + + /** + * The storage URI where the commit bundle is stored. + */ + storageUri: string; + + /** + * The training dataset id. + */ + trainingDatasetId: string | null; + + /** + * The validation dataset id. + */ + validationDatasetId: string | null; + + /** + * The commit creation date. + */ + dateCreated?: string; + + /** + * The ref of the corresponding git commit. + */ + gitCommitRef?: string; + + /** + * The SHA of the corresponding git commit. + */ + gitCommitSha?: number; + + /** + * The URL of the corresponding git commit. + */ + gitCommitUrl?: string; + } + + export interface Links { + app: string; + } +} + +export interface CommitCreateParams { + /** + * The details of a commit (project version). + */ + commit: CommitCreateParams.Commit; + + /** + * The storage URI where the commit bundle is stored. + */ + storageUri: string; + + /** + * Whether the commit is archived. + */ + archived?: boolean | null; + + /** + * The deployment status associated with the commit's model. + */ + deploymentStatus?: string; +} + +export namespace CommitCreateParams { + /** + * The details of a commit (project version). + */ + export interface Commit { + /** + * The commit message. + */ + message: string; + } } export namespace Commits { + export import CommitCreateResponse = CommitsAPI.CommitCreateResponse; + export import CommitCreateParams = CommitsAPI.CommitCreateParams; export import TestResults = TestResultsAPI.TestResults; export import TestResultListResponse = TestResultsAPI.TestResultListResponse; export import TestResultListParams = TestResultsAPI.TestResultListParams; diff --git a/src/resources/commits/index.ts b/src/resources/commits/index.ts index 9f35f3f4..21ac044a 100644 --- a/src/resources/commits/index.ts +++ b/src/resources/commits/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Commits } from './commits'; +export { CommitCreateResponse, CommitCreateParams, Commits } from './commits'; export { TestResultListResponse, TestResultListParams, TestResults } from './test-results'; diff --git a/src/resources/index.ts b/src/resources/index.ts index 8ab3b09b..46656e43 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Commits } from './commits/commits'; +export { CommitCreateResponse, CommitCreateParams, Commits } from './commits/commits'; export { InferencePipelineRetrieveResponse, InferencePipelineUpdateResponse, diff --git a/tests/api-resources/commits/commits.test.ts b/tests/api-resources/commits/commits.test.ts new file mode 100644 index 00000000..6b7f5bc2 --- /dev/null +++ b/tests/api-resources/commits/commits.test.ts @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Openlayer from 'openlayer'; +import { Response } from 'node-fetch'; + +const client = new Openlayer({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource commits', () => { + test('create: only required params', async () => { + const responsePromise = client.commits.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + commit: { message: 'Updated the prompt.' }, + storageUri: 's3://...', + }); + 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 client.commits.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + commit: { message: 'Updated the prompt.' }, + storageUri: 's3://...', + archived: false, + deploymentStatus: 'Deployed', + }); + }); +});