-
Notifications
You must be signed in to change notification settings - Fork 0
/
organizationmember.go
executable file
·96 lines (84 loc) · 3.92 KB
/
organizationmember.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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package braintrust
import (
"context"
"net/http"
"github.com/braintrustdata/braintrust-go/internal/apijson"
"github.com/braintrustdata/braintrust-go/internal/param"
"github.com/braintrustdata/braintrust-go/internal/requestconfig"
"github.com/braintrustdata/braintrust-go/option"
"github.com/braintrustdata/braintrust-go/shared"
)
// OrganizationMemberService contains methods and other services that help with
// interacting with the braintrust 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 [NewOrganizationMemberService] method instead.
type OrganizationMemberService struct {
Options []option.RequestOption
}
// NewOrganizationMemberService 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 NewOrganizationMemberService(opts ...option.RequestOption) (r *OrganizationMemberService) {
r = &OrganizationMemberService{}
r.Options = opts
return
}
// Modify organization membership
func (r *OrganizationMemberService) Update(ctx context.Context, body OrganizationMemberUpdateParams, opts ...option.RequestOption) (res *shared.PatchOrganizationMembersOutput, err error) {
opts = append(r.Options[:], opts...)
path := "v1/organization/members"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
type OrganizationMemberUpdateParams struct {
// Users to invite to the organization
InviteUsers param.Field[OrganizationMemberUpdateParamsInviteUsers] `json:"invite_users"`
// For nearly all users, this parameter should be unnecessary. But in the rare case
// that your API key belongs to multiple organizations, or in case you want to
// explicitly assert the organization you are modifying, you may specify the id of
// the organization.
OrgID param.Field[string] `json:"org_id"`
// For nearly all users, this parameter should be unnecessary. But in the rare case
// that your API key belongs to multiple organizations, or in case you want to
// explicitly assert the organization you are modifying, you may specify the name
// of the organization.
OrgName param.Field[string] `json:"org_name"`
// Users to remove from the organization
RemoveUsers param.Field[OrganizationMemberUpdateParamsRemoveUsers] `json:"remove_users"`
}
func (r OrganizationMemberUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Users to invite to the organization
type OrganizationMemberUpdateParamsInviteUsers struct {
// Emails of users to invite
Emails param.Field[[]string] `json:"emails"`
// Singular form of group_ids
GroupID param.Field[string] `json:"group_id" format:"uuid"`
// Optional list of group ids to add newly-invited users to.
GroupIDs param.Field[[]string] `json:"group_ids" format:"uuid"`
// Singular form of group_names
GroupName param.Field[string] `json:"group_name"`
// Optional list of group names to add newly-invited users to.
GroupNames param.Field[[]string] `json:"group_names"`
// Ids of existing users to invite
IDs param.Field[[]string] `json:"ids" format:"uuid"`
// If true, send invite emails to the users who wore actually added
SendInviteEmails param.Field[bool] `json:"send_invite_emails"`
}
func (r OrganizationMemberUpdateParamsInviteUsers) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Users to remove from the organization
type OrganizationMemberUpdateParamsRemoveUsers struct {
// Emails of users to remove
Emails param.Field[[]string] `json:"emails"`
// Ids of users to remove
IDs param.Field[[]string] `json:"ids" format:"uuid"`
}
func (r OrganizationMemberUpdateParamsRemoveUsers) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}