Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions components/pingone/actions/create-user/create-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import app from "../../pingone.app.mjs";

export default {
key: "pingone-create-user",
name: "Create User",
description: "Creates a new user in PingOne. [See the documentation](https://apidocs.pingidentity.com/pingone/platform/v1/api/#post-create-user).",
version: "0.0.1",
type: "action",
props: {
app,
username: {
propDefinition: [
app,
"username",
],
},
email: {
propDefinition: [
app,
"email",
],
},
givenName: {
propDefinition: [
app,
"givenName",
],
},
familyName: {
propDefinition: [
app,
"familyName",
],
},
department: {
propDefinition: [
app,
"department",
],
},
locales: {
propDefinition: [
app,
"locales",
],
},
},
methods: {
createUser(args = {}) {
return this.app.post({
path: "/users",
...args,
});
},
},
async run({ $ }) {
const {
createUser,
username,
email,
givenName,
familyName,
department,
locales,
} = this;

const response = await createUser({
$,
data: {
username,
email,
name: {
given: givenName,
family: familyName,
},
department,
locales,
},
});

$.export("$summary", "Successfully created user.");
return response;
},
};
93 changes: 93 additions & 0 deletions components/pingone/actions/update-user/update-user.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import app from "../../pingone.app.mjs";

export default {
key: "pingone-update-user",
name: "Update User in PingOne",
description: "Update an existing user's attributes in PingOne. [See the documentation](https://apidocs.pingidentity.com/pingone/platform/v1/api/#patch-update-user).",
version: "0.0.1",
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
username: {
optional: false,
propDefinition: [
app,
"username",
],
},
email: {
propDefinition: [
app,
"email",
],
},
givenName: {
propDefinition: [
app,
"givenName",
],
},
familyName: {
propDefinition: [
app,
"familyName",
],
},
department: {
propDefinition: [
app,
"department",
],
},
locales: {
propDefinition: [
app,
"locales",
],
},
},
methods: {
updateUser({
userId, ...args
} = {}) {
return this.app.patch({
path: `/users/${userId}`,
...args,
});
},
},
async run({ $ }) {
const {
updateUser,
userId,
username,
email,
givenName,
familyName,
department,
locales,
} = this;

const response = await updateUser({
$,
userId,
data: {
username,
email,
givenName,
familyName,
department,
locales,
},
});

$.export("$summary", "Successfully updated user.");
return response;
},
};
11 changes: 11 additions & 0 deletions components/pingone/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const BASE_URL = "https://api.pingone.com";
const VERSION_PATH = "/v1";
const ENV_PATH = "/environments";
const SUBSCRIPTION_ID = "subscriptionId";

export default {
BASE_URL,
VERSION_PATH,
ENV_PATH,
SUBSCRIPTION_ID,
};
188 changes: 184 additions & 4 deletions components/pingone/pingone.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,191 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure safe handling of sensitive data in debug logs
Setting debug: true in _makeRequest() (line 149) could potentially log sensitive information. Make sure no confidential data (like OAuth tokens or user PII) is exposed in the logs.


export default {
type: "app",
app: "pingone",
propDefinitions: {},
propDefinitions: {
username: {
type: "string",
label: "Username",
description: "The user's username. This must either be a well-formed email address or another unique identifier.",
},
email: {
type: "string",
label: "Email",
description: "The user's email address.",
optional: true,
},
givenName: {
type: "string",
label: "First Name",
description: "The user's first name.",
optional: true,
},
familyName: {
type: "string",
label: "Last Name",
description: "The user's last name.",
optional: true,
},
department: {
type: "string",
label: "Department",
description: "The user's department. E.g., `Engineering`.",
optional: true,
},
locales: {
type: "string[]",
label: "Locales",
description: "The user's locales. E.g., `London`.",
optional: true,
async options({ prevContext: { url } }) {
if (url === null) {
return [];
}
const {
_embedded: { languages },
_links: { next },
} = await this.listLanguages({
url,
});
return {
options: languages.map(({ name }) => name),
context: {
url: next?.href || null,
},
};
},
},
userId: {
type: "string",
label: "User ID",
description: "The unique identifier for the user.",
async options({ prevContext: { url } }) {
if (url === null) {
return [];
}
const {
_embedded: { users },
_links: { next },
} = await this.listUsers({
url,
});
return {
options: users.map(({
id: value, username: label,
}) => ({
label,
value,
})),
context: {
url: next?.href || null,
},
};
},
},
applicationId: {
type: "string",
label: "Application ID",
description: "The unique identifier for the application.",
async options({ prevContext: { url } }) {
if (url === null) {
return [];
}
const {
_embedded: { applications },
_links: { next },
} = await this.listApplications({
url,
});
return {
options: applications.map(({
id: value, name: label,
}) => ({
label,
value,
})),
context: {
url: next?.href || null,
},
};
},
},
userAttributes: {
type: "object",
label: "User Attributes",
description: "The attributes to update the user with.",
optional: true,
},
groupId: {
type: "string",
label: "Group ID",
description: "The unique identifier for the group.",
optional: true,
},
status: {
type: "string",
label: "User Status",
description: "The current status of the user, e.g., active, inactive.",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${constants.BASE_URL}${constants.VERSION_PATH}${constants.ENV_PATH}/${this.$auth.environment_id}${path}`;
},
getHeaders(headers) {
return {
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
...headers,
};
},
_makeRequest({
$ = this, url, path, headers, ...args
} = {}) {
return axios($, {
...args,
debug: true,
url: url || this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
patch(args = {}) {
return this._makeRequest({
method: "PATCH",
...args,
});
},
delete(args = {}) {
return this._makeRequest({
method: "DELETE",
...args,
});
},
listUsers(args = {}) {
return this._makeRequest({
path: "/users",
...args,
});
},
listApplications(args = {}) {
return this._makeRequest({
path: "/applications",
...args,
});
},
listLanguages(args = {}) {
return this._makeRequest({
path: "/languages",
...args,
});
},
},
};
Loading
Loading