サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5') import org.apache.http.client.methods.* import org.apache.http.impl.client.* import org.apache.http.auth.* import groovy.json.* def host = "localhost" def port = 12000 def httpclient = new DefaultHttpClient() def method = new HttpGet("http://${host}:${port}/sqoop/v1/connection/all") response = httpclient.execute(method) println response.getStatusLine().getStatusCode() def json = new JsonSlurper().parseText(response.getEntity().getContent().text) //println json for(conn in json.all){ println "id:${conn.id}, name:${conn.name}, connector id:${conn."connector-id"}" }動作環境
groovy 2.3.6, JDK7 update67, Cloudera CDH 5.1.2
0 件のコメント:
コメントを投稿