Skip to content

Instantly share code, notes, and snippets.

@cmaggiulli
Last active April 1, 2019 20:22
Show Gist options
  • Save cmaggiulli/20b147872fde43d8e7f941d3f088cab1 to your computer and use it in GitHub Desktop.
Save cmaggiulli/20b147872fde43d8e7f941d3f088cab1 to your computer and use it in GitHub Desktop.
Groovy script to export all IAR files from Oracle Integration Cloud
#!/usr/bin/env groovy
/*
* This script exports all Oracle Inegration Cloud integrations
* Example execution command below
* groovy export-iar.groovy https://My-Oracle-URL.com MyUsername MyPassword
* Author: Chris Maggiulli
* Email: [email protected]
*/
@Grapes([
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1'),
@Grab(group='org.codehaus.groovy', module='groovy-json', version='2.0.1')
])
import groovyx.net.http.*
import groovy.json.*
def base = args[0], user = args[1], pass = args[2]
def integrations = [:]
def http = new HTTPBuilder(base)
http.auth.basic user, pass
http.ignoreSSLIssues()
http.request(Method.GET, ContentType.JSON) {
uri.path = "/ic/api/integration/v1/integrations"
headers.'Accept' = 'application/json'
response.success = { resp, json ->
json.items.each{ item ->
integrations["${item.name}.iar"] = item.id
}
}
response.failure = { resp, reader ->
println "[x] Failed to retreive integration list"
println "[x] ${resp.statusLine}"
println "[x] ${reader.statusLine}"
}
}
integrations.each{ k, v ->
http.request(Method.GET, ContentType.BINARY) {
uri.path = "/ic/api/integration/v1/integrations/${v}/archive"
response.success = { resp, binary ->
def dst = new File("${k}")
dst << binary.bytes
}
response.failure = { resp, reader ->
println "[x] Failed to export ${k}"
println "[x] ${resp.statusLine}"
println "[x] ${reader.statusLine}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment