@pipedream/snipe_it 0.0.1 → 0.2.0

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.
@@ -0,0 +1,233 @@
1
+ import app from "../../snipe_it.app.mjs";
2
+ import utils from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ key: "snipe_it-create-hardware",
6
+ name: "Create Hardware Asset",
7
+ description: "Creates a new hardware asset in Snipe-IT. [See the documentation](https://snipe-it.readme.io/reference/hardware-create)",
8
+ version: "0.0.2",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
14
+ type: "action",
15
+ props: {
16
+ app,
17
+ modelId: {
18
+ propDefinition: [
19
+ app,
20
+ "modelId",
21
+ ],
22
+ },
23
+ statusId: {
24
+ propDefinition: [
25
+ app,
26
+ "statusId",
27
+ ],
28
+ },
29
+ assetTag: {
30
+ propDefinition: [
31
+ app,
32
+ "assetTag",
33
+ ],
34
+ },
35
+ name: {
36
+ propDefinition: [
37
+ app,
38
+ "name",
39
+ ],
40
+ },
41
+ image: {
42
+ propDefinition: [
43
+ app,
44
+ "image",
45
+ ],
46
+ },
47
+ serial: {
48
+ propDefinition: [
49
+ app,
50
+ "serial",
51
+ ],
52
+ },
53
+ purchaseDate: {
54
+ propDefinition: [
55
+ app,
56
+ "purchaseDate",
57
+ ],
58
+ },
59
+ purchaseCost: {
60
+ propDefinition: [
61
+ app,
62
+ "purchaseCost",
63
+ ],
64
+ },
65
+ orderNumber: {
66
+ propDefinition: [
67
+ app,
68
+ "orderNumber",
69
+ ],
70
+ },
71
+ notes: {
72
+ propDefinition: [
73
+ app,
74
+ "notes",
75
+ ],
76
+ },
77
+ archived: {
78
+ propDefinition: [
79
+ app,
80
+ "archived",
81
+ ],
82
+ },
83
+ warrantyMonths: {
84
+ propDefinition: [
85
+ app,
86
+ "warrantyMonths",
87
+ ],
88
+ },
89
+ depreciate: {
90
+ propDefinition: [
91
+ app,
92
+ "depreciate",
93
+ ],
94
+ },
95
+ supplierId: {
96
+ propDefinition: [
97
+ app,
98
+ "supplierId",
99
+ ],
100
+ },
101
+ requestable: {
102
+ propDefinition: [
103
+ app,
104
+ "requestable",
105
+ ],
106
+ },
107
+ rtdLocationId: {
108
+ label: "RTD Location",
109
+ description: "Select the default location for this asset",
110
+ propDefinition: [
111
+ app,
112
+ "locationId",
113
+ ],
114
+ },
115
+ lastAuditDate: {
116
+ propDefinition: [
117
+ app,
118
+ "lastAuditDate",
119
+ ],
120
+ },
121
+ locationId: {
122
+ propDefinition: [
123
+ app,
124
+ "locationId",
125
+ ],
126
+ },
127
+ byod: {
128
+ propDefinition: [
129
+ app,
130
+ "byod",
131
+ ],
132
+ },
133
+ customFields: {
134
+ propDefinition: [
135
+ app,
136
+ "customFields",
137
+ ],
138
+ },
139
+ },
140
+ async run({ $ }) {
141
+ const {
142
+ app,
143
+ modelId,
144
+ statusId,
145
+ assetTag,
146
+ name,
147
+ image,
148
+ serial,
149
+ purchaseDate,
150
+ purchaseCost,
151
+ orderNumber,
152
+ notes,
153
+ archived,
154
+ warrantyMonths,
155
+ depreciate,
156
+ supplierId,
157
+ requestable,
158
+ rtdLocationId,
159
+ lastAuditDate,
160
+ locationId,
161
+ byod,
162
+ customFields,
163
+ } = this;
164
+
165
+ const parsedCustomFields = utils.parseJson(customFields);
166
+
167
+ const response = await app.createHardware({
168
+ $,
169
+ data: {
170
+ model_id: modelId,
171
+ status_id: statusId,
172
+ ...(name && {
173
+ name,
174
+ }),
175
+ ...(assetTag && {
176
+ asset_tag: assetTag,
177
+ }),
178
+ ...(image && {
179
+ image,
180
+ }),
181
+ ...(serial && {
182
+ serial,
183
+ }),
184
+ ...(purchaseDate && {
185
+ purchase_date: purchaseDate,
186
+ }),
187
+ ...(purchaseCost && {
188
+ purchase_cost: purchaseCost,
189
+ }),
190
+ ...(orderNumber && {
191
+ order_number: orderNumber,
192
+ }),
193
+ ...(notes && {
194
+ notes,
195
+ }),
196
+ ...(archived !== undefined && {
197
+ archived,
198
+ }),
199
+ ...(warrantyMonths && {
200
+ warranty_months: warrantyMonths,
201
+ }),
202
+ ...(depreciate !== undefined && {
203
+ depreciate,
204
+ }),
205
+ ...(supplierId && {
206
+ supplier_id: supplierId,
207
+ }),
208
+ ...(requestable !== undefined && {
209
+ requestable,
210
+ }),
211
+ ...(rtdLocationId && {
212
+ rtd_location_id: rtdLocationId,
213
+ }),
214
+ ...(lastAuditDate && {
215
+ last_audit_date: lastAuditDate,
216
+ }),
217
+ ...(locationId && {
218
+ location_id: locationId,
219
+ }),
220
+ ...(byod !== undefined && {
221
+ byod,
222
+ }),
223
+ ...(typeof(parsedCustomFields) === "object"
224
+ ? parsedCustomFields
225
+ : {}
226
+ ),
227
+ },
228
+ });
229
+
230
+ $.export("$summary", `Successfully created hardware asset with ID \`${response.payload.id}\``);
231
+ return response;
232
+ },
233
+ };
@@ -0,0 +1,216 @@
1
+ import app from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-create-user",
5
+ name: "Create User",
6
+ description: "Creates a new user in Snipe-IT with profile information required for asset or license assignments. [See the documentation](https://snipe-it.readme.io/reference/users-2)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: true,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ firstName: {
17
+ propDefinition: [
18
+ app,
19
+ "firstName",
20
+ ],
21
+ },
22
+ username: {
23
+ propDefinition: [
24
+ app,
25
+ "username",
26
+ ],
27
+ },
28
+ password: {
29
+ propDefinition: [
30
+ app,
31
+ "password",
32
+ ],
33
+ },
34
+ passwordConfirmation: {
35
+ propDefinition: [
36
+ app,
37
+ "passwordConfirmation",
38
+ ],
39
+ },
40
+ lastName: {
41
+ propDefinition: [
42
+ app,
43
+ "lastName",
44
+ ],
45
+ },
46
+ email: {
47
+ propDefinition: [
48
+ app,
49
+ "email",
50
+ ],
51
+ },
52
+ activated: {
53
+ propDefinition: [
54
+ app,
55
+ "activated",
56
+ ],
57
+ },
58
+ phone: {
59
+ propDefinition: [
60
+ app,
61
+ "phone",
62
+ ],
63
+ },
64
+ jobtitle: {
65
+ propDefinition: [
66
+ app,
67
+ "jobtitle",
68
+ ],
69
+ },
70
+ managerId: {
71
+ propDefinition: [
72
+ app,
73
+ "managerId",
74
+ ],
75
+ },
76
+ employeeNum: {
77
+ propDefinition: [
78
+ app,
79
+ "employeeNum",
80
+ ],
81
+ },
82
+ notes: {
83
+ description: "Notes about the user",
84
+ propDefinition: [
85
+ app,
86
+ "notes",
87
+ ],
88
+ },
89
+ companyId: {
90
+ propDefinition: [
91
+ app,
92
+ "companyId",
93
+ ],
94
+ },
95
+ twoFactorEnrolled: {
96
+ propDefinition: [
97
+ app,
98
+ "twoFactorEnrolled",
99
+ ],
100
+ },
101
+ twoFactorOptIn: {
102
+ propDefinition: [
103
+ app,
104
+ "twoFactorOptIn",
105
+ ],
106
+ },
107
+ departmentId: {
108
+ propDefinition: [
109
+ app,
110
+ "departmentId",
111
+ ],
112
+ },
113
+ locationId: {
114
+ propDefinition: [
115
+ app,
116
+ "locationId",
117
+ ],
118
+ },
119
+ remote: {
120
+ propDefinition: [
121
+ app,
122
+ "remote",
123
+ ],
124
+ },
125
+ groups: {
126
+ propDefinition: [
127
+ app,
128
+ "groupIds",
129
+ ],
130
+ },
131
+ autoAssignLicenses: {
132
+ propDefinition: [
133
+ app,
134
+ "autoAssignLicenses",
135
+ ],
136
+ },
137
+ vip: {
138
+ propDefinition: [
139
+ app,
140
+ "vip",
141
+ ],
142
+ },
143
+ startDate: {
144
+ propDefinition: [
145
+ app,
146
+ "startDate",
147
+ ],
148
+ },
149
+ endDate: {
150
+ propDefinition: [
151
+ app,
152
+ "endDate",
153
+ ],
154
+ },
155
+ },
156
+ async run({ $ }) {
157
+ const {
158
+ app,
159
+ firstName,
160
+ username,
161
+ password,
162
+ passwordConfirmation,
163
+ lastName,
164
+ email,
165
+ activated,
166
+ phone,
167
+ jobtitle,
168
+ managerId,
169
+ employeeNum,
170
+ notes,
171
+ companyId,
172
+ twoFactorEnrolled,
173
+ twoFactorOptIn,
174
+ departmentId,
175
+ locationId,
176
+ remote,
177
+ groups,
178
+ autoAssignLicenses,
179
+ vip,
180
+ startDate,
181
+ endDate,
182
+ } = this;
183
+
184
+ const response = await app.createUser({
185
+ $,
186
+ data: {
187
+ first_name: firstName,
188
+ username,
189
+ password,
190
+ password_confirmation: passwordConfirmation,
191
+ last_name: lastName,
192
+ email,
193
+ activated,
194
+ phone,
195
+ jobtitle,
196
+ manager_id: managerId,
197
+ employee_num: employeeNum,
198
+ notes,
199
+ company_id: companyId,
200
+ two_factor_enrolled: twoFactorEnrolled,
201
+ two_factor_optin: twoFactorOptIn,
202
+ department_id: departmentId,
203
+ location_id: locationId,
204
+ remote,
205
+ groups,
206
+ autoassign_licenses: autoAssignLicenses,
207
+ vip,
208
+ start_date: startDate,
209
+ end_date: endDate,
210
+ },
211
+ });
212
+
213
+ $.export("$summary", `Successfully created user with ID \`${response.payload.id}\``);
214
+ return response;
215
+ },
216
+ };
@@ -0,0 +1,32 @@
1
+ import app from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-get-hardware",
5
+ name: "Get Hardware Asset",
6
+ description: "Retrieves details of a specific hardware asset by ID. [See the documentation](https://snipe-it.readme.io/reference/hardware-by-id)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ hardwareId: {
17
+ propDefinition: [
18
+ app,
19
+ "hardwareId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const response = await this.app.getHardware({
25
+ $,
26
+ hardwareId: this.hardwareId,
27
+ });
28
+
29
+ $.export("$summary", `Successfully retrieved hardware asset details with ID \`${response.id}\``);
30
+ return response;
31
+ },
32
+ };
@@ -0,0 +1,37 @@
1
+ import app from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-get-license",
5
+ name: "Get License",
6
+ description: "Retrieves license details including seat count, expiration, and current usage metrics. Note: The response returns 'product_key' but uses 'serial' field for POST/PUT/PATCH requests. [See the documentation](https://snipe-it.readme.io/reference/licensesid)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ licenseId: {
17
+ propDefinition: [
18
+ app,
19
+ "licenseId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const {
25
+ app,
26
+ licenseId,
27
+ } = this;
28
+
29
+ const response = await app.getLicense({
30
+ $,
31
+ licenseId,
32
+ });
33
+
34
+ $.export("$summary", `Successfully retrieved license with ID \`${response.id}\``);
35
+ return response;
36
+ },
37
+ };
@@ -0,0 +1,37 @@
1
+ import app from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-get-user-assets",
5
+ name: "Get User Assets",
6
+ description: "Retrieves all assets currently assigned to a specific user. Useful for audits and inventory reviews. [See the documentation](https://snipe-it.readme.io/reference/usersidassets)",
7
+ version: "0.0.2",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ app,
16
+ userId: {
17
+ propDefinition: [
18
+ app,
19
+ "userId",
20
+ ],
21
+ },
22
+ },
23
+ async run({ $ }) {
24
+ const {
25
+ app,
26
+ userId,
27
+ } = this;
28
+
29
+ const response = await app.getUserAssets({
30
+ $,
31
+ userId,
32
+ });
33
+
34
+ $.export("$summary", `Successfully retrieved \`${response.rows.length}\` assets for user ID \`${userId}\``);
35
+ return response;
36
+ },
37
+ };
@@ -0,0 +1,33 @@
1
+ import snipe_it from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-list-company-id-options",
5
+ name: "List Company Options",
6
+ description: "Retrieves available options for the Company field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ snipe_it,
16
+ page: {
17
+ type: "integer",
18
+ label: "Page",
19
+ description: "The page of results to retrieve.",
20
+ min: 0,
21
+ default: 0,
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const options = await snipe_it.propDefinitions.companyId.options.call(this.snipe_it, {
26
+ page: this.page,
27
+ });
28
+ $.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
29
+ ? ""
30
+ : "s"}`);
31
+ return options;
32
+ },
33
+ };
@@ -0,0 +1,33 @@
1
+ import snipe_it from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-list-department-id-options",
5
+ name: "List Department Options",
6
+ description: "Retrieves available options for the Department field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ snipe_it,
16
+ page: {
17
+ type: "integer",
18
+ label: "Page",
19
+ description: "The page of results to retrieve.",
20
+ min: 0,
21
+ default: 0,
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const options = await snipe_it.propDefinitions.departmentId.options.call(this.snipe_it, {
26
+ page: this.page,
27
+ });
28
+ $.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
29
+ ? ""
30
+ : "s"}`);
31
+ return options;
32
+ },
33
+ };
@@ -0,0 +1,33 @@
1
+ import snipe_it from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-list-group-ids-options",
5
+ name: "List Groups Options",
6
+ description: "Retrieves available options for the Groups field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ snipe_it,
16
+ page: {
17
+ type: "integer",
18
+ label: "Page",
19
+ description: "The page of results to retrieve.",
20
+ min: 0,
21
+ default: 0,
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const options = await snipe_it.propDefinitions.groupIds.options.call(this.snipe_it, {
26
+ page: this.page,
27
+ });
28
+ $.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
29
+ ? ""
30
+ : "s"}`);
31
+ return options;
32
+ },
33
+ };
@@ -0,0 +1,33 @@
1
+ import snipe_it from "../../snipe_it.app.mjs";
2
+
3
+ export default {
4
+ key: "snipe_it-list-hardware-id-options",
5
+ name: "List Hardware Asset Options",
6
+ description: "Retrieves available options for the Hardware Asset field.",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ snipe_it,
16
+ page: {
17
+ type: "integer",
18
+ label: "Page",
19
+ description: "The page of results to retrieve.",
20
+ min: 0,
21
+ default: 0,
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const options = await snipe_it.propDefinitions.hardwareId.options.call(this.snipe_it, {
26
+ page: this.page,
27
+ });
28
+ $.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
29
+ ? ""
30
+ : "s"}`);
31
+ return options;
32
+ },
33
+ };