forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissueWatchers.ts
211 lines (202 loc) · 10.1 KB
/
issueWatchers.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
import * as Models from './models';
import * as Parameters from './parameters';
import { Callback } from '../callback';
import { Client } from '../clients';
import { RequestConfig } from '../requestConfig';
export class IssueWatchers {
constructor(private client: Client) {}
/**
* Returns, for the user, details of the watched status of issues from a list. If an issue ID is invalid, the returned
* watched status is `false`.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
*/
async getIsWatchingIssueBulk<T = Models.BulkIssueIsWatching>(
parameters: Parameters.GetIsWatchingIssueBulk | undefined,
callback: Callback<T>,
): Promise<void>;
/**
* Returns, for the user, details of the watched status of issues from a list. If an issue ID is invalid, the returned
* watched status is `false`.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
*/
async getIsWatchingIssueBulk<T = Models.BulkIssueIsWatching>(
parameters?: Parameters.GetIsWatchingIssueBulk,
callback?: never,
): Promise<T>;
async getIsWatchingIssueBulk<T = Models.BulkIssueIsWatching>(
parameters?: Parameters.GetIsWatchingIssueBulk,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/api/3/issue/watching',
method: 'POST',
data: {
issueIds: parameters?.issueIds,
},
};
return this.client.sendRequest(config, callback);
}
/**
* Returns the watchers for an issue.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* ini
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To see details of users on the watchlist other than themselves, _View voters and watchers_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async getIssueWatchers<T = Models.Watchers>(
parameters: Parameters.GetIssueWatchers,
callback: Callback<T>,
): Promise<void>;
/**
* Returns the watchers for an issue.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* This operation can be accessed anonymously.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* ini
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To see details of users on the watchlist other than themselves, _View voters and watchers_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async getIssueWatchers<T = Models.Watchers>(parameters: Parameters.GetIssueWatchers, callback?: never): Promise<T>;
async getIssueWatchers<T = Models.Watchers>(
parameters: Parameters.GetIssueWatchers,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/3/issue/${parameters.issueIdOrKey}/watchers`,
method: 'GET',
};
return this.client.sendRequest(config, callback);
}
/**
* Adds a user as a watcher of an issue by passing the account ID of the user. For example,
* `"5b10ac8d82e05b22cc7d4ef5"`. If no user is specified the calling user is added.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in.
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To add users other than themselves to the watchlist, _Manage watcher list_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async addWatcher<T = void>(parameters: Parameters.AddWatcher, callback: Callback<T>): Promise<void>;
/**
* Adds a user as a watcher of an issue by passing the account ID of the user. For example,
* `"5b10ac8d82e05b22cc7d4ef5"`. If no user is specified the calling user is added.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in.
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To add users other than themselves to the watchlist, _Manage watcher list_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async addWatcher<T = void>(parameters: Parameters.AddWatcher, callback?: never): Promise<T>;
async addWatcher<T = void>(parameters: Parameters.AddWatcher, callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/3/issue/${parameters.issueIdOrKey}/watchers`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: parameters.accountId,
};
return this.client.sendRequest(config, callback);
}
/**
* Deletes a user as a watcher of an issue.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in.
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To remove users other than themselves from the watchlist, _Manage watcher list_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async removeWatcher<T = void>(parameters: Parameters.RemoveWatcher, callback: Callback<T>): Promise<void>;
/**
* Deletes a user as a watcher of an issue.
*
* This operation requires the **Allow users to watch issues** option to be _ON_. This option is set in General
* configuration for Jira. See [Configuring Jira application options](https://confluence.atlassian.com/x/uYXKM) for
* details.
*
* **[Permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#permissions) required:**
*
* - _Browse projects_ [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is
* in.
* - If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission
* to view the issue.
* - To remove users other than themselves from the watchlist, _Manage watcher list_ [project
* permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
*/
async removeWatcher<T = void>(parameters: Parameters.RemoveWatcher, callback?: never): Promise<T>;
async removeWatcher<T = void>(parameters: Parameters.RemoveWatcher, callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/api/3/issue/${parameters.issueIdOrKey}/watchers`,
method: 'DELETE',
params: {
username: parameters.username,
accountId: parameters.accountId,
},
};
return this.client.sendRequest(config, callback);
}
}