-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathgroups.go
More file actions
116 lines (100 loc) · 5.53 KB
/
groups.go
File metadata and controls
116 lines (100 loc) · 5.53 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
// Code generated by oagen. DO NOT EDIT.
package workos
import (
"context"
"fmt"
"net/url"
)
// GroupService handles Groups operations.
type GroupService struct {
client *Client
}
// GroupsListOrganizationGroupsParams contains the parameters for ListOrganizationGroups.
type GroupsListOrganizationGroupsParams struct {
PaginationParams
}
// ListOrganizationGroups list groups
// Get a paginated list of groups within an organization.
func (s *GroupService) ListOrganizationGroups(ctx context.Context, organizationID string, params *GroupsListOrganizationGroupsParams, opts ...RequestOption) *Iterator[Group] {
return newIterator[Group](ctx, s.client, "GET", fmt.Sprintf("/organizations/%s/groups", url.PathEscape(organizationID)), params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// GroupsCreateOrganizationGroupParams contains the parameters for CreateOrganizationGroup.
type GroupsCreateOrganizationGroupParams struct {
// Name is the name of the Group.
Name string `json:"name" url:"-"`
// Description is an optional description of the Group.
Description *string `json:"description,omitempty" url:"-"`
}
// CreateOrganizationGroup create a group
// Create a new group within an organization.
func (s *GroupService) CreateOrganizationGroup(ctx context.Context, organizationID string, params *GroupsCreateOrganizationGroupParams, opts ...RequestOption) (*Group, error) {
var result Group
_, err := s.client.request(ctx, "POST", fmt.Sprintf("/organizations/%s/groups", url.PathEscape(organizationID)), nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// GetOrganizationGroup get a group
// Retrieve a group by its ID within an organization.
func (s *GroupService) GetOrganizationGroup(ctx context.Context, organizationID string, groupID string, opts ...RequestOption) (*Group, error) {
var result Group
_, err := s.client.request(ctx, "GET", fmt.Sprintf("/organizations/%s/groups/%s", url.PathEscape(organizationID), url.PathEscape(groupID)), nil, nil, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// GroupsUpdateOrganizationGroupParams contains the parameters for UpdateOrganizationGroup.
type GroupsUpdateOrganizationGroupParams struct {
// Name is the name of the Group.
Name *string `json:"name,omitempty" url:"-"`
// Description is an optional description of the Group.
Description *string `json:"description,omitempty" url:"-"`
}
// UpdateOrganizationGroup update a group
// Update an existing group. Only the fields provided in the request body will be updated.
func (s *GroupService) UpdateOrganizationGroup(ctx context.Context, organizationID string, groupID string, params *GroupsUpdateOrganizationGroupParams, opts ...RequestOption) (*Group, error) {
var result Group
_, err := s.client.request(ctx, "PATCH", fmt.Sprintf("/organizations/%s/groups/%s", url.PathEscape(organizationID), url.PathEscape(groupID)), nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// DeleteOrganizationGroup delete a group
// Delete a group from an organization.
func (s *GroupService) DeleteOrganizationGroup(ctx context.Context, organizationID string, groupID string, opts ...RequestOption) error {
_, err := s.client.request(ctx, "DELETE", fmt.Sprintf("/organizations/%s/groups/%s", url.PathEscape(organizationID), url.PathEscape(groupID)), nil, nil, nil, opts)
return err
}
// GroupsListOrganizationMembershipsParams contains the parameters for ListOrganizationMemberships.
type GroupsListOrganizationMembershipsParams struct {
PaginationParams
}
// ListOrganizationMemberships list Group members
// Get a list of organization memberships in a group.
func (s *GroupService) ListOrganizationMemberships(ctx context.Context, organizationID string, groupID string, params *GroupsListOrganizationMembershipsParams, opts ...RequestOption) *Iterator[UserOrganizationMembershipBaseListData] {
return newIterator[UserOrganizationMembershipBaseListData](ctx, s.client, "GET", fmt.Sprintf("/organizations/%s/groups/%s/organization-memberships", url.PathEscape(organizationID), url.PathEscape(groupID)), params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// GroupsCreateOrganizationMembershipParams contains the parameters for CreateOrganizationMembership.
type GroupsCreateOrganizationMembershipParams struct {
// OrganizationMembershipID is the ID of the Organization Membership to add to the group.
OrganizationMembershipID string `json:"organization_membership_id" url:"-"`
}
// CreateOrganizationMembership add a member to a Group
// Add an organization membership to a group.
func (s *GroupService) CreateOrganizationMembership(ctx context.Context, organizationID string, groupID string, params *GroupsCreateOrganizationMembershipParams, opts ...RequestOption) (*Group, error) {
var result Group
_, err := s.client.request(ctx, "POST", fmt.Sprintf("/organizations/%s/groups/%s/organization-memberships", url.PathEscape(organizationID), url.PathEscape(groupID)), nil, params, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// DeleteOrganizationMembership remove a member from a Group
// Remove an organization membership from a group.
func (s *GroupService) DeleteOrganizationMembership(ctx context.Context, organizationID string, groupID string, omID string, opts ...RequestOption) error {
_, err := s.client.request(ctx, "DELETE", fmt.Sprintf("/organizations/%s/groups/%s/organization-memberships/%s", url.PathEscape(organizationID), url.PathEscape(groupID), url.PathEscape(omID)), nil, nil, nil, opts)
return err
}