-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganization.go
1043 lines (967 loc) · 35.1 KB
/
organization.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package gitpod
import (
"context"
"net/http"
"net/url"
"time"
"github.com/gitpod-io/gitpod-sdk-go/internal/apijson"
"github.com/gitpod-io/gitpod-sdk-go/internal/apiquery"
"github.com/gitpod-io/gitpod-sdk-go/internal/param"
"github.com/gitpod-io/gitpod-sdk-go/internal/requestconfig"
"github.com/gitpod-io/gitpod-sdk-go/option"
"github.com/gitpod-io/gitpod-sdk-go/packages/pagination"
"github.com/gitpod-io/gitpod-sdk-go/shared"
)
// OrganizationService contains methods and other services that help with
// interacting with the gitpod 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 [NewOrganizationService] method instead.
type OrganizationService struct {
Options []option.RequestOption
DomainVerifications *OrganizationDomainVerificationService
Invites *OrganizationInviteService
SSOConfigurations *OrganizationSSOConfigurationService
}
// NewOrganizationService 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 NewOrganizationService(opts ...option.RequestOption) (r *OrganizationService) {
r = &OrganizationService{}
r.Options = opts
r.DomainVerifications = NewOrganizationDomainVerificationService(opts...)
r.Invites = NewOrganizationInviteService(opts...)
r.SSOConfigurations = NewOrganizationSSOConfigurationService(opts...)
return
}
// Creates a new organization with the specified name and settings.
//
// Use this method to:
//
// - Create a new organization for team collaboration
// - Set up automatic domain-based invites for team members
// - Join the organization immediately upon creation
//
// ### Examples
//
// - Create a basic organization:
//
// Creates an organization with just a name.
//
// ```yaml
// name: "Acme Corp Engineering"
// joinOrganization: true
// ```
//
// - Create with domain-based invites:
//
// Creates an organization that automatically invites users with matching email
// domains.
//
// ```yaml
// name: "Acme Corp"
// joinOrganization: true
// inviteAccountsWithMatchingDomain: true
// ```
func (r *OrganizationService) New(ctx context.Context, body OrganizationNewParams, opts ...option.RequestOption) (res *OrganizationNewResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/CreateOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Gets details about a specific organization.
//
// Use this method to:
//
// - Retrieve organization settings and configuration
// - Check organization membership status
// - View domain verification settings
//
// ### Examples
//
// - Get organization details:
//
// Retrieves information about a specific organization.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// ```
func (r *OrganizationService) Get(ctx context.Context, body OrganizationGetParams, opts ...option.RequestOption) (res *OrganizationGetResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/GetOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Updates an organization's settings including name, invite domains, and member
// policies.
//
// Use this method to:
//
// - Modify organization display name
// - Configure email domain restrictions
// - Update organization-wide settings
// - Manage member access policies
//
// ### Examples
//
// - Update basic settings:
//
// Changes organization name and invite domains.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// name: "New Company Name"
// inviteDomains:
// domains:
// - "company.com"
// - "subsidiary.com"
// ```
//
// - Remove domain restrictions:
//
// Clears all domain-based invite restrictions.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// inviteDomains:
// domains: []
// ```
func (r *OrganizationService) Update(ctx context.Context, body OrganizationUpdateParams, opts ...option.RequestOption) (res *OrganizationUpdateResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/UpdateOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Lists all organizations the caller has access to with optional filtering.
//
// Use this method to:
//
// - View organizations you're a member of
// - Browse all available organizations
// - Paginate through organization results
//
// ### Examples
//
// - List member organizations:
//
// Shows organizations where the caller is a member.
//
// ```yaml
// pagination:
// pageSize: 20
// scope: SCOPE_MEMBER
// ```
//
// - List all organizations:
//
// Shows all organizations visible to the caller.
//
// ```yaml
// pagination:
// pageSize: 50
// scope: SCOPE_ALL
// ```
func (r *OrganizationService) List(ctx context.Context, params OrganizationListParams, opts ...option.RequestOption) (res *pagination.OrganizationsPage[Organization], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "gitpod.v1.OrganizationService/ListOrganizations"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &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 all organizations the caller has access to with optional filtering.
//
// Use this method to:
//
// - View organizations you're a member of
// - Browse all available organizations
// - Paginate through organization results
//
// ### Examples
//
// - List member organizations:
//
// Shows organizations where the caller is a member.
//
// ```yaml
// pagination:
// pageSize: 20
// scope: SCOPE_MEMBER
// ```
//
// - List all organizations:
//
// Shows all organizations visible to the caller.
//
// ```yaml
// pagination:
// pageSize: 50
// scope: SCOPE_ALL
// ```
func (r *OrganizationService) ListAutoPaging(ctx context.Context, params OrganizationListParams, opts ...option.RequestOption) *pagination.OrganizationsPageAutoPager[Organization] {
return pagination.NewOrganizationsPageAutoPager(r.List(ctx, params, opts...))
}
// Permanently deletes an organization.
//
// Use this method to:
//
// - Remove unused organizations
// - Clean up test organizations
// - Complete organization migration
//
// ### Examples
//
// - Delete organization:
//
// Permanently removes an organization and all its data.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// ```
func (r *OrganizationService) Delete(ctx context.Context, body OrganizationDeleteParams, opts ...option.RequestOption) (res *OrganizationDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/DeleteOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Allows users to join an organization through direct ID, invite link, or
// domain-based auto-join.
//
// Use this method to:
//
// - Join an organization via direct ID or invite
// - Join automatically based on email domain
// - Accept organization invitations
//
// ### Examples
//
// - Join via organization ID:
//
// Joins an organization directly when you have the ID.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// ```
//
// - Join via invite:
//
// Accepts an organization invitation link.
//
// ```yaml
// inviteId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
// ```
func (r *OrganizationService) Join(ctx context.Context, body OrganizationJoinParams, opts ...option.RequestOption) (res *OrganizationJoinResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/JoinOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Removes a user from an organization while preserving organization data.
//
// Use this method to:
//
// - Remove yourself from an organization
// - Clean up inactive memberships
// - Transfer project ownership before leaving
// - Manage team transitions
//
// ### Examples
//
// - Leave organization:
//
// Removes user from organization membership.
//
// ```yaml
// userId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
// ```
//
// Note: Ensure all projects and resources are transferred before leaving.
func (r *OrganizationService) Leave(ctx context.Context, body OrganizationLeaveParams, opts ...option.RequestOption) (res *OrganizationLeaveResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/LeaveOrganization"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Lists and filters organization members with optional pagination.
//
// Use this method to:
//
// - View all organization members
// - Monitor member activity
// - Manage team membership
//
// ### Examples
//
// - List active members:
//
// Retrieves active members with pagination.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// pagination:
// pageSize: 20
// ```
//
// - List with pagination:
//
// Retrieves next page of members.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// pagination:
// pageSize: 50
// token: "next-page-token-from-previous-response"
// ```
func (r *OrganizationService) ListMembers(ctx context.Context, params OrganizationListMembersParams, opts ...option.RequestOption) (res *pagination.MembersPage[OrganizationMember], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "gitpod.v1.OrganizationService/ListMembers"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, params, &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 and filters organization members with optional pagination.
//
// Use this method to:
//
// - View all organization members
// - Monitor member activity
// - Manage team membership
//
// ### Examples
//
// - List active members:
//
// Retrieves active members with pagination.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// pagination:
// pageSize: 20
// ```
//
// - List with pagination:
//
// Retrieves next page of members.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// pagination:
// pageSize: 50
// token: "next-page-token-from-previous-response"
// ```
func (r *OrganizationService) ListMembersAutoPaging(ctx context.Context, params OrganizationListMembersParams, opts ...option.RequestOption) *pagination.MembersPageAutoPager[OrganizationMember] {
return pagination.NewMembersPageAutoPager(r.ListMembers(ctx, params, opts...))
}
// Manages organization membership and roles by setting a user's role within the
// organization.
//
// Use this method to:
//
// - Promote members to admin role
// - Change member permissions
// - Demote admins to regular members
//
// ### Examples
//
// - Promote to admin:
//
// Makes a user an organization administrator.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// userId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
// role: ORGANIZATION_ROLE_ADMIN
// ```
//
// - Change to member:
//
// Changes a user's role to regular member.
//
// ```yaml
// organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
// userId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
// role: ORGANIZATION_ROLE_MEMBER
// ```
func (r *OrganizationService) SetRole(ctx context.Context, body OrganizationSetRoleParams, opts ...option.RequestOption) (res *OrganizationSetRoleResponse, err error) {
opts = append(r.Options[:], opts...)
path := "gitpod.v1.OrganizationService/SetRole"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type InviteDomains struct {
// domains is the list of domains that are allowed to join the organization
Domains []string `json:"domains"`
JSON inviteDomainsJSON `json:"-"`
}
// inviteDomainsJSON contains the JSON metadata for the struct [InviteDomains]
type inviteDomainsJSON struct {
Domains apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InviteDomains) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inviteDomainsJSON) RawJSON() string {
return r.raw
}
type InviteDomainsParam struct {
// domains is the list of domains that are allowed to join the organization
Domains param.Field[[]string] `json:"domains"`
}
func (r InviteDomainsParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type Organization struct {
ID string `json:"id,required" format:"uuid"`
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at nanosecond
// resolution. The count is relative to an epoch at UTC midnight on January 1,
// 1970, in the proleptic Gregorian calendar which extends the Gregorian calendar
// backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a
// [24-hour linear smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
// Example 5: Compute Timestamp from Java `Instant.now()`.
//
// Instant now = Instant.now();
//
// Timestamp timestamp =
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
// .setNanos(now.getNano()).build();
//
// Example 6: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the format is
// "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where {year} is always
// expressed using four digits while {month}, {day}, {hour}, {min}, and {sec} are
// zero-padded to two digits each. The fractional seconds, which can go up to 9
// digits (i.e. up to 1 nanosecond resolution), are optional. The "Z" suffix
// indicates the timezone ("UTC"); the timezone is required. A proto3 JSON
// serializer should always use UTC (as indicated by "Z") when printing the
// Timestamp type and a proto3 JSON parser should be able to accept both UTC and
// other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 01:30 UTC on
// January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted to
// this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with the
// time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use the
// Joda Time's
// [`ISODateTimeFormat.dateTime()`](<http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()>)
// to obtain a formatter capable of generating timestamps in this format.
CreatedAt time.Time `json:"createdAt,required" format:"date-time"`
Name string `json:"name,required"`
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at nanosecond
// resolution. The count is relative to an epoch at UTC midnight on January 1,
// 1970, in the proleptic Gregorian calendar which extends the Gregorian calendar
// backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a
// [24-hour linear smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
// Example 5: Compute Timestamp from Java `Instant.now()`.
//
// Instant now = Instant.now();
//
// Timestamp timestamp =
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
// .setNanos(now.getNano()).build();
//
// Example 6: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the format is
// "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where {year} is always
// expressed using four digits while {month}, {day}, {hour}, {min}, and {sec} are
// zero-padded to two digits each. The fractional seconds, which can go up to 9
// digits (i.e. up to 1 nanosecond resolution), are optional. The "Z" suffix
// indicates the timezone ("UTC"); the timezone is required. A proto3 JSON
// serializer should always use UTC (as indicated by "Z") when printing the
// Timestamp type and a proto3 JSON parser should be able to accept both UTC and
// other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 01:30 UTC on
// January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted to
// this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with the
// time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use the
// Joda Time's
// [`ISODateTimeFormat.dateTime()`](<http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()>)
// to obtain a formatter capable of generating timestamps in this format.
UpdatedAt time.Time `json:"updatedAt,required" format:"date-time"`
InviteDomains InviteDomains `json:"inviteDomains"`
JSON organizationJSON `json:"-"`
}
// organizationJSON contains the JSON metadata for the struct [Organization]
type organizationJSON struct {
ID apijson.Field
CreatedAt apijson.Field
Name apijson.Field
UpdatedAt apijson.Field
InviteDomains apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Organization) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationJSON) RawJSON() string {
return r.raw
}
type OrganizationMember struct {
Email string `json:"email,required"`
FullName string `json:"fullName,required"`
// login_provider is the login provider the user uses to sign in
LoginProvider string `json:"loginProvider,required"`
// A Timestamp represents a point in time independent of any time zone or local
// calendar, encoded as a count of seconds and fractions of seconds at nanosecond
// resolution. The count is relative to an epoch at UTC midnight on January 1,
// 1970, in the proleptic Gregorian calendar which extends the Gregorian calendar
// backwards to year one.
//
// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
// second table is needed for interpretation, using a
// [24-hour linear smear](https://developers.google.com/time/smear).
//
// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
// restricting to that range, we ensure that we can convert to and from
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
//
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`.
//
// Timestamp timestamp;
// timestamp.set_seconds(time(NULL));
// timestamp.set_nanos(0);
//
// Example 2: Compute Timestamp from POSIX `gettimeofday()`.
//
// struct timeval tv;
// gettimeofday(&tv, NULL);
//
// Timestamp timestamp;
// timestamp.set_seconds(tv.tv_sec);
// timestamp.set_nanos(tv.tv_usec * 1000);
//
// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
//
// FILETIME ft;
// GetSystemTimeAsFileTime(&ft);
// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
//
// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
// Timestamp timestamp;
// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
//
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
//
// long millis = System.currentTimeMillis();
//
// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
// .setNanos((int) ((millis % 1000) * 1000000)).build();
//
// Example 5: Compute Timestamp from Java `Instant.now()`.
//
// Instant now = Instant.now();
//
// Timestamp timestamp =
// Timestamp.newBuilder().setSeconds(now.getEpochSecond())
// .setNanos(now.getNano()).build();
//
// Example 6: Compute Timestamp from current time in Python.
//
// timestamp = Timestamp()
// timestamp.GetCurrentTime()
//
// # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the format is
// "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" where {year} is always
// expressed using four digits while {month}, {day}, {hour}, {min}, and {sec} are
// zero-padded to two digits each. The fractional seconds, which can go up to 9
// digits (i.e. up to 1 nanosecond resolution), are optional. The "Z" suffix
// indicates the timezone ("UTC"); the timezone is required. A proto3 JSON
// serializer should always use UTC (as indicated by "Z") when printing the
// Timestamp type and a proto3 JSON parser should be able to accept both UTC and
// other timezones (as indicated by an offset).
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 01:30 UTC on
// January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the standard
// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
// method. In Python, a standard `datetime.datetime` object can be converted to
// this format using
// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with the
// time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use the
// Joda Time's
// [`ISODateTimeFormat.dateTime()`](<http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()>)
// to obtain a formatter capable of generating timestamps in this format.
MemberSince time.Time `json:"memberSince,required" format:"date-time"`
Role shared.OrganizationRole `json:"role,required"`
Status shared.UserStatus `json:"status,required"`
UserID string `json:"userId,required" format:"uuid"`
AvatarURL string `json:"avatarUrl"`
JSON organizationMemberJSON `json:"-"`
}
// organizationMemberJSON contains the JSON metadata for the struct
// [OrganizationMember]
type organizationMemberJSON struct {
Email apijson.Field
FullName apijson.Field
LoginProvider apijson.Field
MemberSince apijson.Field
Role apijson.Field
Status apijson.Field
UserID apijson.Field
AvatarURL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *OrganizationMember) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationMemberJSON) RawJSON() string {
return r.raw
}
type Scope string
const (
ScopeUnspecified Scope = "SCOPE_UNSPECIFIED"
ScopeMember Scope = "SCOPE_MEMBER"
ScopeAll Scope = "SCOPE_ALL"
)
func (r Scope) IsKnown() bool {
switch r {
case ScopeUnspecified, ScopeMember, ScopeAll:
return true
}
return false
}
type OrganizationNewResponse struct {
// organization is the created organization
Organization Organization `json:"organization,required"`
// member is the member that joined the org on creation. Only set if specified
// "join_organization" is "true" in the request.
Member OrganizationMember `json:"member"`
JSON organizationNewResponseJSON `json:"-"`
}
// organizationNewResponseJSON contains the JSON metadata for the struct
// [OrganizationNewResponse]
type organizationNewResponseJSON struct {
Organization apijson.Field
Member apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *OrganizationNewResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationNewResponseJSON) RawJSON() string {
return r.raw
}
type OrganizationGetResponse struct {
// organization is the requested organization
Organization Organization `json:"organization,required"`
JSON organizationGetResponseJSON `json:"-"`
}
// organizationGetResponseJSON contains the JSON metadata for the struct
// [OrganizationGetResponse]
type organizationGetResponseJSON struct {
Organization apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *OrganizationGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationGetResponseJSON) RawJSON() string {
return r.raw
}
type OrganizationUpdateResponse struct {
// organization is the updated organization
Organization Organization `json:"organization,required"`
JSON organizationUpdateResponseJSON `json:"-"`
}
// organizationUpdateResponseJSON contains the JSON metadata for the struct
// [OrganizationUpdateResponse]
type organizationUpdateResponseJSON struct {
Organization apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *OrganizationUpdateResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationUpdateResponseJSON) RawJSON() string {
return r.raw
}
type OrganizationDeleteResponse = interface{}
type OrganizationJoinResponse struct {
// member is the member that was created by joining the organization.
Member OrganizationMember `json:"member,required"`
JSON organizationJoinResponseJSON `json:"-"`
}
// organizationJoinResponseJSON contains the JSON metadata for the struct
// [OrganizationJoinResponse]
type organizationJoinResponseJSON struct {
Member apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *OrganizationJoinResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r organizationJoinResponseJSON) RawJSON() string {
return r.raw
}
type OrganizationLeaveResponse = interface{}
type OrganizationSetRoleResponse = interface{}
type OrganizationNewParams struct {
// name is the organization name
Name param.Field[string] `json:"name,required"`
// Should other Accounts with the same domain be automatically invited to the
// organization?
InviteAccountsWithMatchingDomain param.Field[bool] `json:"inviteAccountsWithMatchingDomain"`
// join_organization decides whether the Identity issuing this request joins the
// org on creation
JoinOrganization param.Field[bool] `json:"joinOrganization"`
}
func (r OrganizationNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationGetParams struct {
// organization_id is the unique identifier of the Organization to retreive.
OrganizationID param.Field[string] `json:"organizationId,required" format:"uuid"`
}
func (r OrganizationGetParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationUpdateParams struct {
// organization_id is the ID of the organization to update the settings for.
OrganizationID param.Field[string] `json:"organizationId,required" format:"uuid"`
// invite_domains is the domain allowlist of the organization
InviteDomains param.Field[InviteDomainsParam] `json:"inviteDomains"`
// name is the new name of the organization
Name param.Field[string] `json:"name"`
}
func (r OrganizationUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationListParams struct {
Token param.Field[string] `query:"token"`
PageSize param.Field[int64] `query:"pageSize"`
// pagination contains the pagination options for listing organizations
Pagination param.Field[OrganizationListParamsPagination] `json:"pagination"`
// scope is the scope of the organizations to list
Scope param.Field[Scope] `json:"scope"`
}
func (r OrganizationListParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// URLQuery serializes [OrganizationListParams]'s query parameters as `url.Values`.
func (r OrganizationListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// pagination contains the pagination options for listing organizations
type OrganizationListParamsPagination struct {
// Token for the next set of results that was returned as next_token of a
// PaginationResponse
Token param.Field[string] `json:"token"`
// Page size is the maximum number of results to retrieve per page. Defaults to 25.
// Maximum 100.
PageSize param.Field[int64] `json:"pageSize"`
}
func (r OrganizationListParamsPagination) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationDeleteParams struct {
// organization_id is the ID of the organization to delete
OrganizationID param.Field[string] `json:"organizationId,required" format:"uuid"`
}
func (r OrganizationDeleteParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationJoinParams struct {
// invite_id is the unique identifier of the invite to join the organization.
InviteID param.Field[string] `json:"inviteId" format:"uuid"`
// organization_id is the unique identifier of the Organization to join.
OrganizationID param.Field[string] `json:"organizationId" format:"uuid"`
}
func (r OrganizationJoinParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationLeaveParams struct {
UserID param.Field[string] `json:"userId,required" format:"uuid"`
}
func (r OrganizationLeaveParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type OrganizationListMembersParams struct {
// organization_id is the ID of the organization to list members for