-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathadminorganizationprojectgrouprole.go
More file actions
394 lines (364 loc) · 16.4 KB
/
Copy pathadminorganizationprojectgrouprole.go
File metadata and controls
394 lines (364 loc) · 16.4 KB
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
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
package openai
import (
"context"
"errors"
"net/http"
"net/url"
"slices"
"github.com/openai/openai-go/v3/internal/apijson"
"github.com/openai/openai-go/v3/internal/apiquery"
"github.com/openai/openai-go/v3/internal/requestconfig"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/packages/pagination"
"github.com/openai/openai-go/v3/packages/param"
"github.com/openai/openai-go/v3/packages/respjson"
"github.com/openai/openai-go/v3/shared/constant"
)
// AdminOrganizationProjectGroupRoleService contains methods and other services
// that help with interacting with the openai 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 [NewAdminOrganizationProjectGroupRoleService] method instead.
type AdminOrganizationProjectGroupRoleService struct {
Options []option.RequestOption
}
// NewAdminOrganizationProjectGroupRoleService 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 NewAdminOrganizationProjectGroupRoleService(opts ...option.RequestOption) (r AdminOrganizationProjectGroupRoleService) {
r = AdminOrganizationProjectGroupRoleService{}
r.Options = requestconfig.InheritedOptions(opts...)
return
}
// Assigns a project role to a group within a project.
func (r *AdminOrganizationProjectGroupRoleService) New(ctx context.Context, projectID string, groupID string, body AdminOrganizationProjectGroupRoleNewParams, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleNewResponse, err error) {
var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
opts = slices.Concat(preClientOpts, r.Options, opts)
if projectID == "" {
err = errors.New("missing required project_id parameter")
return nil, err
}
if groupID == "" {
err = errors.New("missing required group_id parameter")
return nil, err
}
path := requestconfig.FormatPath("projects/%s/groups/%s/roles", projectID, groupID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
// Retrieves a project role assigned to a group.
func (r *AdminOrganizationProjectGroupRoleService) Get(ctx context.Context, projectID string, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleGetResponse, err error) {
var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
opts = slices.Concat(preClientOpts, r.Options, opts)
if projectID == "" {
err = errors.New("missing required project_id parameter")
return nil, err
}
if groupID == "" {
err = errors.New("missing required group_id parameter")
return nil, err
}
if roleID == "" {
err = errors.New("missing required role_id parameter")
return nil, err
}
path := requestconfig.FormatPath("projects/%s/groups/%s/roles/%s", projectID, groupID, roleID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return res, err
}
// Lists the project roles assigned to a group within a project.
func (r *AdminOrganizationProjectGroupRoleService) List(ctx context.Context, projectID string, groupID string, query AdminOrganizationProjectGroupRoleListParams, opts ...option.RequestOption) (res *pagination.NextCursorPage[AdminOrganizationProjectGroupRoleListResponse], err error) {
var raw *http.Response
var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
opts = slices.Concat(preClientOpts, r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if projectID == "" {
err = errors.New("missing required project_id parameter")
return nil, err
}
if groupID == "" {
err = errors.New("missing required group_id parameter")
return nil, err
}
path := requestconfig.FormatPath("projects/%s/groups/%s/roles", projectID, groupID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Lists the project roles assigned to a group within a project.
func (r *AdminOrganizationProjectGroupRoleService) ListAutoPaging(ctx context.Context, projectID string, groupID string, query AdminOrganizationProjectGroupRoleListParams, opts ...option.RequestOption) *pagination.NextCursorPageAutoPager[AdminOrganizationProjectGroupRoleListResponse] {
return pagination.NewNextCursorPageAutoPager(r.List(ctx, projectID, groupID, query, opts...))
}
// Unassigns a project role from a group within a project.
func (r *AdminOrganizationProjectGroupRoleService) Delete(ctx context.Context, projectID string, groupID string, roleID string, opts ...option.RequestOption) (res *AdminOrganizationProjectGroupRoleDeleteResponse, err error) {
var preClientOpts = []option.RequestOption{requestconfig.WithAdminAPIKeyAuthSecurity()}
opts = slices.Concat(preClientOpts, r.Options, opts)
if projectID == "" {
err = errors.New("missing required project_id parameter")
return nil, err
}
if groupID == "" {
err = errors.New("missing required group_id parameter")
return nil, err
}
if roleID == "" {
err = errors.New("missing required role_id parameter")
return nil, err
}
path := requestconfig.FormatPath("projects/%s/groups/%s/roles/%s", projectID, groupID, roleID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return res, err
}
// Role assignment linking a group to a role.
type AdminOrganizationProjectGroupRoleNewResponse struct {
// Summary information about a group returned in role assignment responses.
Group AdminOrganizationProjectGroupRoleNewResponseGroup `json:"group" api:"required"`
// Always `group.role`.
Object constant.GroupRole `json:"object" default:"group.role"`
// Details about a role that can be assigned through the public Roles API.
Role Role `json:"role" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Group respjson.Field
Object respjson.Field
Role respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleNewResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectGroupRoleNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Summary information about a group returned in role assignment responses.
type AdminOrganizationProjectGroupRoleNewResponseGroup struct {
// Identifier for the group.
ID string `json:"id" api:"required"`
// Unix timestamp (in seconds) when the group was created.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Display name of the group.
Name string `json:"name" api:"required"`
// Always `group`.
Object constant.Group `json:"object" default:"group"`
// Whether the group is managed through SCIM.
ScimManaged bool `json:"scim_managed" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
ScimManaged respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleNewResponseGroup) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectGroupRoleNewResponseGroup) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Detailed information about a role assignment entry returned when listing
// assignments.
type AdminOrganizationProjectGroupRoleGetResponse struct {
// Identifier for the role.
ID string `json:"id" api:"required"`
// Principals from which the role assignment is inherited, when available.
AssignmentSources []AdminOrganizationProjectGroupRoleGetResponseAssignmentSource `json:"assignment_sources" api:"required"`
// When the role was created.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Identifier of the actor who created the role.
CreatedBy string `json:"created_by" api:"required"`
// User details for the actor that created the role, when available.
CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"`
// Description of the role.
Description string `json:"description" api:"required"`
// Arbitrary metadata stored on the role.
Metadata map[string]any `json:"metadata" api:"required"`
// Name of the role.
Name string `json:"name" api:"required"`
// Permissions associated with the role.
Permissions []string `json:"permissions" api:"required"`
// Whether the role is predefined by OpenAI.
PredefinedRole bool `json:"predefined_role" api:"required"`
// Resource type the role applies to.
ResourceType string `json:"resource_type" api:"required"`
// When the role was last updated.
UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
AssignmentSources respjson.Field
CreatedAt respjson.Field
CreatedBy respjson.Field
CreatedByUserObj respjson.Field
Description respjson.Field
Metadata respjson.Field
Name respjson.Field
Permissions respjson.Field
PredefinedRole respjson.Field
ResourceType respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleGetResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectGroupRoleGetResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectGroupRoleGetResponseAssignmentSource struct {
PrincipalID string `json:"principal_id" api:"required"`
PrincipalType string `json:"principal_type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
PrincipalID respjson.Field
PrincipalType respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleGetResponseAssignmentSource) RawJSON() string {
return r.JSON.raw
}
func (r *AdminOrganizationProjectGroupRoleGetResponseAssignmentSource) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Detailed information about a role assignment entry returned when listing
// assignments.
type AdminOrganizationProjectGroupRoleListResponse struct {
// Identifier for the role.
ID string `json:"id" api:"required"`
// Principals from which the role assignment is inherited, when available.
AssignmentSources []AdminOrganizationProjectGroupRoleListResponseAssignmentSource `json:"assignment_sources" api:"required"`
// When the role was created.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// Identifier of the actor who created the role.
CreatedBy string `json:"created_by" api:"required"`
// User details for the actor that created the role, when available.
CreatedByUserObj map[string]any `json:"created_by_user_obj" api:"required"`
// Description of the role.
Description string `json:"description" api:"required"`
// Arbitrary metadata stored on the role.
Metadata map[string]any `json:"metadata" api:"required"`
// Name of the role.
Name string `json:"name" api:"required"`
// Permissions associated with the role.
Permissions []string `json:"permissions" api:"required"`
// Whether the role is predefined by OpenAI.
PredefinedRole bool `json:"predefined_role" api:"required"`
// Resource type the role applies to.
ResourceType string `json:"resource_type" api:"required"`
// When the role was last updated.
UpdatedAt int64 `json:"updated_at" api:"required" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
AssignmentSources respjson.Field
CreatedAt respjson.Field
CreatedBy respjson.Field
CreatedByUserObj respjson.Field
Description respjson.Field
Metadata respjson.Field
Name respjson.Field
Permissions respjson.Field
PredefinedRole respjson.Field
ResourceType respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleListResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectGroupRoleListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectGroupRoleListResponseAssignmentSource struct {
PrincipalID string `json:"principal_id" api:"required"`
PrincipalType string `json:"principal_type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
PrincipalID respjson.Field
PrincipalType respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleListResponseAssignmentSource) RawJSON() string {
return r.JSON.raw
}
func (r *AdminOrganizationProjectGroupRoleListResponseAssignmentSource) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Confirmation payload returned after unassigning a role.
type AdminOrganizationProjectGroupRoleDeleteResponse struct {
// Whether the assignment was removed.
Deleted bool `json:"deleted" api:"required"`
// Identifier for the deleted assignment, such as `group.role.deleted` or
// `user.role.deleted`.
Object string `json:"object" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Deleted respjson.Field
Object respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectGroupRoleDeleteResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectGroupRoleDeleteResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectGroupRoleNewParams struct {
// Identifier of the role to assign.
RoleID string `json:"role_id" api:"required"`
paramObj
}
func (r AdminOrganizationProjectGroupRoleNewParams) MarshalJSON() (data []byte, err error) {
type shadow AdminOrganizationProjectGroupRoleNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *AdminOrganizationProjectGroupRoleNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectGroupRoleListParams struct {
// Cursor for pagination. Provide the value from the previous response's `next`
// field to continue listing project roles.
After param.Opt[string] `query:"after,omitzero" json:"-"`
// A limit on the number of project role assignments to return.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Sort order for the returned project roles.
//
// Any of "asc", "desc".
Order AdminOrganizationProjectGroupRoleListParamsOrder `query:"order,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [AdminOrganizationProjectGroupRoleListParams]'s query
// parameters as `url.Values`.
func (r AdminOrganizationProjectGroupRoleListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Sort order for the returned project roles.
type AdminOrganizationProjectGroupRoleListParamsOrder string
const (
AdminOrganizationProjectGroupRoleListParamsOrderAsc AdminOrganizationProjectGroupRoleListParamsOrder = "asc"
AdminOrganizationProjectGroupRoleListParamsOrderDesc AdminOrganizationProjectGroupRoleListParamsOrder = "desc"
)