-
Notifications
You must be signed in to change notification settings - Fork 10
/
libraries.js
281 lines (251 loc) · 9.71 KB
/
libraries.js
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
/*
Copyright 2019 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
// Libraries
// https://developer.adobelaunch.com/api/libraries
// Add DataElement relationships to a Library
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/data_elements/add_relationships/
// Example `deList` value:
// [
// { "DE0123456789012345678901", type: "data_elements"],
// { "DE1234567890123456789012", type: "data_elements"],
// ]
export function addDataElementRelationshipsToLibrary(libraryId, deList) {
return this.post(`/libraries/${libraryId}/relationships/data_elements`, {
data: deList
});
}
// Add Extension relationships to a Library
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/extensions/add_relationships/
// Example `exList` value:
// [
// { "EX0123456789012345678901", type: "extensions"],
// { "EX1234567890123456789012", type: "extensions"],
// ]
export function addExtensionRelationshipsToLibrary(libraryId, exList) {
return this.post(`/libraries/${libraryId}/relationships/extensions`, {
data: exList
});
}
// Add Rule relationships to a Library
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/rules/add_relationships/
// Example `rlList` value:
// [
// { "RL0123456789012345678901", type: "rules"],
// { "RL1234567890123456789012", type: "rules"],
// ]
export function addRuleRelationshipsToLibrary(libraryId, rlList) {
return this.post(`/libraries/${libraryId}/relationships/rules`, {
data: rlList
});
}
// Create a Library
// https://developer.adobelaunch.com/api/libraries/create/
export function createLibrary(propertyId, library) {
return this.post(`/properties/${propertyId}/libraries`, {
data: library
});
}
// Delete a Library
export function deleteLibrary(libraryId) {
return this.delete(`/libraries/${libraryId}`);
}
// Get the Environment
// https://developer.adobelaunch.com/api/libraries/fetch_environment/
export function getEnvironmentForLibrary(libraryId) {
return this.get(`/libraries/${libraryId}/environment`);
}
// Get the Environment relationship
// https://developer.adobelaunch.com/api/libraries/fetch_environment_relationship/
export function getEnvironmentRelationshipForLibrary(libraryId) {
return this.get(`/libraries/${libraryId}/relationships/environment`);
}
// Get a Library
// https://developer.adobelaunch.com/api/libraries/fetch/
export function getLibrary(libraryId) {
return this.get(`/libraries/${libraryId}`);
}
// Get the Property
// https://developer.adobelaunch.com/api/libraries/property/
export function getPropertyForLibrary(libraryId) {
return this.get(`/libraries/${libraryId}/property`);
}
// Get the upstream Library
// https://developer.adobelaunch.com/api/libraries/upstream/
export function getUpstreamLibraryForLibrary(libraryId) {
return this.get(`/libraries/${libraryId}/upstream_library`);
}
// List DataElements
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/data_elements/list_related/
export function listDataElementsForLibrary(libraryId, queryParams) {
return this.get(`/libraries/${libraryId}/data_elements`, queryParams);
}
// List DataElement relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/data_elements/list_relationships/
export function listDataElementRelationshipsForLibrary(libraryId, queryParams) {
return this.get(
`/libraries/${libraryId}/relationships/data_elements`,
queryParams
);
}
// List Extensions
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/extensions/list_related/
export function listExtensionsForLibrary(libraryId, queryParams) {
return this.get(`/libraries/${libraryId}/extensions`, queryParams);
}
// List Extension relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/extensions/list_relationships/
export function listExtensionRelationshipsForLibrary(libraryId, queryParams) {
return this.get(
`/libraries/${libraryId}/relationships/extensions`,
queryParams
);
}
// List Libraries for a Property
// https://developer.adobelaunch.com/api/libraries/
export function listLibrariesForProperty(propertyId, queryParams) {
return this.get(`/properties/${propertyId}/libraries`, queryParams);
}
// List Rule relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/rules/list_relationships/
export function listRuleRelationshipsForLibrary(libraryId, queryParams) {
return this.get(`/libraries/${libraryId}/relationships/rules`, queryParams);
}
// List Rules
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/rules/list_related/
export function listRulesForLibrary(libraryId, queryParams) {
return this.get(`/libraries/${libraryId}/rules`, queryParams);
}
// Publish a Library
// https://developer.adobelaunch.com/api/libraries/publish/
export function publishLibrary(libraryId) {
// NOTE: The Library's Environment must be of type Production, and the build
// must succeed; otherwise, this will *not* generate a state transition to
// 'published'.
return this.createBuild(libraryId);
}
// Remove DataElement relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/data_elements/remove_relationships/
// Example `deList` value:
// [
// { "DE0123456789012345678901", type: "data_elements"],
// { "DE1234567890123456789012", type: "data_elements"],
// ]
export function removeDataElementRelationshipsFromLibrary(libraryId, deList) {
return this.delete(`/libraries/${libraryId}/relationships/data_elements`, {
data: deList
});
}
// Remove Extension relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/extensions/remove_relationships/
// Example `exList` value:
// [
// { "EX0123456789012345678901", type: "extensions"],
// { "EX1234567890123456789012", type: "extensions"],
// ]
export function removeExtensionRelationshipsFromLibrary(libraryId, exList) {
return this.delete(`/libraries/${libraryId}/relationships/extensions`, {
data: exList
});
}
// Remove Environment relationship
// https://developer.adobelaunch.com/api/libraries/delete_environment_relationship/
export function removeEnvironmentRelationshipFromLibrary(
libraryId,
environmentId
) {
return this.delete(`/libraries/${libraryId}/relationships/environment`, {
data: {
id: environmentId,
type: 'environments'
},
id: libraryId
});
}
// Remove Rule relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/rules/remove_relationships/
// Example `rules` value:
// [
// { "RL0123456789012345678901", type: "rules"],
// { "RL1234567890123456789012", type: "rules"],
// ]
export function removeRuleRelationshipsFromLibrary(libraryId, rules) {
return this.delete(`/libraries/${libraryId}/relationships/rules`, {
data: rules
});
}
// Replace Extension relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/extensions/replace_relationships/
// Example `exList` value:
// [
// { "EX0123456789012345678901", type: "extensions"],
// { "EX1234567890123456789012", type: "extensions"],
// ]
export function replaceExtensionRelationshipsForLibrary(libraryId, exList) {
return this.patch(`/libraries/${libraryId}/relationships/extensions`, {
data: exList
});
}
// Replace DataElement relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/data_elements/replace_relationships/
// Example `deList` value:
// [
// { "DE0123456789012345678901", type: "data_elements"],
// { "DE1234567890123456789012", type: "data_elements"],
// ]
export function replaceDataElementRelationshipsForLibrary(libraryId, deList) {
return this.patch(`/libraries/${libraryId}/relationships/data_elements`, {
data: deList
});
}
// Replace Rule relationships
// https://developer.adobelaunch.com/api/reference/1.0/libraries/relationships/rules/replace_relationships/
// Example `rlList` value:
// [
// { "RL0123456789012345678901", type: "rules"],
// { "RL1234567890123456789012", type: "rules"],
// ]
export function replaceRuleRelationshipsForLibrary(libraryId, rlList) {
return this.patch(`/libraries/${libraryId}/relationships/rules`, {
data: rlList
});
}
// Set Environment relationship for a Library
// https://developer.adobelaunch.com/api/libraries/set_environment_relationship/
export function setEnvironmentRelationshipForLibrary(libraryId, environmentId) {
return this.patch(`/libraries/${libraryId}/relationships/environment`, {
data: {
id: environmentId,
type: 'environments'
},
id: libraryId
});
}
// Transition a Library
// https://developer.adobelaunch.com/api/libraries/transition/
// `action` must be 'submit', 'approve', 'reject', or 'develop'
export function transitionLibrary(libraryId, action) {
return this.patch(`/libraries/${libraryId}`, {
data: {
id: libraryId,
type: 'libraries',
meta: {
action
}
}
});
}
// Update a Library
// https://developer.adobelaunch.com/api/libraries/update/
export function updateLibrary(libraryPatch) {
return this.patch(`/libraries/${libraryPatch.id}`, {
data: libraryPatch
});
}