-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathusers.ts
More file actions
291 lines (244 loc) · 6.28 KB
/
Copy pathusers.ts
File metadata and controls
291 lines (244 loc) · 6.28 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
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
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details.
import { APIResource } from '../../../../core/resource';
import * as RolesAPI from './roles';
import {
RoleCreateParams,
RoleCreateResponse,
RoleDeleteParams,
RoleDeleteResponse,
RoleListParams,
RoleListResponse,
RoleListResponsesPage,
RoleRetrieveParams,
RoleRetrieveResponse,
Roles,
} from './roles';
import { APIPromise } from '../../../../core/api-promise';
import {
ConversationCursorPage,
type ConversationCursorPageParams,
PagePromise,
} from '../../../../core/pagination';
import { RequestOptions } from '../../../../internal/request-options';
import { path } from '../../../../internal/utils/path';
export class Users extends APIResource {
roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
/**
* Retrieves a user by their identifier.
*
* @example
* ```ts
* const organizationUser =
* await client.admin.organization.users.retrieve('user_id');
* ```
*/
retrieve(userID: string, options?: RequestOptions): APIPromise<OrganizationUser> {
return this._client.get(path`/organization/users/${userID}`, {
...options,
__security: { adminAPIKeyAuth: true },
});
}
/**
* Modifies a user's role in the organization.
*
* @example
* ```ts
* const organizationUser =
* await client.admin.organization.users.update('user_id');
* ```
*/
update(userID: string, body: UserUpdateParams, options?: RequestOptions): APIPromise<OrganizationUser> {
return this._client.post(path`/organization/users/${userID}`, {
body,
...options,
__security: { adminAPIKeyAuth: true },
});
}
/**
* Lists all of the users in the organization.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const organizationUser of client.admin.organization.users.list()) {
* // ...
* }
* ```
*/
list(
query: UserListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<OrganizationUsersPage, OrganizationUser> {
return this._client.getAPIList('/organization/users', ConversationCursorPage<OrganizationUser>, {
query,
...options,
__security: { adminAPIKeyAuth: true },
});
}
/**
* Deletes a user from the organization.
*
* @example
* ```ts
* const user = await client.admin.organization.users.delete(
* 'user_id',
* );
* ```
*/
delete(userID: string, options?: RequestOptions): APIPromise<UserDeleteResponse> {
return this._client.delete(path`/organization/users/${userID}`, {
...options,
__security: { adminAPIKeyAuth: true },
});
}
}
export type OrganizationUsersPage = ConversationCursorPage<OrganizationUser>;
/**
* Represents an individual `user` within an organization.
*/
export interface OrganizationUser {
/**
* The identifier, which can be referenced in API endpoints
*/
id: string;
/**
* The Unix timestamp (in seconds) of when the user was added.
*/
added_at: number;
/**
* The object type, which is always `organization.user`
*/
object: 'organization.user';
/**
* The Unix timestamp (in seconds) of the user's last API key usage.
*/
api_key_last_used_at?: number | null;
/**
* The Unix timestamp (in seconds) of when the user was created.
*/
created?: number;
/**
* The developer persona metadata for the user.
*/
developer_persona?: string | null;
/**
* The email address of the user
*/
email?: string | null;
/**
* Whether this is the organization's default user.
*/
is_default?: boolean;
/**
* Whether the user is an authorized purchaser for Scale Tier.
*/
is_scale_tier_authorized_purchaser?: boolean | null;
/**
* Whether the user is managed through SCIM.
*/
is_scim_managed?: boolean;
/**
* Whether the user is a service account.
*/
is_service_account?: boolean;
/**
* The name of the user
*/
name?: string | null;
/**
* Projects associated with the user, if included.
*/
projects?: OrganizationUser.Projects | null;
/**
* `owner` or `reader`
*/
role?: string | null;
/**
* The technical level metadata for the user.
*/
technical_level?: string | null;
/**
* Nested user details.
*/
user?: OrganizationUser.User;
}
export namespace OrganizationUser {
/**
* Projects associated with the user, if included.
*/
export interface Projects {
data: Array<Projects.Data>;
object: 'list';
}
export namespace Projects {
export interface Data {
id?: string | null;
name?: string | null;
role?: string | null;
}
}
/**
* Nested user details.
*/
export interface User {
id: string;
object: 'user';
banned?: boolean | null;
banned_at?: number | null;
email?: string | null;
enabled?: boolean | null;
name?: string | null;
picture?: string | null;
}
}
export interface UserDeleteResponse {
id: string;
deleted: boolean;
object: 'organization.user.deleted';
}
export interface UserUpdateParams {
/**
* Developer persona metadata.
*/
developer_persona?: string | null;
/**
* `owner` or `reader`
*/
role?: string | null;
/**
* Role ID to assign to the user.
*/
role_id?: string | null;
/**
* Technical level metadata.
*/
technical_level?: string | null;
}
export interface UserListParams extends ConversationCursorPageParams {
/**
* Filter by the email address of users.
*/
emails?: Array<string>;
}
Users.Roles = Roles;
export declare namespace Users {
export {
type OrganizationUser as OrganizationUser,
type UserDeleteResponse as UserDeleteResponse,
type OrganizationUsersPage as OrganizationUsersPage,
type UserUpdateParams as UserUpdateParams,
type UserListParams as UserListParams,
};
export {
Roles as Roles,
type RoleCreateResponse as RoleCreateResponse,
type RoleRetrieveResponse as RoleRetrieveResponse,
type RoleListResponse as RoleListResponse,
type RoleDeleteResponse as RoleDeleteResponse,
type RoleListResponsesPage as RoleListResponsesPage,
type RoleCreateParams as RoleCreateParams,
type RoleRetrieveParams as RoleRetrieveParams,
type RoleListParams as RoleListParams,
type RoleDeleteParams as RoleDeleteParams,
};
}