Skip to content

Commit 4f660a6

Browse files
feat(api): add endpoint to retrieve commit by id (#103)
1 parent 900cec6 commit 4f660a6

File tree

7 files changed

+203
-5
lines changed

7 files changed

+203
-5
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 14
1+
configured_endpoints: 15

api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ Methods:
3636

3737
# Commits
3838

39+
Types:
40+
41+
- <code><a href="./src/resources/commits/commits.ts">CommitRetrieveResponse</a></code>
42+
43+
Methods:
44+
45+
- <code title="get /versions/{projectVersionId}">client.commits.<a href="./src/resources/commits/commits.ts">retrieve</a>(projectVersionId) -> CommitRetrieveResponse</code>
46+
3947
## TestResults
4048

4149
Types:

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Core from './core';
66
import * as Errors from './error';
77
import * as Uploads from './uploads';
88
import * as API from './resources/index';
9-
import { Commits } from './resources/commits/commits';
9+
import { CommitRetrieveResponse, Commits } from './resources/commits/commits';
1010
import {
1111
InferencePipelineRetrieveParams,
1212
InferencePipelineRetrieveResponse,
@@ -206,7 +206,7 @@ export declare namespace Openlayer {
206206
type ProjectListParams as ProjectListParams,
207207
};
208208

209-
export { Commits as Commits };
209+
export { Commits as Commits, type CommitRetrieveResponse as CommitRetrieveResponse };
210210

211211
export {
212212
InferencePipelines as InferencePipelines,

src/resources/commits/commits.ts

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,177 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
45
import * as TestResultsAPI from './test-results';
56
import { TestResultListParams, TestResultListResponse, TestResults } from './test-results';
67

78
export class Commits extends APIResource {
89
testResults: TestResultsAPI.TestResults = new TestResultsAPI.TestResults(this._client);
10+
11+
/**
12+
* Retrieve a project version (commit) by its id.
13+
*/
14+
retrieve(projectVersionId: string, options?: Core.RequestOptions): Core.APIPromise<CommitRetrieveResponse> {
15+
return this._client.get(`/versions/${projectVersionId}`, options);
16+
}
17+
}
18+
19+
export interface CommitRetrieveResponse {
20+
/**
21+
* The project version (commit) id.
22+
*/
23+
id: string;
24+
25+
/**
26+
* The details of a commit (project version).
27+
*/
28+
commit: CommitRetrieveResponse.Commit;
29+
30+
/**
31+
* The commit archive date.
32+
*/
33+
dateArchived: string | null;
34+
35+
/**
36+
* The project version (commit) creation date.
37+
*/
38+
dateCreated: string;
39+
40+
/**
41+
* The number of tests that are failing for the commit.
42+
*/
43+
failingGoalCount: number;
44+
45+
/**
46+
* The model id.
47+
*/
48+
mlModelId: string | null;
49+
50+
/**
51+
* The number of tests that are passing for the commit.
52+
*/
53+
passingGoalCount: number;
54+
55+
/**
56+
* The project id.
57+
*/
58+
projectId: string;
59+
60+
/**
61+
* The commit status. Initially, the commit is `queued`, then, it switches to
62+
* `running`. Finally, it can be `paused`, `failed`, or `completed`.
63+
*/
64+
status: 'queued' | 'running' | 'paused' | 'failed' | 'completed' | 'unknown';
65+
66+
/**
67+
* The commit status message.
68+
*/
69+
statusMessage: string | null;
70+
71+
/**
72+
* The total number of tests for the commit.
73+
*/
74+
totalGoalCount: number;
75+
76+
/**
77+
* The training dataset id.
78+
*/
79+
trainingDatasetId: string | null;
80+
81+
/**
82+
* The validation dataset id.
83+
*/
84+
validationDatasetId: string | null;
85+
86+
/**
87+
* Whether the commit is archived.
88+
*/
89+
archived?: boolean | null;
90+
91+
/**
92+
* The deployment status associated with the commit's model.
93+
*/
94+
deploymentStatus?: string;
95+
96+
links?: CommitRetrieveResponse.Links;
97+
}
98+
99+
export namespace CommitRetrieveResponse {
100+
/**
101+
* The details of a commit (project version).
102+
*/
103+
export interface Commit {
104+
/**
105+
* The commit id.
106+
*/
107+
id: string;
108+
109+
/**
110+
* The author id of the commit.
111+
*/
112+
authorId: string;
113+
114+
/**
115+
* The size of the commit bundle in bytes.
116+
*/
117+
fileSize: number | null;
118+
119+
/**
120+
* The commit message.
121+
*/
122+
message: string;
123+
124+
/**
125+
* The model id.
126+
*/
127+
mlModelId: string | null;
128+
129+
/**
130+
* The storage URI where the commit bundle is stored.
131+
*/
132+
storageUri: string;
133+
134+
/**
135+
* The training dataset id.
136+
*/
137+
trainingDatasetId: string | null;
138+
139+
/**
140+
* The validation dataset id.
141+
*/
142+
validationDatasetId: string | null;
143+
144+
/**
145+
* The commit creation date.
146+
*/
147+
dateCreated?: string;
148+
149+
/**
150+
* The ref of the corresponding git commit.
151+
*/
152+
gitCommitRef?: string;
153+
154+
/**
155+
* The SHA of the corresponding git commit.
156+
*/
157+
gitCommitSha?: number;
158+
159+
/**
160+
* The URL of the corresponding git commit.
161+
*/
162+
gitCommitUrl?: string;
163+
}
164+
165+
export interface Links {
166+
app: string;
167+
}
9168
}
10169

11170
Commits.TestResults = TestResults;
12171

13172
export declare namespace Commits {
173+
export { type CommitRetrieveResponse as CommitRetrieveResponse };
174+
14175
export {
15176
TestResults as TestResults,
16177
type TestResultListResponse as TestResultListResponse,

src/resources/commits/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export { Commits } from './commits';
3+
export { Commits, type CommitRetrieveResponse } from './commits';
44
export { TestResults, type TestResultListResponse, type TestResultListParams } from './test-results';

src/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
export { Commits } from './commits/commits';
3+
export { Commits, type CommitRetrieveResponse } from './commits/commits';
44
export {
55
InferencePipelines,
66
type InferencePipelineRetrieveResponse,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Openlayer from 'openlayer';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Openlayer({
7+
apiKey: 'My API Key',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource commits', () => {
12+
test('retrieve', async () => {
13+
const responsePromise = client.commits.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
14+
const rawResponse = await responsePromise.asResponse();
15+
expect(rawResponse).toBeInstanceOf(Response);
16+
const response = await responsePromise;
17+
expect(response).not.toBeInstanceOf(Response);
18+
const dataAndResponse = await responsePromise.withResponse();
19+
expect(dataAndResponse.data).toBe(response);
20+
expect(dataAndResponse.response).toBe(rawResponse);
21+
});
22+
23+
test('retrieve: request options instead of params are passed correctly', async () => {
24+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
25+
await expect(
26+
client.commits.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { path: '/_stainless_unknown_path' }),
27+
).rejects.toThrow(Openlayer.NotFoundError);
28+
});
29+
});

0 commit comments

Comments
 (0)