btrz-api-client 8.75.0 → 8.75.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client-standalone-min.js +1 -1
- package/lib/endpoints/inventory/control-classes.js +33 -0
- package/package.json +1 -1
- package/src/endpoints/inventory/control-classes.js +27 -0
- package/test/endpoints/inventory/control-classes.js +14 -0
- package/types/endpoints/inventory/control-classes.d.ts +4 -0
|
@@ -202,12 +202,45 @@ function controlClassesFactory(_ref) {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* POST /control-classes/:rootClassId/clones — Clone a full control class nesting from a root class.
|
|
207
|
+
* Body: { controlClassCloneOptions }. Emits controlclasses.created for each cloned class.
|
|
208
|
+
* @param {Object} opts
|
|
209
|
+
* @param {string} [opts.token] - API key
|
|
210
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
211
|
+
* @param {string} opts.rootClassId - Root control class id (24 hex)
|
|
212
|
+
* @param {{ newRootName?: string, cloneWithPrefix?: string }} opts.controlClassCloneOptions - Clone options
|
|
213
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
214
|
+
* @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
|
|
215
|
+
* @throws 400 WRONG_DATA, INVALID_ROOTCLASS_ID, CONTROLCLASS_NOT_ROOT
|
|
216
|
+
* @throws 401 Unauthorized
|
|
217
|
+
* @throws 404 CONTROLCLASS_NOT_FOUND
|
|
218
|
+
* @throws 500 Internal server error
|
|
219
|
+
*/
|
|
220
|
+
function clone(_ref8) {
|
|
221
|
+
var jwtToken = _ref8.jwtToken,
|
|
222
|
+
token = _ref8.token,
|
|
223
|
+
rootClassId = _ref8.rootClassId,
|
|
224
|
+
controlClassCloneOptions = _ref8.controlClassCloneOptions,
|
|
225
|
+
headers = _ref8.headers;
|
|
226
|
+
|
|
227
|
+
return client({
|
|
228
|
+
url: "/control-classes/" + rootClassId + "/clones",
|
|
229
|
+
method: "post",
|
|
230
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
231
|
+
data: {
|
|
232
|
+
controlClassCloneOptions: controlClassCloneOptions
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
205
237
|
return {
|
|
206
238
|
all: all,
|
|
207
239
|
get: get,
|
|
208
240
|
create: create,
|
|
209
241
|
update: update,
|
|
210
242
|
remove: remove,
|
|
243
|
+
clone: clone,
|
|
211
244
|
schedules: schedules
|
|
212
245
|
};
|
|
213
246
|
}
|
package/package.json
CHANGED
|
@@ -166,12 +166,39 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* POST /control-classes/:rootClassId/clones — Clone a full control class nesting from a root class.
|
|
171
|
+
* Body: { controlClassCloneOptions }. Emits controlclasses.created for each cloned class.
|
|
172
|
+
* @param {Object} opts
|
|
173
|
+
* @param {string} [opts.token] - API key
|
|
174
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
175
|
+
* @param {string} opts.rootClassId - Root control class id (24 hex)
|
|
176
|
+
* @param {{ newRootName?: string, cloneWithPrefix?: string }} opts.controlClassCloneOptions - Clone options
|
|
177
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
178
|
+
* @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
|
|
179
|
+
* @throws 400 WRONG_DATA, INVALID_ROOTCLASS_ID, CONTROLCLASS_NOT_ROOT
|
|
180
|
+
* @throws 401 Unauthorized
|
|
181
|
+
* @throws 404 CONTROLCLASS_NOT_FOUND
|
|
182
|
+
* @throws 500 Internal server error
|
|
183
|
+
*/
|
|
184
|
+
function clone({jwtToken, token, rootClassId, controlClassCloneOptions, headers}) {
|
|
185
|
+
return client({
|
|
186
|
+
url: `/control-classes/${rootClassId}/clones`,
|
|
187
|
+
method: "post",
|
|
188
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
189
|
+
data: {
|
|
190
|
+
controlClassCloneOptions
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
return {
|
|
170
196
|
all,
|
|
171
197
|
get,
|
|
172
198
|
create,
|
|
173
199
|
update,
|
|
174
200
|
remove,
|
|
201
|
+
clone,
|
|
175
202
|
schedules
|
|
176
203
|
};
|
|
177
204
|
}
|
|
@@ -74,4 +74,18 @@ describe("inventory/control-classes", () => {
|
|
|
74
74
|
data: {scheduleIds: ["schedule1", "schedule2"]}
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
it("should clone a control class nesting", () => {
|
|
79
|
+
const rootClassId = "1234";
|
|
80
|
+
axiosMock.onPost(`/control-classes/${rootClassId}/clones`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
81
|
+
return api.inventory.controlClasses.clone({
|
|
82
|
+
jwtToken,
|
|
83
|
+
token,
|
|
84
|
+
rootClassId,
|
|
85
|
+
controlClassCloneOptions: {
|
|
86
|
+
newRootName: "ClonedRoot",
|
|
87
|
+
cloneWithPrefix: "copy"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
77
91
|
});
|