-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathoas_client_gen.go
5091 lines (4603 loc) · 150 KB
/
oas_client_gen.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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by ogen, DO NOT EDIT.
package api
import (
"context"
"net/url"
"strings"
"time"
"github.com/go-faster/errors"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"github.com/ogen-go/ogen/conv"
ht "github.com/ogen-go/ogen/http"
"github.com/ogen-go/ogen/otelogen"
"github.com/ogen-go/ogen/uri"
)
// Invoker invokes operations described by OpenAPI v3 specification.
type Invoker interface {
// Authenticate invokes authenticate operation.
//
// This endpoint returns API tokens for a given email and password.
//
// POST /api/auth
Authenticate(ctx context.Context, request OptAuthenticateReq) (AuthenticateRes, error)
// CacheArtifactExists invokes cacheArtifactExists operation.
//
// This endpoint checks if an artifact exists in the cache. It returns a 404 status code if the
// artifact does not exist.
//
// Deprecated: schema marks this operation as deprecated.
//
// GET /api/cache/exists
CacheArtifactExists(ctx context.Context, params CacheArtifactExistsParams) (CacheArtifactExistsRes, error)
// CancelInvitation invokes cancelInvitation operation.
//
// Cancels an invitation for a given invitee email and an organization.
//
// DELETE /api/organizations/{organization_name}/invitations
CancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (CancelInvitationRes, error)
// CleanCache invokes cleanCache operation.
//
// Cleans cache for a given project.
//
// PUT /api/projects/{account_handle}/{project_handle}/cache/clean
CleanCache(ctx context.Context, params CleanCacheParams) (CleanCacheRes, error)
// CompleteAnalyticsArtifactMultipartUpload invokes completeAnalyticsArtifactMultipartUpload operation.
//
// Given the upload ID and all the parts with their ETags, this endpoint completes the multipart
// upload.
//
// POST /api/runs/{run_id}/complete
CompleteAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCompleteAnalyticsArtifactMultipartUploadReq, params CompleteAnalyticsArtifactMultipartUploadParams) (CompleteAnalyticsArtifactMultipartUploadRes, error)
// CompleteAnalyticsArtifactsUploads invokes completeAnalyticsArtifactsUploads operation.
//
// Given a command event, it marks all artifact uploads as finished and does extra processing of a
// given command run, such as test flakiness detection.
//
// PUT /api/runs/{run_id}/complete_artifacts_uploads
CompleteAnalyticsArtifactsUploads(ctx context.Context, request OptCompleteAnalyticsArtifactsUploadsReq, params CompleteAnalyticsArtifactsUploadsParams) (CompleteAnalyticsArtifactsUploadsRes, error)
// CompleteCacheArtifactMultipartUpload invokes completeCacheArtifactMultipartUpload operation.
//
// Given the upload ID and all the parts with their ETags, this endpoint completes the multipart
// upload. The cache will then be able to serve the artifact.
//
// POST /api/cache/multipart/complete
CompleteCacheArtifactMultipartUpload(ctx context.Context, request OptCompleteCacheArtifactMultipartUploadReq, params CompleteCacheArtifactMultipartUploadParams) (CompleteCacheArtifactMultipartUploadRes, error)
// CompletePreviewsMultipartUpload invokes completePreviewsMultipartUpload operation.
//
// Given the upload ID and all the parts with their ETags, this endpoint completes the multipart
// upload.
//
// POST /api/projects/{account_handle}/{project_handle}/previews/complete
CompletePreviewsMultipartUpload(ctx context.Context, request OptCompletePreviewsMultipartUploadReq, params CompletePreviewsMultipartUploadParams) (CompletePreviewsMultipartUploadRes, error)
// CreateAccountToken invokes createAccountToken operation.
//
// This endpoint returns a new account token.
//
// POST /api/accounts/{account_handle}/tokens
CreateAccountToken(ctx context.Context, request OptCreateAccountTokenReq, params CreateAccountTokenParams) (CreateAccountTokenRes, error)
// CreateCommandEvent invokes createCommandEvent operation.
//
// Create a a new command analytics event.
//
// POST /api/analytics
CreateCommandEvent(ctx context.Context, request OptCreateCommandEventReq, params CreateCommandEventParams) (CreateCommandEventRes, error)
// CreateInvitation invokes createInvitation operation.
//
// Invites a user with a given email to a given organization.
//
// POST /api/organizations/{organization_name}/invitations
CreateInvitation(ctx context.Context, request OptCreateInvitationReq, params CreateInvitationParams) (CreateInvitationRes, error)
// CreateOrganization invokes createOrganization operation.
//
// Creates an organization with the given name.
//
// POST /api/organizations
CreateOrganization(ctx context.Context, request OptCreateOrganizationReq) (CreateOrganizationRes, error)
// CreateProject invokes createProject operation.
//
// Create a new project.
//
// POST /api/projects
CreateProject(ctx context.Context, request OptCreateProjectReq) (CreateProjectRes, error)
// CreateProjectToken invokes createProjectToken operation.
//
// This endpoint returns a new project token.
//
// POST /api/projects/{account_handle}/{project_handle}/tokens
CreateProjectToken(ctx context.Context, params CreateProjectTokenParams) (CreateProjectTokenRes, error)
// DeleteOrganization invokes deleteOrganization operation.
//
// Deletes the organization with the given name.
//
// DELETE /api/organizations/{organization_name}
DeleteOrganization(ctx context.Context, params DeleteOrganizationParams) (DeleteOrganizationRes, error)
// DeleteProject invokes deleteProject operation.
//
// Deletes a project with a given id.
//
// DELETE /api/projects/{id}
DeleteProject(ctx context.Context, params DeleteProjectParams) (DeleteProjectRes, error)
// DownloadCacheArtifact invokes downloadCacheArtifact operation.
//
// This endpoint returns a signed URL that can be used to download an artifact from the cache.
//
// GET /api/cache
DownloadCacheArtifact(ctx context.Context, params DownloadCacheArtifactParams) (DownloadCacheArtifactRes, error)
// DownloadPreview invokes downloadPreview operation.
//
// This endpoint returns a preview with a given id, including the url to download the preview.
//
// GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id}
DownloadPreview(ctx context.Context, params DownloadPreviewParams) (DownloadPreviewRes, error)
// GenerateAnalyticsArtifactMultipartUploadURL invokes generateAnalyticsArtifactMultipartUploadURL operation.
//
// Given an upload ID and a part number, this endpoint returns a signed URL that can be used to
// upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.
//
// POST /api/runs/{run_id}/generate-url
GenerateAnalyticsArtifactMultipartUploadURL(ctx context.Context, request OptGenerateAnalyticsArtifactMultipartUploadURLReq, params GenerateAnalyticsArtifactMultipartUploadURLParams) (GenerateAnalyticsArtifactMultipartUploadURLRes, error)
// GenerateCacheArtifactMultipartUploadURL invokes generateCacheArtifactMultipartUploadURL operation.
//
// Given an upload ID and a part number, this endpoint returns a signed URL that can be used to
// upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.
//
// POST /api/cache/multipart/generate-url
GenerateCacheArtifactMultipartUploadURL(ctx context.Context, params GenerateCacheArtifactMultipartUploadURLParams) (GenerateCacheArtifactMultipartUploadURLRes, error)
// GeneratePreviewsMultipartUploadURL invokes generatePreviewsMultipartUploadURL operation.
//
// Given an upload ID and a part number, this endpoint returns a signed URL that can be used to
// upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.
//
// POST /api/projects/{account_handle}/{project_handle}/previews/generate-url
GeneratePreviewsMultipartUploadURL(ctx context.Context, request OptGeneratePreviewsMultipartUploadURLReq, params GeneratePreviewsMultipartUploadURLParams) (GeneratePreviewsMultipartUploadURLRes, error)
// GetCacheActionItem invokes getCacheActionItem operation.
//
// This endpoint gets an item from the action cache.
//
// GET /api/projects/{account_handle}/{project_handle}/cache/ac/{hash}
GetCacheActionItem(ctx context.Context, params GetCacheActionItemParams) (GetCacheActionItemRes, error)
// GetDeviceCode invokes getDeviceCode operation.
//
// This endpoint returns a token for a given device code if the device code is authenticated.
//
// GET /api/auth/device_code/{device_code}
GetDeviceCode(ctx context.Context, params GetDeviceCodeParams) (GetDeviceCodeRes, error)
// ListOrganizations invokes listOrganizations operation.
//
// Returns all the organizations the authenticated subject is part of.
//
// GET /api/organizations
ListOrganizations(ctx context.Context) (ListOrganizationsRes, error)
// ListPreviews invokes listPreviews operation.
//
// This endpoint returns a list of previews for a given project.
//
// GET /api/projects/{account_handle}/{project_handle}/previews
ListPreviews(ctx context.Context, params ListPreviewsParams) (ListPreviewsRes, error)
// ListProjectTokens invokes listProjectTokens operation.
//
// This endpoint returns all tokens for a given project.
//
// GET /api/projects/{account_handle}/{project_handle}/tokens
ListProjectTokens(ctx context.Context, params ListProjectTokensParams) (ListProjectTokensRes, error)
// ListProjects invokes listProjects operation.
//
// List projects the authenticated user has access to.
//
// GET /api/projects
ListProjects(ctx context.Context) (ListProjectsRes, error)
// ListRuns invokes listRuns operation.
//
// List runs associated with a given project.
//
// GET /api/projects/{account_handle}/{project_handle}/runs
ListRuns(ctx context.Context, params ListRunsParams) (ListRunsRes, error)
// RefreshToken invokes refreshToken operation.
//
// This endpoint returns new tokens for a given refresh token if the refresh token is valid.
//
// POST /api/auth/refresh_token
RefreshToken(ctx context.Context, request OptRefreshTokenReq) (RefreshTokenRes, error)
// RevokeProjectToken invokes revokeProjectToken operation.
//
// Revokes a project token.
//
// DELETE /api/projects/{account_handle}/{project_handle}/tokens/{id}
RevokeProjectToken(ctx context.Context, params RevokeProjectTokenParams) (RevokeProjectTokenRes, error)
// ShowOrganization invokes showOrganization operation.
//
// Returns the organization with the given identifier.
//
// GET /api/organizations/{organization_name}
ShowOrganization(ctx context.Context, params ShowOrganizationParams) (ShowOrganizationRes, error)
// ShowOrganizationUsage invokes showOrganizationUsage operation.
//
// Returns the usage of the organization with the given identifier. (e.g. number of remote cache hits).
//
// GET /api/organizations/{organization_name}/usage
ShowOrganizationUsage(ctx context.Context, params ShowOrganizationUsageParams) (ShowOrganizationUsageRes, error)
// ShowProject invokes showProject operation.
//
// Returns a project based on the handle.
//
// GET /api/projects/{account_handle}/{project_handle}
ShowProject(ctx context.Context, params ShowProjectParams) (ShowProjectRes, error)
// StartAnalyticsArtifactMultipartUpload invokes startAnalyticsArtifactMultipartUpload operation.
//
// The endpoint returns an upload ID that can be used to generate URLs for the individual parts and
// complete the upload.
//
// POST /api/runs/{run_id}/start
StartAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error)
// StartCacheArtifactMultipartUpload invokes startCacheArtifactMultipartUpload operation.
//
// The endpoint returns an upload ID that can be used to generate URLs for the individual parts and
// complete the upload.
//
// POST /api/cache/multipart/start
StartCacheArtifactMultipartUpload(ctx context.Context, params StartCacheArtifactMultipartUploadParams) (StartCacheArtifactMultipartUploadRes, error)
// StartPreviewsMultipartUpload invokes startPreviewsMultipartUpload operation.
//
// The endpoint returns an upload ID that can be used to generate URLs for the individual parts and
// complete the upload.
//
// POST /api/projects/{account_handle}/{project_handle}/previews/start
StartPreviewsMultipartUpload(ctx context.Context, request OptStartPreviewsMultipartUploadReq, params StartPreviewsMultipartUploadParams) (StartPreviewsMultipartUploadRes, error)
// UpdateAccount invokes updateAccount operation.
//
// Updates the given account.
//
// PATCH /api/accounts/{account_handle}
UpdateAccount(ctx context.Context, request OptUpdateAccountReq, params UpdateAccountParams) (UpdateAccountRes, error)
// UpdateOrganization invokes updateOrganization operation.
//
// Updates an organization with given parameters.
//
// PUT /api/organizations/{organization_name}
UpdateOrganization(ctx context.Context, request OptUpdateOrganizationReq, params UpdateOrganizationParams) (UpdateOrganizationRes, error)
// UpdateOrganization2 invokes updateOrganization (2) operation.
//
// Updates an organization with given parameters.
//
// PATCH /api/organizations/{organization_name}
UpdateOrganization2(ctx context.Context, request OptUpdateOrganization2Req, params UpdateOrganization2Params) (UpdateOrganization2Res, error)
// UpdateOrganizationMember invokes updateOrganizationMember operation.
//
// Updates a member in a given organization.
//
// PUT /api/organizations/{organization_name}/members/{user_name}
UpdateOrganizationMember(ctx context.Context, request OptUpdateOrganizationMemberReq, params UpdateOrganizationMemberParams) (UpdateOrganizationMemberRes, error)
// UpdateProject invokes updateProject operation.
//
// Updates a project with given parameters.
//
// PUT /api/projects/{account_handle}/{project_handle}
UpdateProject(ctx context.Context, request OptUpdateProjectReq, params UpdateProjectParams) (UpdateProjectRes, error)
// UploadCacheActionItem invokes uploadCacheActionItem operation.
//
// The endpoint caches a given action item without uploading a file. To upload files, use the
// multipart upload instead.
//
// POST /api/projects/{account_handle}/{project_handle}/cache/ac
UploadCacheActionItem(ctx context.Context, request OptUploadCacheActionItemReq, params UploadCacheActionItemParams) (UploadCacheActionItemRes, error)
// UploadPreviewIcon invokes uploadPreviewIcon operation.
//
// The endpoint uploads a preview icon.
//
// POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons
UploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (UploadPreviewIconRes, error)
}
// Client implements OAS client.
type Client struct {
serverURL *url.URL
baseClient
}
var _ Handler = struct {
*Client
}{}
func trimTrailingSlashes(u *url.URL) {
u.Path = strings.TrimRight(u.Path, "/")
u.RawPath = strings.TrimRight(u.RawPath, "/")
}
// NewClient initializes new Client defined by OAS.
func NewClient(serverURL string, opts ...ClientOption) (*Client, error) {
u, err := url.Parse(serverURL)
if err != nil {
return nil, err
}
trimTrailingSlashes(u)
c, err := newClientConfig(opts...).baseClient()
if err != nil {
return nil, err
}
return &Client{
serverURL: u,
baseClient: c,
}, nil
}
type serverURLKey struct{}
// WithServerURL sets context key to override server URL.
func WithServerURL(ctx context.Context, u *url.URL) context.Context {
return context.WithValue(ctx, serverURLKey{}, u)
}
func (c *Client) requestURL(ctx context.Context) *url.URL {
u, ok := ctx.Value(serverURLKey{}).(*url.URL)
if !ok {
return c.serverURL
}
return u
}
// Authenticate invokes authenticate operation.
//
// This endpoint returns API tokens for a given email and password.
//
// POST /api/auth
func (c *Client) Authenticate(ctx context.Context, request OptAuthenticateReq) (AuthenticateRes, error) {
res, err := c.sendAuthenticate(ctx, request)
return res, err
}
func (c *Client) sendAuthenticate(ctx context.Context, request OptAuthenticateReq) (res AuthenticateRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("authenticate"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/api/auth"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "Authenticate",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [1]string
pathParts[0] = "/api/auth"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeAuthenticateRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeAuthenticateResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CacheArtifactExists invokes cacheArtifactExists operation.
//
// This endpoint checks if an artifact exists in the cache. It returns a 404 status code if the
// artifact does not exist.
//
// Deprecated: schema marks this operation as deprecated.
//
// GET /api/cache/exists
func (c *Client) CacheArtifactExists(ctx context.Context, params CacheArtifactExistsParams) (CacheArtifactExistsRes, error) {
res, err := c.sendCacheArtifactExists(ctx, params)
return res, err
}
func (c *Client) sendCacheArtifactExists(ctx context.Context, params CacheArtifactExistsParams) (res CacheArtifactExistsRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("cacheArtifactExists"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/api/cache/exists"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CacheArtifactExists",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [1]string
pathParts[0] = "/api/cache/exists"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeQueryParams"
q := uri.NewQueryEncoder()
{
// Encode "cache_category" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "cache_category",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
if val, ok := params.CacheCategory.Get(); ok {
return e.EncodeValue(conv.StringToString(string(val)))
}
return nil
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "project_id" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "project_id",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(params.ProjectID))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "hash" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "hash",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(params.Hash))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
{
// Encode "name" parameter.
cfg := uri.QueryParameterEncodingConfig{
Name: "name",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(params.Name))
}); err != nil {
return res, errors.Wrap(err, "encode query")
}
}
u.RawQuery = q.Values().Encode()
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "GET", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCacheArtifactExistsResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CancelInvitation invokes cancelInvitation operation.
//
// Cancels an invitation for a given invitee email and an organization.
//
// DELETE /api/organizations/{organization_name}/invitations
func (c *Client) CancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (CancelInvitationRes, error) {
res, err := c.sendCancelInvitation(ctx, request, params)
return res, err
}
func (c *Client) sendCancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (res CancelInvitationRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("cancelInvitation"),
semconv.HTTPRequestMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/api/organizations/{organization_name}/invitations"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CancelInvitation",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [3]string
pathParts[0] = "/api/organizations/"
{
// Encode "organization_name" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "organization_name",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.StringToString(params.OrganizationName))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
encoded, err := e.Result()
if err != nil {
return res, errors.Wrap(err, "encode path")
}
pathParts[1] = encoded
}
pathParts[2] = "/invitations"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "DELETE", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCancelInvitationRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCancelInvitationResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CleanCache invokes cleanCache operation.
//
// Cleans cache for a given project.
//
// PUT /api/projects/{account_handle}/{project_handle}/cache/clean
func (c *Client) CleanCache(ctx context.Context, params CleanCacheParams) (CleanCacheRes, error) {
res, err := c.sendCleanCache(ctx, params)
return res, err
}
func (c *Client) sendCleanCache(ctx context.Context, params CleanCacheParams) (res CleanCacheRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("cleanCache"),
semconv.HTTPRequestMethodKey.String("PUT"),
semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/cache/clean"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CleanCache",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [5]string
pathParts[0] = "/api/projects/"
{
// Encode "account_handle" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "account_handle",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.StringToString(params.AccountHandle))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
encoded, err := e.Result()
if err != nil {
return res, errors.Wrap(err, "encode path")
}
pathParts[1] = encoded
}
pathParts[2] = "/"
{
// Encode "project_handle" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "project_handle",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.StringToString(params.ProjectHandle))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
encoded, err := e.Result()
if err != nil {
return res, errors.Wrap(err, "encode path")
}
pathParts[3] = encoded
}
pathParts[4] = "/cache/clean"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PUT", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCleanCacheResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CompleteAnalyticsArtifactMultipartUpload invokes completeAnalyticsArtifactMultipartUpload operation.
//
// Given the upload ID and all the parts with their ETags, this endpoint completes the multipart
// upload.
//
// POST /api/runs/{run_id}/complete
func (c *Client) CompleteAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCompleteAnalyticsArtifactMultipartUploadReq, params CompleteAnalyticsArtifactMultipartUploadParams) (CompleteAnalyticsArtifactMultipartUploadRes, error) {
res, err := c.sendCompleteAnalyticsArtifactMultipartUpload(ctx, request, params)
return res, err
}
func (c *Client) sendCompleteAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCompleteAnalyticsArtifactMultipartUploadReq, params CompleteAnalyticsArtifactMultipartUploadParams) (res CompleteAnalyticsArtifactMultipartUploadRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("completeAnalyticsArtifactMultipartUpload"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/api/runs/{run_id}/complete"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CompleteAnalyticsArtifactMultipartUpload",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [3]string
pathParts[0] = "/api/runs/"
{
// Encode "run_id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "run_id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.RunID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
encoded, err := e.Result()
if err != nil {
return res, errors.Wrap(err, "encode path")
}
pathParts[1] = encoded
}
pathParts[2] = "/complete"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "POST", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCompleteAnalyticsArtifactMultipartUploadRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCompleteAnalyticsArtifactMultipartUploadResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CompleteAnalyticsArtifactsUploads invokes completeAnalyticsArtifactsUploads operation.
//
// Given a command event, it marks all artifact uploads as finished and does extra processing of a
// given command run, such as test flakiness detection.
//
// PUT /api/runs/{run_id}/complete_artifacts_uploads
func (c *Client) CompleteAnalyticsArtifactsUploads(ctx context.Context, request OptCompleteAnalyticsArtifactsUploadsReq, params CompleteAnalyticsArtifactsUploadsParams) (CompleteAnalyticsArtifactsUploadsRes, error) {
res, err := c.sendCompleteAnalyticsArtifactsUploads(ctx, request, params)
return res, err
}
func (c *Client) sendCompleteAnalyticsArtifactsUploads(ctx context.Context, request OptCompleteAnalyticsArtifactsUploadsReq, params CompleteAnalyticsArtifactsUploadsParams) (res CompleteAnalyticsArtifactsUploadsRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("completeAnalyticsArtifactsUploads"),
semconv.HTTPRequestMethodKey.String("PUT"),
semconv.HTTPRouteKey.String("/api/runs/{run_id}/complete_artifacts_uploads"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CompleteAnalyticsArtifactsUploads",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"
u := uri.Clone(c.requestURL(ctx))
var pathParts [3]string
pathParts[0] = "/api/runs/"
{
// Encode "run_id" parameter.
e := uri.NewPathEncoder(uri.PathEncoderConfig{
Param: "run_id",
Style: uri.PathStyleSimple,
Explode: false,
})
if err := func() error {
return e.EncodeValue(conv.IntToString(params.RunID))
}(); err != nil {
return res, errors.Wrap(err, "encode path")
}
encoded, err := e.Result()
if err != nil {
return res, errors.Wrap(err, "encode path")
}
pathParts[1] = encoded
}
pathParts[2] = "/complete_artifacts_uploads"
uri.AddPathParts(u, pathParts[:]...)
stage = "EncodeRequest"
r, err := ht.NewRequest(ctx, "PUT", u)
if err != nil {
return res, errors.Wrap(err, "create request")
}
if err := encodeCompleteAnalyticsArtifactsUploadsRequest(request, r); err != nil {
return res, errors.Wrap(err, "encode request")
}
stage = "SendRequest"
resp, err := c.cfg.Client.Do(r)
if err != nil {
return res, errors.Wrap(err, "do request")
}
defer resp.Body.Close()
stage = "DecodeResponse"
result, err := decodeCompleteAnalyticsArtifactsUploadsResponse(resp)
if err != nil {
return res, errors.Wrap(err, "decode response")
}
return result, nil
}
// CompleteCacheArtifactMultipartUpload invokes completeCacheArtifactMultipartUpload operation.
//
// Given the upload ID and all the parts with their ETags, this endpoint completes the multipart
// upload. The cache will then be able to serve the artifact.
//
// POST /api/cache/multipart/complete
func (c *Client) CompleteCacheArtifactMultipartUpload(ctx context.Context, request OptCompleteCacheArtifactMultipartUploadReq, params CompleteCacheArtifactMultipartUploadParams) (CompleteCacheArtifactMultipartUploadRes, error) {
res, err := c.sendCompleteCacheArtifactMultipartUpload(ctx, request, params)
return res, err
}
func (c *Client) sendCompleteCacheArtifactMultipartUpload(ctx context.Context, request OptCompleteCacheArtifactMultipartUploadReq, params CompleteCacheArtifactMultipartUploadParams) (res CompleteCacheArtifactMultipartUploadRes, err error) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("completeCacheArtifactMultipartUpload"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/api/cache/multipart/complete"),
}
// Run stopwatch.
startTime := time.Now()
defer func() {
// Use floating point division here for higher precision (instead of Millisecond method).
elapsedDuration := time.Since(startTime)
c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...))
}()
// Increment request counter.
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
// Start a span for this request.
ctx, span := c.cfg.Tracer.Start(ctx, "CompleteCacheArtifactMultipartUpload",
trace.WithAttributes(otelAttrs...),
clientSpanKind,
)
// Track stage for error reporting.
var stage string
defer func() {
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
}
span.End()
}()
stage = "BuildURL"