-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.ts
More file actions
183 lines (141 loc) · 4.23 KB
/
users.ts
File metadata and controls
183 lines (141 loc) · 4.23 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as DocsAPI from './docs';
import {
DocBulkDeleteParams,
DocBulkDeleteResponse,
DocCreateParams,
DocDeleteResponse,
DocListParams,
DocSearchParams,
DocSearchResponse,
Docs,
} from './docs';
import { OffsetPagination, type OffsetPaginationParams } from '../../pagination';
export class Users extends APIResource {
docs: DocsAPI.Docs = new DocsAPI.Docs(this._client);
/**
* Create User
*/
create(body: UserCreateParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.post('/users', { body, ...options });
}
/**
* Patch User
*/
update(userId: string, body: UserUpdateParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.patch(`/users/${userId}`, { body, ...options });
}
/**
* List Users
*/
list(query?: UserListParams, options?: Core.RequestOptions): Core.PagePromise<UsersOffsetPagination, User>;
list(options?: Core.RequestOptions): Core.PagePromise<UsersOffsetPagination, User>;
list(
query: UserListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<UsersOffsetPagination, User> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/users', UsersOffsetPagination, { query, ...options });
}
/**
* Delete User
*/
delete(userId: string, options?: Core.RequestOptions): Core.APIPromise<UserDeleteResponse> {
return this._client.delete(`/users/${userId}`, options);
}
/**
* Create Or Update User
*/
createOrUpdate(
userId: string,
body: UserCreateOrUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<User> {
return this._client.post(`/users/${userId}`, { body, ...options });
}
/**
* Get User Details
*/
get(userId: string, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.get(`/users/${userId}`, options);
}
/**
* Update User
*/
reset(userId: string, body: UserResetParams, options?: Core.RequestOptions): Core.APIPromise<User> {
return this._client.put(`/users/${userId}`, { body, ...options });
}
}
export class UsersOffsetPagination extends OffsetPagination<User> {}
export interface User {
id: string;
created_at: string;
updated_at: string;
about?: string;
metadata?: unknown | null;
name?: string;
project?: string | null;
}
export interface UserDeleteResponse {
id: string;
deleted_at: string;
jobs?: Array<string>;
}
export interface UserCreateParams {
about?: string;
metadata?: unknown | null;
name?: string;
project?: string | null;
}
export interface UserUpdateParams {
about?: string;
metadata?: unknown | null;
name?: string;
project?: string | null;
}
export interface UserListParams extends OffsetPaginationParams {
direction?: 'asc' | 'desc';
metadata_filter?: { [key: string]: unknown };
sort_by?: 'created_at' | 'updated_at';
}
export interface UserCreateOrUpdateParams {
about?: string;
metadata?: unknown | null;
name?: string;
project?: string | null;
}
export interface UserResetParams {
about?: string;
metadata?: unknown | null;
name?: string;
project?: string | null;
}
Users.UsersOffsetPagination = UsersOffsetPagination;
Users.Docs = Docs;
export declare namespace Users {
export {
type User as User,
type UserDeleteResponse as UserDeleteResponse,
UsersOffsetPagination as UsersOffsetPagination,
type UserCreateParams as UserCreateParams,
type UserUpdateParams as UserUpdateParams,
type UserListParams as UserListParams,
type UserCreateOrUpdateParams as UserCreateOrUpdateParams,
type UserResetParams as UserResetParams,
};
export {
Docs as Docs,
type DocDeleteResponse as DocDeleteResponse,
type DocBulkDeleteResponse as DocBulkDeleteResponse,
type DocSearchResponse as DocSearchResponse,
type DocCreateParams as DocCreateParams,
type DocListParams as DocListParams,
type DocBulkDeleteParams as DocBulkDeleteParams,
type DocSearchParams as DocSearchParams,
};
}