forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tested components (PipedreamHQ#12074)
- Loading branch information
Showing
11 changed files
with
604 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import app from "../../keycloak.app.mjs"; | ||
|
||
export default { | ||
key: "keycloak-create-user", | ||
name: "Create User", | ||
description: "Create a new user in Keycloak. The username must be unique. [See the documentation](https://www.keycloak.org/docs-api/latest/rest-api/index.html#_users)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
realm: { | ||
propDefinition: [ | ||
app, | ||
"realm", | ||
], | ||
}, | ||
username: { | ||
type: "string", | ||
label: "Username", | ||
description: "The username of the user.", | ||
}, | ||
firstName: { | ||
propDefinition: [ | ||
app, | ||
"firstName", | ||
], | ||
}, | ||
lastName: { | ||
propDefinition: [ | ||
app, | ||
"lastName", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
emailVerified: { | ||
propDefinition: [ | ||
app, | ||
"emailVerified", | ||
], | ||
}, | ||
enabled: { | ||
propDefinition: [ | ||
app, | ||
"enabled", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
createUser({ | ||
realm, ...args | ||
} = {}) { | ||
return this.app.post({ | ||
path: `/admin/realms/${realm}/users`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
createUser, | ||
realm, | ||
...data | ||
} = this; | ||
|
||
await createUser({ | ||
$, | ||
realm, | ||
data, | ||
}); | ||
|
||
$.export("$summary", "Successfully created user."); | ||
|
||
return { | ||
success: true, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import app from "../../keycloak.app.mjs"; | ||
|
||
export default { | ||
key: "keycloak-delete-user", | ||
name: "Delete User", | ||
description: "Delete a user from Keycloak. [See the documentation](https://www.keycloak.org/docs-api/latest/rest-api/index.html#_users)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
realm: { | ||
propDefinition: [ | ||
app, | ||
"realm", | ||
], | ||
}, | ||
userId: { | ||
propDefinition: [ | ||
app, | ||
"userId", | ||
({ realm }) => ({ | ||
realm, | ||
}), | ||
], | ||
}, | ||
}, | ||
methods: { | ||
deleteUser({ | ||
realm, userId, ...args | ||
} = {}) { | ||
return this.app.delete({ | ||
path: `/admin/realms/${realm}/users/${userId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
deleteUser, | ||
realm, | ||
userId, | ||
} = this; | ||
|
||
await deleteUser({ | ||
$, | ||
realm, | ||
userId, | ||
}); | ||
|
||
$.export("$summary", "Successfully deleted user."); | ||
|
||
return { | ||
success: true, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import app from "../../keycloak.app.mjs"; | ||
|
||
export default { | ||
key: "keycloak-get-user", | ||
name: "Get User", | ||
description: "Retrieve the representation of the user. [See the documentation](https://www.keycloak.org/docs-api/latest/rest-api/index.html#_users)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
realm: { | ||
propDefinition: [ | ||
app, | ||
"realm", | ||
], | ||
}, | ||
userId: { | ||
propDefinition: [ | ||
app, | ||
"userId", | ||
({ realm }) => ({ | ||
realm, | ||
}), | ||
], | ||
}, | ||
}, | ||
methods: { | ||
getUser({ | ||
realm, userId, ...args | ||
} = {}) { | ||
return this.app._makeRequest({ | ||
path: `/admin/realms/${realm}/users/${userId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
getUser, | ||
realm, | ||
userId, | ||
} = this; | ||
|
||
const response = await getUser({ | ||
$, | ||
realm, | ||
userId, | ||
}); | ||
$.export("$summary", `Successfully retrieved user with ID \`${response.id}\`.`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* eslint-disable no-unused-vars */ | ||
import app from "../../keycloak.app.mjs"; | ||
|
||
export default { | ||
key: "keycloak-update-user", | ||
name: "Update User", | ||
description: "Updates a user in Keycloak. [See the documentation](https://www.keycloak.org/docs-api/latest/rest-api/index.html#_users)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
realm: { | ||
propDefinition: [ | ||
app, | ||
"realm", | ||
], | ||
}, | ||
userId: { | ||
propDefinition: [ | ||
app, | ||
"userId", | ||
({ realm }) => ({ | ||
realm, | ||
}), | ||
], | ||
}, | ||
firstName: { | ||
propDefinition: [ | ||
app, | ||
"firstName", | ||
], | ||
}, | ||
lastName: { | ||
propDefinition: [ | ||
app, | ||
"lastName", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
emailVerified: { | ||
propDefinition: [ | ||
app, | ||
"emailVerified", | ||
], | ||
}, | ||
enabled: { | ||
propDefinition: [ | ||
app, | ||
"enabled", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
updateUser({ | ||
realm, userId, ...args | ||
} = {}) { | ||
return this.app.put({ | ||
path: `/admin/realms/${realm}/users/${userId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
app, | ||
updateUser, | ||
realm, | ||
userId, | ||
...data | ||
} = this; | ||
|
||
await updateUser({ | ||
$, | ||
realm, | ||
userId, | ||
data, | ||
}); | ||
|
||
$.export("$summary", "Successfully updated user."); | ||
|
||
return { | ||
success: true, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const DEFAULT_LIMIT = 100; | ||
const DEFAULT_MAX = 600; | ||
const LAST_DATE_FROM = "dateFrom"; | ||
|
||
export default { | ||
DEFAULT_LIMIT, | ||
DEFAULT_MAX, | ||
LAST_DATE_FROM, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
async function iterate(iterations) { | ||
const items = []; | ||
for await (const item of iterations) { | ||
items.push(item); | ||
} | ||
return items; | ||
} | ||
|
||
export default { | ||
iterate, | ||
}; |
Oops, something went wrong.