Skip to content

Commit 4289286

Browse files
committed
[Components] Snipe-IT
1 parent 4ae047b commit 4289286

File tree

9 files changed

+1407
-55
lines changed

9 files changed

+1407
-55
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
import app from "../../snipe_it.app.mjs";
2+
3+
export default {
4+
key: "snipe_it-create-hardware",
5+
name: "Create Hardware Asset",
6+
description: "Creates a new hardware asset in Snipe-IT. [See the documentation](https://snipe-it.readme.io/reference/hardware-create)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
modelId: {
12+
propDefinition: [
13+
app,
14+
"modelId",
15+
],
16+
},
17+
statusId: {
18+
propDefinition: [
19+
app,
20+
"statusId",
21+
],
22+
},
23+
assetTag: {
24+
propDefinition: [
25+
app,
26+
"assetTag",
27+
],
28+
},
29+
name: {
30+
propDefinition: [
31+
app,
32+
"name",
33+
],
34+
},
35+
image: {
36+
propDefinition: [
37+
app,
38+
"image",
39+
],
40+
},
41+
serial: {
42+
propDefinition: [
43+
app,
44+
"serial",
45+
],
46+
},
47+
purchaseDate: {
48+
propDefinition: [
49+
app,
50+
"purchaseDate",
51+
],
52+
},
53+
purchaseCost: {
54+
propDefinition: [
55+
app,
56+
"purchaseCost",
57+
],
58+
},
59+
orderNumber: {
60+
propDefinition: [
61+
app,
62+
"orderNumber",
63+
],
64+
},
65+
notes: {
66+
propDefinition: [
67+
app,
68+
"notes",
69+
],
70+
},
71+
archived: {
72+
propDefinition: [
73+
app,
74+
"archived",
75+
],
76+
},
77+
warrantyMonths: {
78+
propDefinition: [
79+
app,
80+
"warrantyMonths",
81+
],
82+
},
83+
depreciate: {
84+
propDefinition: [
85+
app,
86+
"depreciate",
87+
],
88+
},
89+
supplierId: {
90+
propDefinition: [
91+
app,
92+
"supplierId",
93+
],
94+
},
95+
requestable: {
96+
propDefinition: [
97+
app,
98+
"requestable",
99+
],
100+
},
101+
rtdLocationId: {
102+
label: "RTD Location",
103+
description: "Select the default location for this asset",
104+
propDefinition: [
105+
app,
106+
"locationId",
107+
],
108+
},
109+
lastAuditDate: {
110+
propDefinition: [
111+
app,
112+
"lastAuditDate",
113+
],
114+
},
115+
locationId: {
116+
propDefinition: [
117+
app,
118+
"locationId",
119+
],
120+
},
121+
byod: {
122+
propDefinition: [
123+
app,
124+
"byod",
125+
],
126+
},
127+
customFields: {
128+
propDefinition: [
129+
app,
130+
"customFields",
131+
],
132+
},
133+
},
134+
async run({ $ }) {
135+
const {
136+
app,
137+
modelId,
138+
statusId,
139+
assetTag,
140+
name,
141+
image,
142+
serial,
143+
purchaseDate,
144+
purchaseCost,
145+
orderNumber,
146+
notes,
147+
archived,
148+
warrantyMonths,
149+
depreciate,
150+
supplierId,
151+
requestable,
152+
rtdLocationId,
153+
lastAuditDate,
154+
locationId,
155+
byod,
156+
customFields,
157+
} = this;
158+
159+
const response = await app.createHardware({
160+
$,
161+
data: {
162+
model_id: modelId,
163+
status_id: statusId,
164+
...(name && {
165+
name,
166+
}),
167+
...(assetTag && {
168+
asset_tag: assetTag,
169+
}),
170+
...(image && {
171+
image,
172+
}),
173+
...(serial && {
174+
serial,
175+
}),
176+
...(purchaseDate && {
177+
purchase_date: purchaseDate,
178+
}),
179+
...(purchaseCost && {
180+
purchase_cost: purchaseCost,
181+
}),
182+
...(orderNumber && {
183+
order_number: orderNumber,
184+
}),
185+
...(notes && {
186+
notes,
187+
}),
188+
...(archived !== undefined && {
189+
archived,
190+
}),
191+
...(warrantyMonths && {
192+
warranty_months: warrantyMonths,
193+
}),
194+
...(depreciate !== undefined && {
195+
depreciate,
196+
}),
197+
...(supplierId && {
198+
supplier_id: supplierId,
199+
}),
200+
...(requestable !== undefined && {
201+
requestable,
202+
}),
203+
...(rtdLocationId && {
204+
rtd_location_id: rtdLocationId,
205+
}),
206+
...(lastAuditDate && {
207+
last_audit_date: lastAuditDate,
208+
}),
209+
...(locationId && {
210+
location_id: locationId,
211+
}),
212+
...(byod !== undefined && {
213+
byod,
214+
}),
215+
...(customFields && {
216+
...customFields,
217+
}),
218+
},
219+
});
220+
221+
$.export("$summary", `Successfully created hardware asset with ID \`${response.payload.id}\``);
222+
return response;
223+
},
224+
};

0 commit comments

Comments
 (0)