-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdirectory_sync.go
More file actions
103 lines (90 loc) · 4.44 KB
/
directory_sync.go
File metadata and controls
103 lines (90 loc) · 4.44 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
// Code generated by oagen. DO NOT EDIT.
package workos
import (
"context"
"fmt"
"net/url"
)
// DirectorySyncService handles DirectorySync operations.
type DirectorySyncService struct {
client *Client
}
// DirectorySyncListParams contains the parameters for List.
type DirectorySyncListParams struct {
PaginationParams
// OrganizationID is filter Directories by their associated organization.
OrganizationID *string `url:"organization_id,omitempty" json:"-"`
// Search is searchable text to match against Directory names.
Search *string `url:"search,omitempty" json:"-"`
// Domain is filter Directories by their associated domain.
//
// Deprecated: this parameter is deprecated.
Domain *string `url:"domain,omitempty" json:"-"`
}
// List directories
// Get a list of all of your existing directories matching the criteria specified.
func (s *DirectorySyncService) List(ctx context.Context, params *DirectorySyncListParams, opts ...RequestOption) *Iterator[Directory] {
return newIterator[Directory](ctx, s.client, "GET", "/directories", params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// Get a Directory
// Get the details of an existing directory.
func (s *DirectorySyncService) Get(ctx context.Context, id string, opts ...RequestOption) (*Directory, error) {
var result Directory
_, err := s.client.request(ctx, "GET", fmt.Sprintf("/directories/%s", url.PathEscape(id)), nil, nil, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// Delete a Directory
// Permanently deletes an existing directory. It cannot be undone.
func (s *DirectorySyncService) Delete(ctx context.Context, id string, opts ...RequestOption) error {
_, err := s.client.request(ctx, "DELETE", fmt.Sprintf("/directories/%s", url.PathEscape(id)), nil, nil, nil, opts)
return err
}
// DirectorySyncListGroupsParams contains the parameters for ListGroups.
type DirectorySyncListGroupsParams struct {
PaginationParams
// Directory is unique identifier of the WorkOS Directory. This value can be obtained from the WorkOS dashboard or from the WorkOS API.
Directory *string `url:"directory,omitempty" json:"-"`
// User is unique identifier of the WorkOS Directory User. This value can be obtained from the WorkOS API.
User *string `url:"user,omitempty" json:"-"`
}
// ListGroups list Directory Groups
// Get a list of all of existing directory groups matching the criteria specified.
func (s *DirectorySyncService) ListGroups(ctx context.Context, params *DirectorySyncListGroupsParams, opts ...RequestOption) *Iterator[DirectoryGroup] {
return newIterator[DirectoryGroup](ctx, s.client, "GET", "/directory_groups", params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// GetGroup get a Directory Group
// Get the details of an existing Directory Group.
func (s *DirectorySyncService) GetGroup(ctx context.Context, id string, opts ...RequestOption) (*DirectoryGroup, error) {
var result DirectoryGroup
_, err := s.client.request(ctx, "GET", fmt.Sprintf("/directory_groups/%s", url.PathEscape(id)), nil, nil, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}
// DirectorySyncListUsersParams contains the parameters for ListUsers.
type DirectorySyncListUsersParams struct {
PaginationParams
// Directory is unique identifier of the WorkOS Directory. This value can be obtained from the WorkOS dashboard or from the WorkOS API.
Directory *string `url:"directory,omitempty" json:"-"`
// Group is unique identifier of the WorkOS Directory Group. This value can be obtained from the WorkOS API.
Group *string `url:"group,omitempty" json:"-"`
}
// ListUsers list Directory Users
// Get a list of all of existing Directory Users matching the criteria specified.
func (s *DirectorySyncService) ListUsers(ctx context.Context, params *DirectorySyncListUsersParams, opts ...RequestOption) *Iterator[DirectoryUserWithGroups] {
return newIterator[DirectoryUserWithGroups](ctx, s.client, "GET", "/directory_users", params, "after", "data", opts, map[string]string{"limit": "10", "order": "desc"})
}
// GetUser get a Directory User
// Get the details of an existing Directory User.
func (s *DirectorySyncService) GetUser(ctx context.Context, id string, opts ...RequestOption) (*DirectoryUserWithGroups, error) {
var result DirectoryUserWithGroups
_, err := s.client.request(ctx, "GET", fmt.Sprintf("/directory_users/%s", url.PathEscape(id)), nil, nil, &result, opts)
if err != nil {
return nil, err
}
return &result, nil
}