auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const { mode } = params
const { query } = params
const { owner } = params
const { accessRequestConfig } = params
const { applicationId } = params
this.mode = params.mode
this.query = params.query
this.owner = params.owner
this.accessRequestConfig = params.accessRequestConfig
this.applicationId = params.applicationId
async
params => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType,
data: params.data,
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
const papa = require('papaparse')
return papa.parse(steps.get_service_plans.$return_value, { header: true })
Add query parameters as key-value pairs
Add headers as key-value pairs
async
(params, auths) => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType,
data: params.data,
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
auths
objectAdd headers as key-value pairs
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType
}
if (steps.input.mode == "remove") {
const pd = require("@pipedreamhq/platform")
if ($checkpoint) {
for (i in $checkpoint) {
config.url = params.url + i
console.log(`Deleting AP ${$checkpoint[i]}`)
try {
let ap = await pd.axios(this, config)
delete $checkpoint[i]
console.log("Successfully deleted.")
} catch (e) {
console.log(e.message)
}
}
}
$end("Finished deleting access profiles.")
} else {
console.log(`Mode is not remove. Skipping.`)
}
auths
objectAdd headers as key-value pairs
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType,
data: params.data
}
return await require("@pipedreamhq/platform").axios(this, config)
auths
objectAdd headers as key-value pairs
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
headers: params.headers,
responseType: params.responseType,
data: params.data,
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
auths
objectAdd headers as key-value pairs
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
headers: params.headers,
responseType: params.responseType,
data: params.data
}
if (params.auth) config.auth = params.auth
return await require("@pipedreamhq/platform").axios(this, config)
auths
objectAdd headers as key-value pairs
Data to be sent as the request body
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType,
data: params.data,
}
const capitalize = (str) => {
return str.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase())
}
if (steps.input.mode == "add") {
const pd = require("@pipedreamhq/platform")
let checkpoint = []
if (! $checkpoint) {
$checkpoint = {}
} else {
for (let i in $checkpoint) checkpoint.push($checkpoint[i])
}
for (entitlement of steps.get_entitlements.$return_value) {
console.log(`Evaluating ${entitlement.name}...`)
let product_serviceplan = entitlement.name.split(' : ')
let product = product_serviceplan[0]
if (product == 'DEVELOPERPACK_E5') product = 'SPE_E5'
let serviceplan = product_serviceplan[1]
let info = steps.parse_service_plans.$return_value.data.filter(x => x['String_Id'] == product && x['Service_Plan_Name'] == serviceplan).pop()
let name
let description
if (info) {
console.log(`Found in service list`)
name = `${capitalize(info['Service_Plans_Included_Friendly_Names'])} (${info['Product_Display_Name']})`
description = `Service plan from ${entitlement.source.name}`
} else {
console.log(`Not found in service list`)
name = `${serviceplan} (${product})`
description = `Service plan from ${entitlement.source.name}`
}
console.log(`Name: ${name}`)
console.log(`Description: ${description}`)
config.data.name = name
if( checkpoint.indexOf(config.data.name) == -1 ) {
config.data.description = description
config.data.entitlements = [{id: entitlement.id,
type: "ENTITLEMENT",
name: entitlement.value}]
config.data.source = {id: entitlement.source.id,
type: "SOURCE",
name: entitlement.source.name}
console.log(`Creating AP ${config.data.name}.`)
try {
let ap = await pd.axios(this, config)
$checkpoint[ap.id] = ap.name
console.log("Successfully created.")
} catch (e) {
console.log(e.message)
}
} else {
console.log(`Skipping ${entitlement.name}.`)
}
}
} else {
console.log(`Mode is not add. Skipping.`)
}
auths
objectAdd headers as key-value pairs
Data to be sent as the request body
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const config = {
method: params.method,
url: params.url,
params: params.query,
headers: params.headers,
responseType: params.responseType,
data: params.data,
}
if (steps.input.applicationId) {
if ($checkpoint) {
let accessProfileIds = []
for (ap in $checkpoint) {
accessProfileIds.push(ap)
}
config.data.accessProfileIds = accessProfileIds
}
return await require("@pipedreamhq/platform").axios(this, config)
} else {
$end('Skipping application update')
}