Skip to content

Commit 48171a0

Browse files
luancazarinecoderabbitai[bot]michelle0927
authored
New Components - okta (#12439)
* okta init * [Components] okta #12420 Polling Sources - Watch New Events Actions - Create User - Get User - Update User * pnpm update * Update components/okta/actions/create-user/create-user.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update components/okta/sources/watch-new-events/watch-new-events.mjs Co-authored-by: michelle0927 <[email protected]> * remove utils.mjs --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: michelle0927 <[email protected]>
1 parent 84fd522 commit 48171a0

File tree

9 files changed

+613
-8
lines changed

9 files changed

+613
-8
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import okta from "../../okta.app.mjs";
3+
4+
export default {
5+
key: "okta-create-user",
6+
name: "Create User",
7+
description: "Creates a new user in the Okta system. [See the documentation](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/User/#tag/User/operation/createUser)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
okta,
12+
activate: {
13+
type: "boolean",
14+
label: "Activate",
15+
description: "Executes activation lifecycle operation when creating the user. Defaults to true.",
16+
optional: true,
17+
},
18+
firstName: {
19+
propDefinition: [
20+
okta,
21+
"firstName",
22+
],
23+
},
24+
lastName: {
25+
propDefinition: [
26+
okta,
27+
"lastName",
28+
],
29+
},
30+
email: {
31+
propDefinition: [
32+
okta,
33+
"email",
34+
],
35+
},
36+
login: {
37+
propDefinition: [
38+
okta,
39+
"login",
40+
],
41+
},
42+
mobilePhone: {
43+
propDefinition: [
44+
okta,
45+
"mobilePhone",
46+
],
47+
optional: true,
48+
},
49+
typeId: {
50+
propDefinition: [
51+
okta,
52+
"typeId",
53+
],
54+
optional: true,
55+
},
56+
},
57+
async run({ $ }) {
58+
try {
59+
const {
60+
okta,
61+
activate,
62+
typeId,
63+
...profile
64+
} = this;
65+
66+
const data = {
67+
profile,
68+
};
69+
70+
if (typeId) {
71+
data.type = {
72+
id: this.typeId,
73+
};
74+
}
75+
76+
const response = await okta.createUser({
77+
$,
78+
data,
79+
params: {
80+
activate,
81+
},
82+
});
83+
84+
$.export("$summary", `Successfully created user with ID ${response.id}`);
85+
return response;
86+
} catch ({ message }) {
87+
const messageError = JSON.parse(message);
88+
throw new ConfigurationError(messageError.errorCauses.length
89+
? messageError.errorCauses[0].errorSummary
90+
: messageError.errorSummary);
91+
}
92+
},
93+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import okta from "../../okta.app.mjs";
2+
3+
export default {
4+
key: "okta-get-user",
5+
name: "Get User",
6+
description: "Fetches the information of a specific user from the Okta system. [See the documentation](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/User/#tag/User/operation/getUser)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
okta,
11+
userId: {
12+
propDefinition: [
13+
okta,
14+
"userId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.okta.getUser({
20+
$,
21+
userId: this.userId,
22+
});
23+
$.export("$summary", `Successfully fetched user details for user ID ${this.userId}`);
24+
return response;
25+
},
26+
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import okta from "../../okta.app.mjs";
2+
3+
export default {
4+
key: "okta-update-user",
5+
name: "Update User",
6+
description: "Updates the profile of a specific user in the Okta system. [See the documentation](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/User/#tag/User/operation/updateUser)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
okta,
11+
userId: {
12+
propDefinition: [
13+
okta,
14+
"userId",
15+
],
16+
},
17+
firstName: {
18+
propDefinition: [
19+
okta,
20+
"firstName",
21+
],
22+
optional: true,
23+
},
24+
lastName: {
25+
propDefinition: [
26+
okta,
27+
"lastName",
28+
],
29+
optional: true,
30+
},
31+
email: {
32+
propDefinition: [
33+
okta,
34+
"email",
35+
],
36+
optional: true,
37+
},
38+
login: {
39+
propDefinition: [
40+
okta,
41+
"login",
42+
],
43+
optional: true,
44+
},
45+
mobilePhone: {
46+
propDefinition: [
47+
okta,
48+
"mobilePhone",
49+
],
50+
optional: true,
51+
},
52+
typeId: {
53+
propDefinition: [
54+
okta,
55+
"typeId",
56+
],
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const {
62+
okta,
63+
userId,
64+
typeId,
65+
...profile
66+
} = this;
67+
68+
const { profile: userProfile } = await okta.getUser({
69+
userId,
70+
});
71+
72+
const response = await okta.updateUser({
73+
$,
74+
userId,
75+
data: {
76+
profile: {
77+
...userProfile,
78+
...profile,
79+
},
80+
...(typeId
81+
? {
82+
type: {
83+
id: this.typeId,
84+
},
85+
} :
86+
{}),
87+
},
88+
});
89+
90+
$.export("$summary", `Successfully updated user with ID ${userId}`);
91+
return response;
92+
},
93+
};

components/okta/common/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const LIMIT = 1000;

0 commit comments

Comments
 (0)