forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterSharing.ts
255 lines (240 loc) · 10.2 KB
/
filterSharing.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
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
import * as Models from './models';
import * as Parameters from './parameters';
import { Callback } from '../callback';
import { Client } from '../clients';
import { RequestConfig } from '../requestConfig';
export class FilterSharing {
constructor(private client: Client) {}
/**
* Returns the default sharing settings for new filters and dashboards for a user.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira.
*/
async getDefaultShareScope<T = Models.DefaultShareScope>(callback: Callback<T>): Promise<void>;
/**
* Returns the default sharing settings for new filters and dashboards for a user.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira.
*/
async getDefaultShareScope<T = Models.DefaultShareScope>(callback?: never): Promise<T>;
async getDefaultShareScope<T = Models.DefaultShareScope>(callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/2/filter/defaultShareScope',
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Sets the default sharing for new filters and dashboards for a user.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira.
*/
async setDefaultShareScope<T = Models.DefaultShareScope>(
parameters: Parameters.SetDefaultShareScope | string,
callback: Callback<T>,
): Promise<void>;
/**
* Sets the default sharing for new filters and dashboards for a user.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira.
*/
async setDefaultShareScope<T = Models.DefaultShareScope>(
parameters: Parameters.SetDefaultShareScope | string,
callback?: never,
): Promise<T>;
async setDefaultShareScope<T = Models.DefaultShareScope>(
parameters: Parameters.SetDefaultShareScope | string,
callback?: Callback<T>,
): Promise<void | T> {
const scope = typeof parameters === 'string' ? parameters : parameters.scope;
const config: RequestConfig = {
url: '/rest/api/2/filter/defaultShareScope',
method: 'PUT',
data: {
scope,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns the share permissions for a filter. A filter can be shared with groups, projects, all logged-in users, or
* the public. Sharing with all logged-in users or the public is known as a global share permission.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None,
* however, share permissions are only returned for:
*
* - Filters owned by the user.
* - Filters shared with a group that the user is a member of.
* - Filters shared with a private project that the user has _Browse projects_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for.
* - Filters shared with a public project.
* - Filters shared with the public.
*/
async getSharePermissions<T = Models.SharePermission[]>(
parameters: Parameters.GetSharePermissions | string,
callback: Callback<T>,
): Promise<void>;
/**
* Returns the share permissions for a filter. A filter can be shared with groups, projects, all logged-in users, or
* the public. Sharing with all logged-in users or the public is known as a global share permission.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None,
* however, share permissions are only returned for:
*
* - Filters owned by the user.
* - Filters shared with a group that the user is a member of.
* - Filters shared with a private project that the user has _Browse projects_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for.
* - Filters shared with a public project.
* - Filters shared with the public.
*/
async getSharePermissions<T = Models.SharePermission[]>(
parameters: Parameters.GetSharePermissions | string,
callback?: never,
): Promise<T>;
async getSharePermissions<T = Models.SharePermission[]>(
parameters: Parameters.GetSharePermissions | string,
callback?: Callback<T>,
): Promise<void | T> {
const id = typeof parameters === 'string' ? parameters : parameters.id;
const config: RequestConfig = {
url: `/rest/api/2/filter/${id}/permission`,
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Add a share permissions to a filter. If you add a global share permission (one for all logged-in users or the
* public) it will overwrite all share permissions for the filter.
*
* Be aware that this operation uses different objects for updating share permissions compared to [Update
* filter](#api-rest-api-2-filter-id-put).
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Share
* dashboards and filters_ [global permission](https://confluence.atlassian.com/x/x4dKLg) and the user must own the
* filter.
*/
async addSharePermission<T = Models.SharePermission[]>(
parameters: Parameters.AddSharePermission,
callback: Callback<T>,
): Promise<void>;
/**
* Add a share permissions to a filter. If you add a global share permission (one for all logged-in users or the
* public) it will overwrite all share permissions for the filter.
*
* Be aware that this operation uses different objects for updating share permissions compared to [Update
* filter](#api-rest-api-2-filter-id-put).
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** _Share
* dashboards and filters_ [global permission](https://confluence.atlassian.com/x/x4dKLg) and the user must own the
* filter.
*/
async addSharePermission<T = Models.SharePermission[]>(
parameters: Parameters.AddSharePermission,
callback?: never,
): Promise<T>;
async addSharePermission<T = Models.SharePermission[]>(
parameters: Parameters.AddSharePermission,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/2/filter/${parameters.id}/permission`,
method: 'POST',
data: {
type: parameters.type,
projectId: parameters.projectId,
groupname: parameters.groupname,
projectRoleId: parameters.projectRoleId,
accountId: parameters.accountId,
rights: parameters.rights,
groupId: parameters.groupId,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns a share permission for a filter. A filter can be shared with groups, projects, all logged-in users, or the
* public. Sharing with all logged-in users or the public is known as a global share permission.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None,
* however, a share permission is only returned for:
*
* - Filters owned by the user.
* - Filters shared with a group that the user is a member of.
* - Filters shared with a private project that the user has _Browse projects_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for.
* - Filters shared with a public project.
* - Filters shared with the public.
*/
async getSharePermission<T = Models.SharePermission>(
parameters: Parameters.GetSharePermission,
callback: Callback<T>,
): Promise<void>;
/**
* Returns a share permission for a filter. A filter can be shared with groups, projects, all logged-in users, or the
* public. Sharing with all logged-in users or the public is known as a global share permission.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:** None,
* however, a share permission is only returned for:
*
* - Filters owned by the user.
* - Filters shared with a group that the user is a member of.
* - Filters shared with a private project that the user has _Browse projects_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for.
* - Filters shared with a public project.
* - Filters shared with the public.
*/
async getSharePermission<T = Models.SharePermission>(
parameters: Parameters.GetSharePermission,
callback?: never,
): Promise<T>;
async getSharePermission<T = Models.SharePermission>(
parameters: Parameters.GetSharePermission,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/2/filter/${parameters.id}/permission/${parameters.permissionId}`,
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Deletes a share permission from a filter.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira and the user must own the filter.
*/
async deleteSharePermission<T = void>(
parameters: Parameters.DeleteSharePermission,
callback: Callback<T>,
): Promise<void>;
/**
* Deletes a share permission from a filter.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#permissions) required:**
* Permission to access Jira and the user must own the filter.
*/
async deleteSharePermission<T = void>(parameters: Parameters.DeleteSharePermission, callback?: never): Promise<T>;
async deleteSharePermission<T = void>(
parameters: Parameters.DeleteSharePermission,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/2/filter/${parameters.id}/permission/${parameters.permissionId}`,
method: 'DELETE',
};
return this.client.sendRequest(config, callback);
}
}