-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathValues.ts
More file actions
114 lines (108 loc) · 3.37 KB
/
Values.ts
File metadata and controls
114 lines (108 loc) · 3.37 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
import { BaseResource } from "../BaseResource";
import { Configuration } from "../../Configuration";
import {
UpdateWorkItemPropertyValue,
ListWorkItemPropertyValuesParams,
WorkItemPropertyValues,
} from "../../models/WorkItemProperty";
/**
* WorkItemPropertyValues API resource
* Handles all work item property value operations
*/
export class Values extends BaseResource {
constructor(config: Configuration) {
super(config);
}
/**
* Retrieve a property value by ID
*/
async retrieve(
workspaceSlug: string,
projectId: string,
workItemId: string,
propertyId: string
): Promise<WorkItemPropertyValues> {
const propertyValues = await this.get<WorkItemPropertyValues>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`
);
return propertyValues;
}
/**
* List property values for a work item
*/
async list(
workspaceSlug: string,
projectId: string,
workItemId: string,
params?: ListWorkItemPropertyValuesParams
): Promise<WorkItemPropertyValues> {
return this.get<WorkItemPropertyValues>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/values/`,
params
);
}
/**
* Create/update a property value
*
* For single-value properties:
* - Acts as an upsert operation (create or update)
* - Returns a single WorkItemPropertyValues
*
* For multi-value properties (is_multi=True):
* - Replaces all existing values with the new ones (sync operation)
* - Returns a list of values
*/
async create(
workspaceSlug: string,
projectId: string,
workItemId: string,
propertyId: string,
updateData: UpdateWorkItemPropertyValue
): Promise<WorkItemPropertyValues> {
return this.post<WorkItemPropertyValues>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`,
updateData
);
}
/**
* Update an existing property value(s) (partial update)
*
* For single-value properties:
* - Updates the existing value
* - Returns a single WorkItemPropertyValues
*
* For multi-value properties (is_multi=True):
* - Replaces all existing values with the new ones (sync operation)
* - Returns a list of values
*
* @throws {HttpError} If the property value does not exist (404)
*/
async update(
workspaceSlug: string,
projectId: string,
workItemId: string,
propertyId: string,
updateData: UpdateWorkItemPropertyValue
): Promise<WorkItemPropertyValues> {
return this.patch<WorkItemPropertyValues>(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`,
updateData
);
}
/**
* Delete the property value(s) for a work item
*
* For single-value properties:
* - Deletes the single value
*
* For multi-value properties (is_multi=True):
* - Deletes all values for that property
*
* @throws {HttpError} If the property value does not exist (404)
*/
async delete(workspaceSlug: string, projectId: string, workItemId: string, propertyId: string): Promise<void> {
return this.httpDelete(
`/workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/work-item-properties/${propertyId}/values/`
);
}
}