diff --git a/api.md b/api.md index 60d83c6..7b49d84 100644 --- a/api.md +++ b/api.md @@ -14,10 +14,12 @@ Methods: Types: +- CommitCreateResponse - CommitListResponse Methods: +- client.projects.commits.create(projectId, { ...params }) -> CommitCreateResponse - client.projects.commits.list(projectId, { ...params }) -> CommitListResponse ## InferencePipelines @@ -34,14 +36,6 @@ Methods: # Commits -Types: - -- CommitCreateResponse - -Methods: - -- client.commits.create(projectId, { ...params }) -> CommitCreateResponse - ## TestResults Types: diff --git a/src/index.ts b/src/index.ts index 5400f80..051dead 100644 --- a/src/index.ts +++ b/src/index.ts @@ -199,8 +199,6 @@ 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 c5b9fb8..bc3cc40 100644 --- a/src/resources/commits/commits.ts +++ b/src/resources/commits/commits.ts @@ -1,213 +1,13 @@ // 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 21ac044..9f35f3f 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 { CommitCreateResponse, CommitCreateParams, Commits } from './commits'; +export { Commits } from './commits'; export { TestResultListResponse, TestResultListParams, TestResults } from './test-results'; diff --git a/src/resources/index.ts b/src/resources/index.ts index 46656e4..8ab3b09 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 { CommitCreateResponse, CommitCreateParams, Commits } from './commits/commits'; +export { Commits } from './commits/commits'; export { InferencePipelineRetrieveResponse, InferencePipelineUpdateResponse, diff --git a/src/resources/projects/commits.ts b/src/resources/projects/commits.ts index 21a4342..4a39a5d 100644 --- a/src/resources/projects/commits.ts +++ b/src/resources/projects/commits.ts @@ -6,6 +6,17 @@ import * as Core from '../../core'; import * as CommitsAPI from './commits'; export class Commits extends APIResource { + /** + * 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 }); + } + /** * List the commits (project versions) in a project. */ @@ -27,6 +38,157 @@ export class Commits extends APIResource { } } +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 CommitListResponse { items: Array; } @@ -184,6 +346,40 @@ export namespace CommitListResponse { } } +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 interface CommitListParams { /** * The page to return in a paginated query. @@ -197,6 +393,8 @@ export interface CommitListParams { } export namespace Commits { + export import CommitCreateResponse = CommitsAPI.CommitCreateResponse; export import CommitListResponse = CommitsAPI.CommitListResponse; + export import CommitCreateParams = CommitsAPI.CommitCreateParams; export import CommitListParams = CommitsAPI.CommitListParams; } diff --git a/src/resources/projects/index.ts b/src/resources/projects/index.ts index 62a84c5..6b87b6d 100644 --- a/src/resources/projects/index.ts +++ b/src/resources/projects/index.ts @@ -1,6 +1,12 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { CommitListResponse, CommitListParams, Commits } from './commits'; +export { + CommitCreateResponse, + CommitListResponse, + CommitCreateParams, + CommitListParams, + Commits, +} from './commits'; export { InferencePipelineCreateResponse, InferencePipelineListResponse, diff --git a/src/resources/projects/projects.ts b/src/resources/projects/projects.ts index 6645257..ff4d9a8 100644 --- a/src/resources/projects/projects.ts +++ b/src/resources/projects/projects.ts @@ -315,7 +315,9 @@ export namespace Projects { export import ProjectCreateParams = ProjectsAPI.ProjectCreateParams; export import ProjectListParams = ProjectsAPI.ProjectListParams; export import Commits = CommitsAPI.Commits; + export import CommitCreateResponse = CommitsAPI.CommitCreateResponse; export import CommitListResponse = CommitsAPI.CommitListResponse; + export import CommitCreateParams = CommitsAPI.CommitCreateParams; export import CommitListParams = CommitsAPI.CommitListParams; export import InferencePipelines = InferencePipelinesAPI.InferencePipelines; export import InferencePipelineCreateResponse = InferencePipelinesAPI.InferencePipelineCreateResponse; diff --git a/tests/api-resources/projects/commits.test.ts b/tests/api-resources/projects/commits.test.ts index ab0838a..29aefb5 100644 --- a/tests/api-resources/projects/commits.test.ts +++ b/tests/api-resources/projects/commits.test.ts @@ -9,6 +9,29 @@ const client = new Openlayer({ }); describe('resource commits', () => { + test('create: only required params', async () => { + const responsePromise = client.projects.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.projects.commits.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + commit: { message: 'Updated the prompt.' }, + storageUri: 's3://...', + archived: false, + deploymentStatus: 'Deployed', + }); + }); + test('list', async () => { const responsePromise = client.projects.commits.list('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse();