-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.go
476 lines (419 loc) · 17.6 KB
/
project.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openlayer
import (
"context"
"net/http"
"net/url"
"time"
"github.com/openlayer-ai/openlayer-go/internal/apijson"
"github.com/openlayer-ai/openlayer-go/internal/apiquery"
"github.com/openlayer-ai/openlayer-go/internal/param"
"github.com/openlayer-ai/openlayer-go/internal/requestconfig"
"github.com/openlayer-ai/openlayer-go/option"
)
// ProjectService contains methods and other services that help with interacting
// with the openlayer API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewProjectService] method instead.
type ProjectService struct {
Options []option.RequestOption
Commits *ProjectCommitService
InferencePipelines *ProjectInferencePipelineService
}
// NewProjectService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewProjectService(opts ...option.RequestOption) (r *ProjectService) {
r = &ProjectService{}
r.Options = opts
r.Commits = NewProjectCommitService(opts...)
r.InferencePipelines = NewProjectInferencePipelineService(opts...)
return
}
// Create a project in your workspace.
func (r *ProjectService) New(ctx context.Context, body ProjectNewParams, opts ...option.RequestOption) (res *ProjectNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "projects"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// List your workspace's projects.
func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *ProjectListResponse, err error) {
opts = append(r.Options[:], opts...)
path := "projects"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type ProjectNewResponse struct {
// The project id.
ID string `json:"id,required" format:"uuid"`
// The project creator id.
CreatorID string `json:"creatorId,required,nullable" format:"uuid"`
// The project creation date.
DateCreated time.Time `json:"dateCreated,required" format:"date-time"`
// The project last updated date.
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
// The number of tests in the development mode of the project.
DevelopmentGoalCount int64 `json:"developmentGoalCount,required"`
// The total number of tests in the project.
GoalCount int64 `json:"goalCount,required"`
// The number of inference pipelines in the project.
InferencePipelineCount int64 `json:"inferencePipelineCount,required"`
// Links to the project.
Links ProjectNewResponseLinks `json:"links,required"`
// The number of tests in the monitoring mode of the project.
MonitoringGoalCount int64 `json:"monitoringGoalCount,required"`
// The project name.
Name string `json:"name,required"`
// The source of the project.
Source ProjectNewResponseSource `json:"source,required,nullable"`
// The task type of the project.
TaskType ProjectNewResponseTaskType `json:"taskType,required"`
// The number of versions (commits) in the project.
VersionCount int64 `json:"versionCount,required"`
// The workspace id.
WorkspaceID string `json:"workspaceId,required,nullable" format:"uuid"`
// The project description.
Description string `json:"description,nullable"`
GitRepo ProjectNewResponseGitRepo `json:"gitRepo,nullable"`
JSON projectNewResponseJSON `json:"-"`
}
// projectNewResponseJSON contains the JSON metadata for the struct
// [ProjectNewResponse]
type projectNewResponseJSON struct {
ID apijson.Field
CreatorID apijson.Field
DateCreated apijson.Field
DateUpdated apijson.Field
DevelopmentGoalCount apijson.Field
GoalCount apijson.Field
InferencePipelineCount apijson.Field
Links apijson.Field
MonitoringGoalCount apijson.Field
Name apijson.Field
Source apijson.Field
TaskType apijson.Field
VersionCount apijson.Field
WorkspaceID apijson.Field
Description apijson.Field
GitRepo apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectNewResponseJSON) RawJSON() string {
return r.raw
}
// Links to the project.
type ProjectNewResponseLinks struct {
App string `json:"app,required"`
JSON projectNewResponseLinksJSON `json:"-"`
}
// projectNewResponseLinksJSON contains the JSON metadata for the struct
// [ProjectNewResponseLinks]
type projectNewResponseLinksJSON struct {
App apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectNewResponseLinks) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectNewResponseLinksJSON) RawJSON() string {
return r.raw
}
// The source of the project.
type ProjectNewResponseSource string
const (
ProjectNewResponseSourceWeb ProjectNewResponseSource = "web"
ProjectNewResponseSourceAPI ProjectNewResponseSource = "api"
ProjectNewResponseSourceNull ProjectNewResponseSource = "null"
)
func (r ProjectNewResponseSource) IsKnown() bool {
switch r {
case ProjectNewResponseSourceWeb, ProjectNewResponseSourceAPI, ProjectNewResponseSourceNull:
return true
}
return false
}
// The task type of the project.
type ProjectNewResponseTaskType string
const (
ProjectNewResponseTaskTypeLlmBase ProjectNewResponseTaskType = "llm-base"
ProjectNewResponseTaskTypeTabularClassification ProjectNewResponseTaskType = "tabular-classification"
ProjectNewResponseTaskTypeTabularRegression ProjectNewResponseTaskType = "tabular-regression"
ProjectNewResponseTaskTypeTextClassification ProjectNewResponseTaskType = "text-classification"
)
func (r ProjectNewResponseTaskType) IsKnown() bool {
switch r {
case ProjectNewResponseTaskTypeLlmBase, ProjectNewResponseTaskTypeTabularClassification, ProjectNewResponseTaskTypeTabularRegression, ProjectNewResponseTaskTypeTextClassification:
return true
}
return false
}
type ProjectNewResponseGitRepo struct {
ID string `json:"id,required" format:"uuid"`
DateConnected time.Time `json:"dateConnected,required" format:"date-time"`
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
GitAccountID string `json:"gitAccountId,required" format:"uuid"`
GitID int64 `json:"gitId,required"`
Name string `json:"name,required"`
Private bool `json:"private,required"`
ProjectID string `json:"projectId,required" format:"uuid"`
Slug string `json:"slug,required"`
URL string `json:"url,required" format:"url"`
Branch string `json:"branch"`
RootDir string `json:"rootDir"`
JSON projectNewResponseGitRepoJSON `json:"-"`
}
// projectNewResponseGitRepoJSON contains the JSON metadata for the struct
// [ProjectNewResponseGitRepo]
type projectNewResponseGitRepoJSON struct {
ID apijson.Field
DateConnected apijson.Field
DateUpdated apijson.Field
GitAccountID apijson.Field
GitID apijson.Field
Name apijson.Field
Private apijson.Field
ProjectID apijson.Field
Slug apijson.Field
URL apijson.Field
Branch apijson.Field
RootDir apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectNewResponseGitRepo) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectNewResponseGitRepoJSON) RawJSON() string {
return r.raw
}
type ProjectListResponse struct {
Items []ProjectListResponseItem `json:"items,required"`
JSON projectListResponseJSON `json:"-"`
}
// projectListResponseJSON contains the JSON metadata for the struct
// [ProjectListResponse]
type projectListResponseJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectListResponseJSON) RawJSON() string {
return r.raw
}
type ProjectListResponseItem struct {
// The project id.
ID string `json:"id,required" format:"uuid"`
// The project creator id.
CreatorID string `json:"creatorId,required,nullable" format:"uuid"`
// The project creation date.
DateCreated time.Time `json:"dateCreated,required" format:"date-time"`
// The project last updated date.
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
// The number of tests in the development mode of the project.
DevelopmentGoalCount int64 `json:"developmentGoalCount,required"`
// The total number of tests in the project.
GoalCount int64 `json:"goalCount,required"`
// The number of inference pipelines in the project.
InferencePipelineCount int64 `json:"inferencePipelineCount,required"`
// Links to the project.
Links ProjectListResponseItemsLinks `json:"links,required"`
// The number of tests in the monitoring mode of the project.
MonitoringGoalCount int64 `json:"monitoringGoalCount,required"`
// The project name.
Name string `json:"name,required"`
// The source of the project.
Source ProjectListResponseItemsSource `json:"source,required,nullable"`
// The task type of the project.
TaskType ProjectListResponseItemsTaskType `json:"taskType,required"`
// The number of versions (commits) in the project.
VersionCount int64 `json:"versionCount,required"`
// The workspace id.
WorkspaceID string `json:"workspaceId,required,nullable" format:"uuid"`
// The project description.
Description string `json:"description,nullable"`
GitRepo ProjectListResponseItemsGitRepo `json:"gitRepo,nullable"`
JSON projectListResponseItemJSON `json:"-"`
}
// projectListResponseItemJSON contains the JSON metadata for the struct
// [ProjectListResponseItem]
type projectListResponseItemJSON struct {
ID apijson.Field
CreatorID apijson.Field
DateCreated apijson.Field
DateUpdated apijson.Field
DevelopmentGoalCount apijson.Field
GoalCount apijson.Field
InferencePipelineCount apijson.Field
Links apijson.Field
MonitoringGoalCount apijson.Field
Name apijson.Field
Source apijson.Field
TaskType apijson.Field
VersionCount apijson.Field
WorkspaceID apijson.Field
Description apijson.Field
GitRepo apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectListResponseItem) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectListResponseItemJSON) RawJSON() string {
return r.raw
}
// Links to the project.
type ProjectListResponseItemsLinks struct {
App string `json:"app,required"`
JSON projectListResponseItemsLinksJSON `json:"-"`
}
// projectListResponseItemsLinksJSON contains the JSON metadata for the struct
// [ProjectListResponseItemsLinks]
type projectListResponseItemsLinksJSON struct {
App apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectListResponseItemsLinks) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectListResponseItemsLinksJSON) RawJSON() string {
return r.raw
}
// The source of the project.
type ProjectListResponseItemsSource string
const (
ProjectListResponseItemsSourceWeb ProjectListResponseItemsSource = "web"
ProjectListResponseItemsSourceAPI ProjectListResponseItemsSource = "api"
ProjectListResponseItemsSourceNull ProjectListResponseItemsSource = "null"
)
func (r ProjectListResponseItemsSource) IsKnown() bool {
switch r {
case ProjectListResponseItemsSourceWeb, ProjectListResponseItemsSourceAPI, ProjectListResponseItemsSourceNull:
return true
}
return false
}
// The task type of the project.
type ProjectListResponseItemsTaskType string
const (
ProjectListResponseItemsTaskTypeLlmBase ProjectListResponseItemsTaskType = "llm-base"
ProjectListResponseItemsTaskTypeTabularClassification ProjectListResponseItemsTaskType = "tabular-classification"
ProjectListResponseItemsTaskTypeTabularRegression ProjectListResponseItemsTaskType = "tabular-regression"
ProjectListResponseItemsTaskTypeTextClassification ProjectListResponseItemsTaskType = "text-classification"
)
func (r ProjectListResponseItemsTaskType) IsKnown() bool {
switch r {
case ProjectListResponseItemsTaskTypeLlmBase, ProjectListResponseItemsTaskTypeTabularClassification, ProjectListResponseItemsTaskTypeTabularRegression, ProjectListResponseItemsTaskTypeTextClassification:
return true
}
return false
}
type ProjectListResponseItemsGitRepo struct {
ID string `json:"id,required" format:"uuid"`
DateConnected time.Time `json:"dateConnected,required" format:"date-time"`
DateUpdated time.Time `json:"dateUpdated,required" format:"date-time"`
GitAccountID string `json:"gitAccountId,required" format:"uuid"`
GitID int64 `json:"gitId,required"`
Name string `json:"name,required"`
Private bool `json:"private,required"`
ProjectID string `json:"projectId,required" format:"uuid"`
Slug string `json:"slug,required"`
URL string `json:"url,required" format:"url"`
Branch string `json:"branch"`
RootDir string `json:"rootDir"`
JSON projectListResponseItemsGitRepoJSON `json:"-"`
}
// projectListResponseItemsGitRepoJSON contains the JSON metadata for the struct
// [ProjectListResponseItemsGitRepo]
type projectListResponseItemsGitRepoJSON struct {
ID apijson.Field
DateConnected apijson.Field
DateUpdated apijson.Field
GitAccountID apijson.Field
GitID apijson.Field
Name apijson.Field
Private apijson.Field
ProjectID apijson.Field
Slug apijson.Field
URL apijson.Field
Branch apijson.Field
RootDir apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ProjectListResponseItemsGitRepo) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r projectListResponseItemsGitRepoJSON) RawJSON() string {
return r.raw
}
type ProjectNewParams struct {
// The project name.
Name param.Field[string] `json:"name,required"`
// The task type of the project.
TaskType param.Field[ProjectNewParamsTaskType] `json:"taskType,required"`
// The project description.
Description param.Field[string] `json:"description"`
}
func (r ProjectNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// The task type of the project.
type ProjectNewParamsTaskType string
const (
ProjectNewParamsTaskTypeLlmBase ProjectNewParamsTaskType = "llm-base"
ProjectNewParamsTaskTypeTabularClassification ProjectNewParamsTaskType = "tabular-classification"
ProjectNewParamsTaskTypeTabularRegression ProjectNewParamsTaskType = "tabular-regression"
ProjectNewParamsTaskTypeTextClassification ProjectNewParamsTaskType = "text-classification"
)
func (r ProjectNewParamsTaskType) IsKnown() bool {
switch r {
case ProjectNewParamsTaskTypeLlmBase, ProjectNewParamsTaskTypeTabularClassification, ProjectNewParamsTaskTypeTabularRegression, ProjectNewParamsTaskTypeTextClassification:
return true
}
return false
}
type ProjectListParams struct {
// Filter list of items by project name.
Name param.Field[string] `query:"name"`
// The page to return in a paginated query.
Page param.Field[int64] `query:"page"`
// Maximum number of items to return per page.
PerPage param.Field[int64] `query:"perPage"`
// Filter list of items by task type.
TaskType param.Field[ProjectListParamsTaskType] `query:"taskType"`
}
// URLQuery serializes [ProjectListParams]'s query parameters as `url.Values`.
func (r ProjectListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Filter list of items by task type.
type ProjectListParamsTaskType string
const (
ProjectListParamsTaskTypeLlmBase ProjectListParamsTaskType = "llm-base"
ProjectListParamsTaskTypeTabularClassification ProjectListParamsTaskType = "tabular-classification"
ProjectListParamsTaskTypeTabularRegression ProjectListParamsTaskType = "tabular-regression"
ProjectListParamsTaskTypeTextClassification ProjectListParamsTaskType = "text-classification"
)
func (r ProjectListParamsTaskType) IsKnown() bool {
switch r {
case ProjectListParamsTaskTypeLlmBase, ProjectListParamsTaskTypeTabularClassification, ProjectListParamsTaskTypeTabularRegression, ProjectListParamsTaskTypeTextClassification:
return true
}
return false
}