Skip to content

Instantly share code, notes, and snippets.

@dhonig
Created June 5, 2012 23:15
Show Gist options
  • Save dhonig/2878734 to your computer and use it in GitHub Desktop.
Save dhonig/2878734 to your computer and use it in GitHub Desktop.
Attempt to deploy to ION
import static groovyx.net.http.ContentType.JSON
import groovyx.net.http.RESTClient
import static groovyx.net.http.Method.GET
import static groovyx.net.http.Method.PUT
import static groovyx.net.http.ContentType.TEXT
import static groovyx.net.http.ContentType.URLENC
@Grab(group = 'org.codehaus.groovy.modules.http-builder',
module = 'http-builder', version = '0.5.2')
def appName = "devion"
def username = "tfm-ion"
def password = "BuffaloNickle1"
def ionEndpoint = "https://muleion.com/api/"
def http = new groovyx.net.http.HTTPBuilder(ionEndpoint)
http.auth.basic(username, password)
http.encoder.'application/zip' = this.&encodeZipFile
def file = new File("../../../target/franklinmintflows-1.0-SNAPSHOT.zip")
//http.encoder.'application/zip' = this.&encodeZipFile
http.post( path: "applications/devion/deploy", body: file, requestContentType: 'application/zip' )
def encodeZipFile( Object data ) throws UnsupportedEncodingException {
if ( data instanceof File ) {
def entity = new org.apache.http.entity.FileEntity( (File) data, "application/zip" );
entity.setContentType( "application/zip" );
return entity
} else {
throw new IllegalArgumentException(
"Don't know how to encode ${data.class.name} as a zip file" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment