Repository navigation
Expand file tree
/
Copy pathadminorganizationprojectcertificate.go
More file actions
353 lines (322 loc) · 16.1 KB
/
Copy pathadminorganizationprojectcertificate.go
File metadata and controls
353 lines (322 loc) · 16.1 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
// 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"
)
// AdminOrganizationProjectCertificateService 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 [NewAdminOrganizationProjectCertificateService] method instead.
type AdminOrganizationProjectCertificateService struct {
Options []option.RequestOption
}
// NewAdminOrganizationProjectCertificateService 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 NewAdminOrganizationProjectCertificateService(opts ...option.RequestOption) (r AdminOrganizationProjectCertificateService) {
r = AdminOrganizationProjectCertificateService{}
r.Options = requestconfig.InheritedOptions(opts...)
return
}
// List certificates for this project.
func (r *AdminOrganizationProjectCertificateService) List(ctx context.Context, projectID string, query AdminOrganizationProjectCertificateListParams, opts ...option.RequestOption) (res *pagination.ConversationCursorPage[AdminOrganizationProjectCertificateListResponse], 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
}
path := requestconfig.FormatPath("organization/projects/%s/certificates", projectID)
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
}
// List certificates for this project.
func (r *AdminOrganizationProjectCertificateService) ListAutoPaging(ctx context.Context, projectID string, query AdminOrganizationProjectCertificateListParams, opts ...option.RequestOption) *pagination.ConversationCursorPageAutoPager[AdminOrganizationProjectCertificateListResponse] {
return pagination.NewConversationCursorPageAutoPager(r.List(ctx, projectID, query, opts...))
}
// Activate certificates at the project level.
//
// You can atomically and idempotently activate up to 10 certificates at a time.
func (r *AdminOrganizationProjectCertificateService) Activate(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateActivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationProjectCertificateActivateResponse], 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
}
path := requestconfig.FormatPath("organization/projects/%s/certificates/activate", projectID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Activate certificates at the project level.
//
// You can atomically and idempotently activate up to 10 certificates at a time.
func (r *AdminOrganizationProjectCertificateService) ActivateAutoPaging(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateActivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationProjectCertificateActivateResponse] {
return pagination.NewPageAutoPager(r.Activate(ctx, projectID, body, opts...))
}
// Deactivate certificates at the project level. You can atomically and
// idempotently deactivate up to 10 certificates at a time.
func (r *AdminOrganizationProjectCertificateService) Deactivate(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateDeactivateParams, opts ...option.RequestOption) (res *pagination.Page[AdminOrganizationProjectCertificateDeactivateResponse], 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
}
path := requestconfig.FormatPath("organization/projects/%s/certificates/deactivate", projectID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Deactivate certificates at the project level. You can atomically and
// idempotently deactivate up to 10 certificates at a time.
func (r *AdminOrganizationProjectCertificateService) DeactivateAutoPaging(ctx context.Context, projectID string, body AdminOrganizationProjectCertificateDeactivateParams, opts ...option.RequestOption) *pagination.PageAutoPager[AdminOrganizationProjectCertificateDeactivateResponse] {
return pagination.NewPageAutoPager(r.Deactivate(ctx, projectID, body, opts...))
}
// Represents an individual certificate configured at the project level.
type AdminOrganizationProjectCertificateListResponse struct {
// The identifier, which can be referenced in API endpoints
ID string `json:"id" api:"required"`
// Whether the certificate is currently active at the project level.
Active bool `json:"active" api:"required"`
CertificateDetails AdminOrganizationProjectCertificateListResponseCertificateDetails `json:"certificate_details" api:"required"`
// The Unix timestamp (in seconds) of when the certificate was uploaded.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The name of the certificate.
Name string `json:"name" api:"required"`
// The object type, which is always `organization.project.certificate`.
Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Active respjson.Field
CertificateDetails respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateListResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectCertificateListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectCertificateListResponseCertificateDetails struct {
// The Unix timestamp (in seconds) of when the certificate expires.
ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// The Unix timestamp (in seconds) of when the certificate becomes valid.
ValidAt int64 `json:"valid_at" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExpiresAt respjson.Field
ValidAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateListResponseCertificateDetails) RawJSON() string {
return r.JSON.raw
}
func (r *AdminOrganizationProjectCertificateListResponseCertificateDetails) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Represents an individual certificate configured at the project level.
type AdminOrganizationProjectCertificateActivateResponse struct {
// The identifier, which can be referenced in API endpoints
ID string `json:"id" api:"required"`
// Whether the certificate is currently active at the project level.
Active bool `json:"active" api:"required"`
CertificateDetails AdminOrganizationProjectCertificateActivateResponseCertificateDetails `json:"certificate_details" api:"required"`
// The Unix timestamp (in seconds) of when the certificate was uploaded.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The name of the certificate.
Name string `json:"name" api:"required"`
// The object type, which is always `organization.project.certificate`.
Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Active respjson.Field
CertificateDetails respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateActivateResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectCertificateActivateResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectCertificateActivateResponseCertificateDetails struct {
// The Unix timestamp (in seconds) of when the certificate expires.
ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// The Unix timestamp (in seconds) of when the certificate becomes valid.
ValidAt int64 `json:"valid_at" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExpiresAt respjson.Field
ValidAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateActivateResponseCertificateDetails) RawJSON() string {
return r.JSON.raw
}
func (r *AdminOrganizationProjectCertificateActivateResponseCertificateDetails) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Represents an individual certificate configured at the project level.
type AdminOrganizationProjectCertificateDeactivateResponse struct {
// The identifier, which can be referenced in API endpoints
ID string `json:"id" api:"required"`
// Whether the certificate is currently active at the project level.
Active bool `json:"active" api:"required"`
CertificateDetails AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails `json:"certificate_details" api:"required"`
// The Unix timestamp (in seconds) of when the certificate was uploaded.
CreatedAt int64 `json:"created_at" api:"required" format:"unixtime"`
// The name of the certificate.
Name string `json:"name" api:"required"`
// The object type, which is always `organization.project.certificate`.
Object constant.OrganizationProjectCertificate `json:"object" default:"organization.project.certificate"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Active respjson.Field
CertificateDetails respjson.Field
CreatedAt respjson.Field
Name respjson.Field
Object respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateDeactivateResponse) RawJSON() string { return r.JSON.raw }
func (r *AdminOrganizationProjectCertificateDeactivateResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails struct {
// The Unix timestamp (in seconds) of when the certificate expires.
ExpiresAt int64 `json:"expires_at" format:"unixtime"`
// The Unix timestamp (in seconds) of when the certificate becomes valid.
ValidAt int64 `json:"valid_at" format:"unixtime"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ExpiresAt respjson.Field
ValidAt respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails) RawJSON() string {
return r.JSON.raw
}
func (r *AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectCertificateListParams struct {
// A cursor for use in pagination. `after` is an object ID that defines your place
// in the list. For instance, if you make a list request and receive 100 objects,
// ending with obj_foo, your subsequent call can include after=obj_foo in order to
// fetch the next page of the list.
After param.Opt[string] `query:"after,omitzero" json:"-"`
// A limit on the number of objects to be returned. Limit can range between 1 and
// 100, and the default is 20.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
//
// Any of "asc", "desc".
Order AdminOrganizationProjectCertificateListParamsOrder `query:"order,omitzero" json:"-"`
paramObj
}
// URLQuery serializes [AdminOrganizationProjectCertificateListParams]'s query
// parameters as `url.Values`.
func (r AdminOrganizationProjectCertificateListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
// order and `desc` for descending order.
type AdminOrganizationProjectCertificateListParamsOrder string
const (
AdminOrganizationProjectCertificateListParamsOrderAsc AdminOrganizationProjectCertificateListParamsOrder = "asc"
AdminOrganizationProjectCertificateListParamsOrderDesc AdminOrganizationProjectCertificateListParamsOrder = "desc"
)
type AdminOrganizationProjectCertificateActivateParams struct {
CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"`
paramObj
}
func (r AdminOrganizationProjectCertificateActivateParams) MarshalJSON() (data []byte, err error) {
type shadow AdminOrganizationProjectCertificateActivateParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *AdminOrganizationProjectCertificateActivateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
type AdminOrganizationProjectCertificateDeactivateParams struct {
CertificateIDs []string `json:"certificate_ids,omitzero" api:"required"`
paramObj
}
func (r AdminOrganizationProjectCertificateDeactivateParams) MarshalJSON() (data []byte, err error) {
type shadow AdminOrganizationProjectCertificateDeactivateParams
return param.MarshalObject(r, (*shadow)(&r))
}
func (r *AdminOrganizationProjectCertificateDeactivateParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}