サンプルコード
@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.message.* import org.apache.http.auth.* import groovy.json.* def host = "192.168.1.240" // replace this def port = 7180 def user = "admin" def password = "admin" def httpclient = new DefaultHttpClient() httpclient.getCredentialsProvider().setCredentials( new AuthScope(host, port), new UsernamePasswordCredentials(user, password) ) def method = new HttpGet("http://${host}:${port}/api/v7/clusters") def response = httpclient.execute(method) println response.getStatusLine().getStatusCode() def json = new JsonSlurper().parseText(response.getEntity().getContent().text) for(item in json.items){ println "name:${item.name}" println "display name:${item.displayName}" println "full version:${item.fullVersion}" }参考情報
/clusters - Cloudera Manager API v7
0 件のコメント:
コメントを投稿