Azure profiles builder
@fdelosrios
code:
data:privatelast updated:5 months ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
Cron Scheduler
Deploy to configure a custom schedule
This workflow runs on Pipedream's servers and is triggered on a custom schedule.
steps.
input
auth
to use OAuth tokens and API keys in code via theauths object
params
Mode
string ·params.mode
Query
attribute:assignedPlans
string ·params.query
Owner
slpt.services
string ·params.owner
AccessRequestConfig
{{{commentsRequired: false, denialCommentsRequired: false, approvalSchemes: [{approverType: "MANAGER"}]}}}
string ·params.accessRequestConfig
ApplicationId
{{null}}
string ·params.applicationId
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
}
14
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
steps.
get_service_plans
Make an HTTP or webhook request and return the response as a step export.
params
URL
https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv
string ·params.url
Optional
code
async params => {
1
2
3
4
5
6
7
8
9
10
11
}
12
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)
steps.
parse_service_plans
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
}
4
const papa = require('papaparse')
return papa.parse(steps.get_service_plans.$return_value, { header: true })
steps.
get_idn_token
Make an HTTP or webhook request and return the response as a step export.
auth
(auths.http)
params
URL
https://{{process.env.idn_org}}/oauth/token
string ·params.url
Method
string ·params.method
Query

Add query parameters as key-value pairs

grant_type
client_credentials
client_id
{{process.env.idn_client_id}}
client_secret
{{process.env.idn_client_secret}}
object ·params.query
Headers

Add headers as key-value pairs

Content-Type
application/json
object ·params.headers
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
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)
steps.
remove_access_profiles
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/beta/access-profiles/
string ·params.url
Method
string ·params.method
Headers

Add headers as key-value pairs

Content-Type
application/json
Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
object ·params.headers
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
}
30
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.`)
}
steps.
get_entitlements
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/v3/search
string ·params.url
Data
query
{{{query : steps.input.query}}}
sort
{{[ "name" ]}}
indices
{{[ "entitlements" ]}}
includeNested
{{false}}
object ·params.data
Method
string ·params.method
Query
limit
1000
object ·params.query
Headers

Add headers as key-value pairs

Content-Type
application/json
Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
object ·params.headers
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
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)
steps.
get_sources
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/beta/sources
string ·params.url
Method
string ·params.method
Headers

Add headers as key-value pairs

Content-Type
application/json
Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
object ·params.headers
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
}
12
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)
steps.
get_owner
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/v3/search
string ·params.url
Data
query
{{{query: `name.exact: ${steps.input.owner}`}}}
indices
{{[ "identities" ]}}
includeNested
{{false}}
object ·params.data
Method
string ·params.method
Headers

Add headers as key-value pairs

Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
Content-Type
application/json
object ·params.headers
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
}
11
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)
steps.
create_access_profiles
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/beta/access-profiles
string ·params.url
Method
string ·params.method
Headers

Add headers as key-value pairs

Content-Type
application/json
Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
object ·params.headers
Data

Data to be sent as the request body

name
 
value
description
 
value
owner
{{{type: "IDENTITY", id: steps.get_owner.$return_value[0].id, name: steps.input.owner}}}
entitlements
 
value
accessRequestConfig
{{steps.input.accessRequestConfig}}
enabled
true
requestable
true
object ·params.data
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
}
69
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.`)
}
steps.
update_application
auth
to use OAuth tokens and API keys in code via theauths object
params
URL
https://{{process.env.idn_org}}/cc/api/app/update/{{steps.input.applicationId}}
string ·params.url
Method
string ·params.method
Headers

Add headers as key-value pairs

Content-Type
application/json
Authorization
Bearer {{steps.get_idn_token.$return_value.access_token}}
object ·params.headers
Data

Data to be sent as the request body

accessProfileIds
 
value
object ·params.data
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
}
24
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')
}