サンプルコード
@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/connector/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}, class:${conn.class}" }動作環境
Cloudera CDH 5.1.2
0 件のコメント:
コメントを投稿