-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprofiles.ts
More file actions
180 lines (166 loc) · 5.46 KB
/
Copy pathprofiles.ts
File metadata and controls
180 lines (166 loc) · 5.46 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as BrowsersAPI from './browsers/browsers';
import { ProfilesOffsetPagination } from './browsers/browsers';
import { APIPromise } from '../core/api-promise';
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
/**
* Create, list, retrieve, and delete browser profiles.
*/
export class Profiles extends APIResource {
/**
* Create a browser profile that can be used to load state into future browser
* sessions.
*
* @example
* ```ts
* const profile = await client.profiles.create();
* ```
*/
create(body: ProfileCreateParams, options?: RequestOptions): APIPromise<BrowsersAPI.Profile> {
return this._client.post('/profiles', { body, ...options });
}
/**
* Retrieve details for a single profile by its ID or name.
*
* @example
* ```ts
* const profile = await client.profiles.retrieve(
* 'id_or_name',
* );
* ```
*/
retrieve(idOrName: string, options?: RequestOptions): APIPromise<BrowsersAPI.Profile> {
return this._client.get(path`/profiles/${idOrName}`, options);
}
/**
* Update a profile's name. Names must be unique within the logical project; during
* the default-project migration, unscoped profiles and profiles in the org default
* project are treated as the same project. Duplicate-name conflicts are checked
* before update but are best-effort because there is no backing unique index.
* Renaming a profile while a browser session references it by name may prevent
* that session's changes from saving; prefer renaming when the profile is not in
* use.
*
* @example
* ```ts
* const profile = await client.profiles.update('id_or_name', {
* name: 'my-renamed-profile',
* });
* ```
*/
update(
idOrName: string,
body: ProfileUpdateParams,
options?: RequestOptions,
): APIPromise<BrowsersAPI.Profile> {
return this._client.patch(path`/profiles/${idOrName}`, { body, ...options });
}
/**
* List profiles with optional filtering and pagination.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const profile of client.profiles.list()) {
* // ...
* }
* ```
*/
list(
query: ProfileListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<ProfilesOffsetPagination, BrowsersAPI.Profile> {
return this._client.getAPIList('/profiles', OffsetPagination<BrowsersAPI.Profile>, { query, ...options });
}
/**
* Delete a profile by its ID or by its name.
*
* @example
* ```ts
* await client.profiles.delete('id_or_name');
* ```
*/
delete(idOrName: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/profiles/${idOrName}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Downloads the profile in its stored format by default. Current profiles are
* returned as zstd-compressed tar archives, while legacy profiles remain JSON. Set
* `format=tar` to decompress current profiles during download; legacy profiles
* remain JSON.
*
* @example
* ```ts
* const response = await client.profiles.download(
* 'id_or_name',
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
download(
idOrName: string,
query: ProfileDownloadParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<Response> {
return this._client.get(path`/profiles/${idOrName}/download`, {
query,
...options,
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
__binaryResponse: true,
});
}
}
export interface ProfileCreateParams {
/**
* Optional name of the profile. Must be unique within the logical project; during
* the default-project migration, unscoped profiles and profiles in the org default
* project are treated as the same project.
*/
name?: string;
}
export interface ProfileUpdateParams {
/**
* New profile name. Must be unique within the logical project; during the
* default-project migration, unscoped profiles and profiles in the org default
* project are treated as the same project.
*/
name: string;
}
export interface ProfileListParams extends OffsetPaginationParams {
/**
* Exact-match filter on profile name using the database collation. In production,
* matching is case- and accent-insensitive. During the default-project migration,
* unscoped requests prefer a concrete default-project profile over a legacy
* unscoped profile with the same name.
*/
name?: string;
/**
* Case-insensitive substring match against profile name or ID.
*/
query?: string;
}
export interface ProfileDownloadParams {
/**
* Response format for current profile archives. Legacy profiles are always
* returned as JSON.
*/
format?: 'tar.zst' | 'tar';
}
export declare namespace Profiles {
export {
type ProfileCreateParams as ProfileCreateParams,
type ProfileUpdateParams as ProfileUpdateParams,
type ProfileListParams as ProfileListParams,
type ProfileDownloadParams as ProfileDownloadParams,
};
}
export { type ProfilesOffsetPagination };