forked from ctreminiom/go-atlassian
/
project.go
445 lines (381 loc) · 18.9 KB
/
project.go
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
package jira
import (
"context"
model "github.com/ctreminiom/go-atlassian/pkg/infra/models"
)
type ProjectConnector interface {
// Create creates a project based on a project type template
//
// POST /rest/api/{2-3}/project
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#create-project
Create(ctx context.Context, payload *model.ProjectPayloadScheme) (*model.NewProjectCreatedScheme, *model.ResponseScheme, error)
// Search returns a paginated list of projects visible to the user.
//
// GET /rest/api/{2-3}/project/search
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#get-projects-paginated
Search(ctx context.Context, options *model.ProjectSearchOptionsScheme, startAt, maxResults int) (*model.ProjectSearchScheme, *model.ResponseScheme, error)
// Get returns the project details for a project.
//
// GET /rest/api/{2-3}project/{projectIdOrKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#get-project
Get(ctx context.Context, projectKeyOrId string, expand []string) (*model.ProjectScheme, *model.ResponseScheme, error)
// Update updates the project details of a project.
//
// PUT /rest/api/{2-3}/project/{projectIdOrKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#update-project
Update(ctx context.Context, projectKeyOrId string, payload *model.ProjectUpdateScheme) (*model.ProjectScheme, *model.ResponseScheme, error)
// Delete deletes a project.
//
// You can't delete a project if it's archived. To delete an archived project, restore the project and then delete it.
//
// To restore a project, use the Jira UI.
//
// DELETE /rest/api/{2-3}/project/{projectIdOrKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#delete-project
Delete(ctx context.Context, projectKeyOrId string, enableUndo bool) (*model.ResponseScheme, error)
// DeleteAsynchronously deletes a project asynchronously.
//
// 1. transactional, that is, if part of to delete fails the project is not deleted.
//
// 2. asynchronous. Follow the location link in the response to determine the status of the task and use Get task to obtain subsequent updates.
//
// POST /rest/api/{2-3}/project/{projectIdOrKey}/delete
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#delete-project-asynchronously
DeleteAsynchronously(ctx context.Context, projectKeyOrId string) (*model.TaskScheme, *model.ResponseScheme, error)
// Archive archives a project. Archived projects cannot be deleted.
//
// To delete an archived project, restore the project and then delete it.
//
// To restore a project, use the Jira UI.
//
// POST /rest/api/{2-3}/project/{projectIdOrKey}/archive
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#archive-project
Archive(ctx context.Context, projectKeyOrId string) (*model.ResponseScheme, error)
// Restore restores a project from the Jira recycle bin.
//
// POST /rest/api/3/project/{projectIdOrKey}/restore
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#restore-deleted-project
Restore(ctx context.Context, projectKeyOrId string) (*model.ProjectScheme, *model.ResponseScheme, error)
// Statuses returns the valid statuses for a project.
//
// The statuses are grouped by issue type, as each project has a set of valid issue types and each issue type has a set of valid statuses.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/statuses
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#get-all-statuses-for-project
Statuses(ctx context.Context, projectKeyOrId string) ([]*model.ProjectStatusPageScheme, *model.ResponseScheme, error)
// NotificationScheme gets the notification scheme associated with the project.
//
// GET /rest/api/{2-3}/project/{projectKeyOrId}/notificationscheme
//
// https://docs.go-atlassian.io/jira-software-cloud/projects#get-project-notification-scheme
NotificationScheme(ctx context.Context, projectKeyOrId string, expand []string) (*model.NotificationSchemeScheme, *model.ResponseScheme, error)
}
type ProjectCategoryConnector interface {
// Gets returns all project categories.
//
// GET /rest/api/{2-3}/projectCategory
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/categories#get-all-project-categories
Gets(ctx context.Context) ([]*model.ProjectCategoryScheme, *model.ResponseScheme, error)
// Get returns a project category.
//
// GET /rest/api/{2-3}/projectCategory/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/categories#get-project-category-by-id
Get(ctx context.Context, categoryId int) (*model.ProjectCategoryScheme, *model.ResponseScheme, error)
// Create creates a project category.
//
// POST /rest/api/{2-3}/projectCategory
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/categories#create-project-category
Create(ctx context.Context, payload *model.ProjectCategoryPayloadScheme) (*model.ProjectCategoryScheme, *model.ResponseScheme, error)
// Update updates a project category.
//
// PUT /rest/api/{2-3}/projectCategory/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/categories#update-project-category
Update(ctx context.Context, categoryId int, payload *model.ProjectCategoryPayloadScheme) (*model.ProjectCategoryScheme, *model.ResponseScheme, error)
// Delete deletes a project category.
//
// DELETE /rest/api/{2-3}/projectCategory/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/categories#delete-project-category
Delete(ctx context.Context, categoryId int) (*model.ResponseScheme, error)
}
type ProjectComponentConnector interface {
// Create creates a component. Use components to provide containers for issues within a project.
//
// POST /rest/api/{2-3}/component
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#create-component
Create(ctx context.Context, payload *model.ComponentPayloadScheme) (*model.ComponentScheme, *model.ResponseScheme, error)
// Gets returns all components in a project.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/components
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#get-project-components
Gets(ctx context.Context, projectIdOrKey string) ([]*model.ComponentScheme, *model.ResponseScheme, error)
// Count returns the counts of issues assigned to the component.
//
// GET /rest/api/{2-3}/component/{id}/relatedIssueCounts
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#get-component-issues-count
Count(ctx context.Context, componentId string) (*model.ComponentCountScheme, *model.ResponseScheme, error)
// Delete deletes a component.
//
// DELETE /rest/api/{2-3}/component/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#delete-component
Delete(ctx context.Context, componentId string) (*model.ResponseScheme, error)
// Update updates a component.
//
// Any fields included in the request are overwritten
//
// PUT /rest/api/{2-3}/component/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#update-component
Update(ctx context.Context, componentId string, payload *model.ComponentPayloadScheme) (*model.ComponentScheme, *model.ResponseScheme, error)
// Get returns a component.
//
// GET /rest/api/{2-3}/component/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/components#get-component
Get(ctx context.Context, componentId string) (*model.ComponentScheme, *model.ResponseScheme, error)
}
type ProjectFeatureConnector interface {
// Gets returns the list of features for a project.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/features
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/features#get-project-features
Gets(ctx context.Context, projectKeyOrId string) (*model.ProjectFeaturesScheme, *model.ResponseScheme, error)
// Set sets the state of a project feature.
//
// PUT /rest/api/{2-3}/project/{projectIdOrKey}/features/{featureKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/features#set-project-feature-state
Set(ctx context.Context, projectKeyOrId, featureKey, state string) (*model.ProjectFeaturesScheme, *model.ResponseScheme, error)
}
type ProjectPermissionSchemeConnector interface {
// Get search the permission scheme associated with the project.
//
// GET /rest/api/{2-3}/project/{projectKeyOrId}/permissionscheme
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/permission-schemes#get-assigned-permission-scheme
Get(ctx context.Context, projectKeyOrId string, expand []string) (*model.PermissionSchemeScheme, *model.ResponseScheme, error)
// Assign assigns a permission scheme with a project.
//
// See Managing project permissions for more information about permission schemes.
//
// PUT /rest/api/{2-3}/project/{projectKeyOrId}/permissionscheme
Assign(ctx context.Context, projectKeyOrId string, permissionSchemeId int) (*model.PermissionSchemeScheme, *model.ResponseScheme, error)
// SecurityLevels returns all issue security levels for the project that the user has access to.
//
// GET /rest/api/{2-3}/project/{projectKeyOrId}/securitylevel
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/permission-schemes#get-project-issue-security-levels
SecurityLevels(ctx context.Context, projectKeyOrId string) (*model.IssueSecurityLevelsScheme, *model.ResponseScheme, error)
}
type ProjectPropertyConnector interface {
// Gets returns all project property keys for the project.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/properties
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/properties#get-project-properties-keys
Gets(ctx context.Context, projectKeyOrId string) (*model.ProjectPropertyPageScheme, *model.ResponseScheme, error)
// Get returns the value of a project property.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/properties#get-project-property
Get(ctx context.Context, projectKeyOrId, propertyKey string) (*model.EntityPropertyScheme, *model.ResponseScheme, error)
// Set sets the value of the project property.
//
// You can use project properties to store custom data against the project.
//
// The value of the request body must be a valid, non-empty JSON blob.
//
// The maximum length is 32768 characters.
//
// PUT /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/properties#set-project-property
Set(ctx context.Context, projectKeyOrId, propertyKey string, payload interface{}) (*model.ResponseScheme, error)
// Delete deletes the property from a project.
//
// DELETE /rest/api/{2-3}/project/{projectIdOrKey}/properties/{propertyKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/properties#delete-project-property
Delete(ctx context.Context, projectKeyOrId, propertyKey string) (*model.ResponseScheme, error)
}
type ProjectRoleConnector interface {
// Gets returns a list of project roles for the project returning the name and self URL for each role.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/role
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles#get-project-roles-for-project
Gets(ctx context.Context, projectKeyOrId string) (*map[string]int, *model.ResponseScheme, error)
// Get returns a project role's details and actors associated with the project.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/role/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles#get-project-role-for-project
Get(ctx context.Context, projectKeyOrId string, roleId int) (*model.ProjectRoleScheme, *model.ResponseScheme, error)
// Details returns all project roles and the details for each role.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/roledetails
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles#get-project-role-details
Details(ctx context.Context, projectKeyOrId string) ([]*model.ProjectRoleDetailScheme, *model.ResponseScheme, error)
// Global gets a list of all project roles, complete with project role details and default actors.
//
// GET /rest/api/{2-3}/role
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles#get-all-project-roles
Global(ctx context.Context) ([]*model.ProjectRoleScheme, *model.ResponseScheme, error)
// Create creates a new project role with no default actors.
//
// POST /rest/api/{2-3}/role
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles#create-project-role
Create(ctx context.Context, payload *model.ProjectRolePayloadScheme) (*model.ProjectRoleScheme, *model.ResponseScheme, error)
}
type ProjectRoleActorConnector interface {
// Add adds actors to a project role for the project.
//
// POST /rest/api/{2-3}/project/{projectIdOrKey}/role/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles/actors#add-actors-to-project-role
Add(ctx context.Context, projectKeyOrId string, roleId int, accountIds, groups []string) (*model.ProjectRoleScheme, *model.ResponseScheme, error)
// Delete deletes actors from a project role for the project.
//
// DELETE /rest/api/{2-3}/project/{projectIdOrKey}/role/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/roles/actors#delete-actors-from-project-role
Delete(ctx context.Context, projectKeyOrId string, roleId int, accountId, group string) (*model.ResponseScheme, error)
}
type ProjectTypeConnector interface {
// Gets returns all project types, whether the instance has a valid license for each type.
//
// GET /rest/api/{2-3}/project/type
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/types#get-all-project-types
Gets(ctx context.Context) ([]*model.ProjectTypeScheme, *model.ResponseScheme, error)
// Licensed returns all project types with a valid license.
//
// GET /rest/api/{2-3}/project/type/accessible
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/types#get-licensed-project-types
Licensed(ctx context.Context) ([]*model.ProjectTypeScheme, *model.ResponseScheme, error)
// Get returns a project type
//
// GET /rest/api/{2-3}/project/type/{projectTypeKey}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/types#get-project-type-by-key
Get(ctx context.Context, projectTypeKey string) (*model.ProjectTypeScheme, *model.ResponseScheme, error)
// Accessible returns a project type if it is accessible to the user.
//
// GET /rest/api/{2-3}/project/type/{projectTypeKey}/accessible
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/types#get-accessible-project-type-by-key
Accessible(ctx context.Context, projectTypeKey string) (*model.ProjectTypeScheme, *model.ResponseScheme, error)
}
type ProjectValidatorConnector interface {
// Validate validates a project key by confirming the key is a valid string and not in use.
//
// GET /rest/api/{2-3}/projectvalidate/key
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/validation#validate-project-key
Validate(ctx context.Context, key string) (*model.ProjectValidationMessageScheme, *model.ResponseScheme, error)
// Key validates a project key and, if the key is invalid or in use,
//
// generates a valid random string for the project key.
//
// GET /rest/api/{2-3}/projectvalidate/validProjectKey
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/validation#get-valid-project-key
Key(ctx context.Context, key string) (string, *model.ResponseScheme, error)
// Name checks that a project name isn't in use.
//
// If the name isn't in use, the passed string is returned.
//
// If the name is in use, this operation attempts to generate a valid project name based on the one supplied,
//
// usually by adding a sequence number. If a valid project name cannot be generated, a 404 response is returned.
//
// GET /rest/api/{2-3}/projectvalidate/validProjectName
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/validation#get-valid-project-name
Name(ctx context.Context, name string) (string, *model.ResponseScheme, error)
}
type ProjectVersionConnector interface {
// Gets returns all versions in a project.
//
// The response is not paginated.
//
// Use Search() if you want to get the versions in a project with pagination.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/versions
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#get-project-versions
Gets(ctx context.Context, projectKeyOrId string) ([]*model.VersionScheme, *model.ResponseScheme, error)
// Search returns a paginated list of all versions in a project.
//
// GET /rest/api/{2-3}/project/{projectIdOrKey}/version
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#get-project-versions-paginated
Search(ctx context.Context, projectKeyOrId string, options *model.VersionGetsOptions, startAt, maxResults int) (*model.VersionPageScheme, *model.ResponseScheme, error)
// Create creates a project version.
//
// POST /rest/api/{2-3}/version
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#create-version
Create(ctx context.Context, payload *model.VersionPayloadScheme) (*model.VersionScheme, *model.ResponseScheme, error)
// Get returns a project version.
//
// GET /rest/api/{2-3}/version/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#get-version
Get(ctx context.Context, versionId string, expand []string) (*model.VersionScheme, *model.ResponseScheme, error)
// Update updates a project version.
//
// PUT /rest/api/{2-3}/version/{id}
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#update-version
Update(ctx context.Context, versionId string, payload *model.VersionPayloadScheme) (*model.VersionScheme, *model.ResponseScheme, error)
// Merge merges two project versions.
//
// The merge is completed by deleting the version specified in id and replacing any occurrences of
//
// its ID in fixVersion with the version ID specified in moveIssuesTo.
//
// PUT /rest/api/{2-3}/version/{id}/mergeto/{moveIssuesTo}
Merge(ctx context.Context, versionId, versionMoveIssuesTo string) (*model.ResponseScheme, error)
// RelatedIssueCounts returns the following counts for a version:
//
// 1. Number of issues where the fixVersion is set to the version.
//
// 2. Number of issues where the affectedVersion is set to the version.
//
// 3. Number of issues where a version custom field is set to the version.
//
// GET /rest/api/{2-3}/version/{id}/relatedIssueCounts
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#get-versions-related-issues-count
RelatedIssueCounts(ctx context.Context, versionId string) (*model.VersionIssueCountsScheme, *model.ResponseScheme, error)
// UnresolvedIssueCount returns counts of the issues and unresolved issues for the project version.
//
// GET /rest/api/{2-3}/version/{id}/unresolvedIssueCount
//
// https://docs.go-atlassian.io/jira-software-cloud/projects/versions#get-versions-unresolved-issues-count
UnresolvedIssueCount(ctx context.Context, versionId string) (*model.VersionUnresolvedIssuesCountScheme, *model.ResponseScheme, error)
}