Skip to content

Commit 6488ad4

Browse files
committed
onelogin init
1 parent 7e0a32b commit 6488ad4

File tree

8 files changed

+1176
-3
lines changed

8 files changed

+1176
-3
lines changed
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
import onelogin from "../../onelogin.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "onelogin-create-user",
6+
name: "Create User",
7+
description: "Creates a new user in OneLogin. [See the documentation](https://developers.onelogin.com/api-docs/1/users/create-user)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
onelogin,
12+
firstname: {
13+
propDefinition: [
14+
onelogin,
15+
"firstname",
16+
],
17+
},
18+
lastname: {
19+
propDefinition: [
20+
onelogin,
21+
"lastname",
22+
],
23+
},
24+
email: {
25+
propDefinition: [
26+
onelogin,
27+
"email",
28+
],
29+
optional: true,
30+
},
31+
username: {
32+
propDefinition: [
33+
onelogin,
34+
"username",
35+
],
36+
optional: true,
37+
},
38+
company: {
39+
propDefinition: [
40+
onelogin,
41+
"company",
42+
],
43+
optional: true,
44+
},
45+
department: {
46+
propDefinition: [
47+
onelogin,
48+
"department",
49+
],
50+
optional: true,
51+
},
52+
directoryId: {
53+
propDefinition: [
54+
onelogin,
55+
"directoryId",
56+
],
57+
optional: true,
58+
},
59+
distinguishedName: {
60+
propDefinition: [
61+
onelogin,
62+
"distinguishedName",
63+
],
64+
optional: true,
65+
},
66+
externalId: {
67+
propDefinition: [
68+
onelogin,
69+
"externalId",
70+
],
71+
optional: true,
72+
},
73+
groupId: {
74+
propDefinition: [
75+
onelogin,
76+
"groupId",
77+
],
78+
optional: true,
79+
},
80+
invalidLoginAttempts: {
81+
propDefinition: [
82+
onelogin,
83+
"invalidLoginAttempts",
84+
],
85+
optional: true,
86+
},
87+
localeCode: {
88+
propDefinition: [
89+
onelogin,
90+
"localeCode",
91+
],
92+
optional: true,
93+
},
94+
memberOf: {
95+
propDefinition: [
96+
onelogin,
97+
"memberOf",
98+
],
99+
optional: true,
100+
},
101+
openidName: {
102+
propDefinition: [
103+
onelogin,
104+
"openidName",
105+
],
106+
optional: true,
107+
},
108+
phone: {
109+
propDefinition: [
110+
onelogin,
111+
"phone",
112+
],
113+
optional: true,
114+
},
115+
samaccountname: {
116+
propDefinition: [
117+
onelogin,
118+
"samaccountname",
119+
],
120+
optional: true,
121+
},
122+
title: {
123+
propDefinition: [
124+
onelogin,
125+
"title",
126+
],
127+
optional: true,
128+
},
129+
customAttributes: {
130+
propDefinition: [
131+
onelogin,
132+
"customAttributes",
133+
],
134+
optional: true,
135+
},
136+
},
137+
async run({ $ }) {
138+
if (!this.email && !this.username) {
139+
throw new Error("Either email or username must be provided.");
140+
}
141+
142+
const userData = {
143+
firstname: this.firstname,
144+
lastname: this.lastname,
145+
...(this.email
146+
? {
147+
email: this.email,
148+
}
149+
: {}),
150+
...(this.username
151+
? {
152+
username: this.username,
153+
}
154+
: {}),
155+
...(this.company != null
156+
? {
157+
company: this.company,
158+
}
159+
: {}),
160+
...(this.department != null
161+
? {
162+
department: this.department,
163+
}
164+
: {}),
165+
...(this.directoryId != null
166+
? {
167+
directory_id: this.directoryId,
168+
}
169+
: {}),
170+
...(this.distinguishedName != null
171+
? {
172+
distinguished_name: this.distinguishedName,
173+
}
174+
: {}),
175+
...(this.externalId != null
176+
? {
177+
external_id: this.externalId,
178+
}
179+
: {}),
180+
...(this.groupId != null
181+
? {
182+
group_id: parseInt(this.groupId, 10),
183+
}
184+
: {}),
185+
...(this.invalidLoginAttempts != null
186+
? {
187+
invalid_login_attempts: this.invalidLoginAttempts,
188+
}
189+
: {}),
190+
...(this.localeCode != null
191+
? {
192+
locale_code: this.localeCode,
193+
}
194+
: {}),
195+
...(this.memberOf != null
196+
? {
197+
member_of: this.memberOf,
198+
}
199+
: {}),
200+
...(this.openidName != null
201+
? {
202+
openid_name: this.openidName,
203+
}
204+
: {}),
205+
...(this.phone != null
206+
? {
207+
phone: this.phone,
208+
}
209+
: {}),
210+
...(this.samaccountname != null
211+
? {
212+
samaccountname: this.samaccountname,
213+
}
214+
: {}),
215+
...(this.title != null
216+
? {
217+
title: this.title,
218+
}
219+
: {}),
220+
...(this.customAttributes != null
221+
? {
222+
custom_attributes: this.customAttributes,
223+
}
224+
: {}),
225+
};
226+
227+
const response = await this.onelogin.createUser(userData);
228+
229+
$.export("$summary", `Created user ${response.username} with ID ${response.id}`);
230+
return response;
231+
},
232+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import onelogin from "../../onelogin.app.mjs";
2+
3+
export default {
4+
key: "onelogin-revoke-user-sessions",
5+
name: "Revoke User Sessions",
6+
description: "Revokes all active sessions for a specified user in OneLogin. [See the documentation]()",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
onelogin,
11+
revokeUserId: {
12+
propDefinition: [
13+
onelogin,
14+
"revokeUserId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.onelogin.revokeUserSessions(this.revokeUserId);
20+
$.export("$summary", `Successfully revoked sessions for user ID ${this.revokeUserId}`);
21+
return response;
22+
},
23+
};

0 commit comments

Comments
 (0)