-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpolicies.ts
229 lines (204 loc) · 5.45 KB
/
policies.ts
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { APIPromise } from '../../api-promise';
import { PagePromise, PoliciesPage, type PoliciesPageParams } from '../../pagination';
import { RequestOptions } from '../../internal/request-options';
export class Policies extends APIResource {
/**
* Creates a new policy for a project.
*
* Use this method to:
*
* - Set up access controls
* - Define group permissions
* - Configure role-based access
*
* ### Examples
*
* - Create admin policy:
*
* Grants admin access to a group.
*
* ```yaml
* projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
* groupId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
* role: PROJECT_ROLE_ADMIN
* ```
*/
create(body: PolicyCreateParams, options?: RequestOptions): APIPromise<PolicyCreateResponse> {
return this._client.post('/gitpod.v1.ProjectService/CreateProjectPolicy', { body, ...options });
}
/**
* Updates an existing project policy.
*
* Use this method to:
*
* - Modify access levels
* - Change group roles
* - Update permissions
*
* ### Examples
*
* - Update policy role:
*
* Changes a group's access level.
*
* ```yaml
* projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
* groupId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
* role: PROJECT_ROLE_EDITOR
* ```
*/
update(body: PolicyUpdateParams, options?: RequestOptions): APIPromise<PolicyUpdateResponse> {
return this._client.post('/gitpod.v1.ProjectService/UpdateProjectPolicy', { body, ...options });
}
/**
* Lists policies for a project.
*
* Use this method to:
*
* - View access controls
* - Check policy configurations
* - Audit permissions
*
* ### Examples
*
* - List policies:
*
* Shows all policies for a project.
*
* ```yaml
* projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
* pagination:
* pageSize: 20
* ```
*/
list(
params: PolicyListParams,
options?: RequestOptions,
): PagePromise<ProjectPoliciesPoliciesPage, ProjectPolicy> {
const { token, pageSize, ...body } = params;
return this._client.getAPIList(
'/gitpod.v1.ProjectService/ListProjectPolicies',
PoliciesPage<ProjectPolicy>,
{ query: { token, pageSize }, body, method: 'post', ...options },
);
}
/**
* Deletes a project policy.
*
* Use this method to:
*
* - Remove access controls
* - Revoke permissions
* - Clean up policies
*
* ### Examples
*
* - Delete policy:
*
* Removes a group's access policy.
*
* ```yaml
* projectId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
* groupId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
* ```
*/
delete(body: PolicyDeleteParams, options?: RequestOptions): APIPromise<unknown> {
return this._client.post('/gitpod.v1.ProjectService/DeleteProjectPolicy', { body, ...options });
}
}
export type ProjectPoliciesPoliciesPage = PoliciesPage<ProjectPolicy>;
export interface ProjectPolicy {
groupId?: string;
/**
* role is the role assigned to the group
*/
role?: ProjectRole;
}
export type ProjectRole =
| 'PROJECT_ROLE_UNSPECIFIED'
| 'PROJECT_ROLE_ADMIN'
| 'PROJECT_ROLE_USER'
| 'PROJECT_ROLE_EDITOR';
export interface PolicyCreateResponse {
policy?: ProjectPolicy;
}
export interface PolicyUpdateResponse {
policy?: ProjectPolicy;
}
export type PolicyDeleteResponse = unknown;
export interface PolicyCreateParams {
/**
* group_id specifies the group_id identifier
*/
groupId?: string;
/**
* project_id specifies the project identifier
*/
projectId?: string;
role?: ProjectRole;
}
export interface PolicyUpdateParams {
/**
* group_id specifies the group_id identifier
*/
groupId?: string;
/**
* project_id specifies the project identifier
*/
projectId?: string;
role?: ProjectRole;
}
export interface PolicyListParams extends PoliciesPageParams {
/**
* Body param: pagination contains the pagination options for listing project
* policies
*/
pagination?: PolicyListParams.Pagination;
/**
* Body param: project_id specifies the project identifier
*/
projectId?: string;
}
export namespace PolicyListParams {
/**
* pagination contains the pagination options for listing project policies
*/
export interface Pagination {
/**
* Token for the next set of results that was returned as next_token of a
* PaginationResponse
*/
token?: string;
/**
* Page size is the maximum number of results to retrieve per page. Defaults to 25.
* Maximum 100.
*/
pageSize?: number;
}
}
export interface PolicyDeleteParams {
/**
* group_id specifies the group_id identifier
*/
groupId?: string;
/**
* project_id specifies the project identifier
*/
projectId?: string;
}
export declare namespace Policies {
export {
type ProjectPolicy as ProjectPolicy,
type ProjectRole as ProjectRole,
type PolicyCreateResponse as PolicyCreateResponse,
type PolicyUpdateResponse as PolicyUpdateResponse,
type PolicyDeleteResponse as PolicyDeleteResponse,
type ProjectPoliciesPoliciesPage as ProjectPoliciesPoliciesPage,
type PolicyCreateParams as PolicyCreateParams,
type PolicyUpdateParams as PolicyUpdateParams,
type PolicyListParams as PolicyListParams,
type PolicyDeleteParams as PolicyDeleteParams,
};
}