Last active
June 15, 2018 21:44
-
-
Save cmaggiulli/0b7c4cb156ee9747efb72ea354efe0c0 to your computer and use it in GitHub Desktop.
A Groovy script to facility mass deactivating of process applications in Oracle Integration Cloud. The script can be used to deactivate all revisions of a given project. Please see header comments for usage instructions. Please do not use on production environment, as deactivating an application will truncate all the runtime data associated with…
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
#!/usr/bin/env groovy | |
/* | |
* This script undeploys all revisions of a particular project as specified in the command line arguments | |
* Example execution command below | |
* groovy deactivate.groovy https://My-Oracle-URL.com MyProject MyUsername MyPassword | |
* Author: Chris Maggiulli | |
* Email: cmaggiulli@gmail.com | |
*/ | |
@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] | |
def project = args[1] | |
def user = args[2] | |
def pass = args[3] | |
def http = new HTTPBuilder(base) | |
http.auth.basic user, pass | |
http.setHeaders(['Accept':'application/json']) | |
http.ignoreSSLIssues() | |
undeploy(base, project, getRevisions(base, project, http), http) | |
def undeploy(base, projectId, targetId = 'ORACLEINTERNALPCS', revisions, https) { | |
revisions.each{ revision -> | |
https.request(Method.DELETE, ContentType.TEXT) { | |
uri.path = "/ic/api/process/v1/targets/${targetId}/projects/${projectId}/revisions/${revision}" | |
response.success = { resp -> | |
println "[x] Successfully undeployed project ${projectId} at revision ${revision}" | |
} | |
response.failure = { resp -> | |
println "[x] Failured to undeploy project ${projectId} at revision ${revision}" | |
} | |
} | |
} | |
} | |
def getRevisions(base, projectId, targetId = 'ORACLEINTERNALPCS', https) { | |
def revisions = [] | |
https.request(Method.GET, ContentType.TEXT) { | |
uri.path = "/ic/api/process/v1/targets/${targetId}/projects/${projectId}/revisions" | |
response.success = { resp, reader -> | |
def json = new JsonSlurper().parseText(reader.text) | |
json.items.each{ item -> | |
revisions.add(item.revisionId) | |
} | |
} | |
response.failure = { resp, reader -> | |
println "[x] Failured to get revision for project ${projectId}" | |
} | |
} | |
return revisions | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment