12.07.2015 Views

Ridgeline 4.0 REST API Quick Start PDF - Extreme Networks

Ridgeline 4.0 REST API Quick Start PDF - Extreme Networks

Ridgeline 4.0 REST API Quick Start PDF - Extreme Networks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using the <strong>REST</strong> <strong>API</strong>new AuthScope(this.hostName, this.portNumber),new UsernamePasswordCredentials(this.userName,this.password));}try {HttpResponse httpResponse = client.execute(httpget);StatusLine status = httpResponse.getStatusLine();if (status.getStatusCode() == HttpStatus.SC_OK) {HttpEntity entity = httpResponse.getEntity();if (entity != null) {response = EntityUtils.toString(entity);}} else {response = httpResponse.toString();}} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {httpget.releaseConnection();}return response;private boolean isXML() {boolean isXML = false;if (this.Url.trim().endsWith(RestHttpClient.xmlExtension)) {isXML = true;}return isXML;}private String getFileName() {SimpleDateFormat formatter = newSimpleDateFormat("dd_MM_yyyy_HH_mm_ss");StringBuilder fileName = new StringBuilder(formatter.format(newDate()));fileName.append("_Rest_Get");fileName.append(isXML() ? RestHttpClient.xmlExtension: RestHttpClient.jsonExtension);}return fileName.toString();private void writeToFile() {BufferedWriter writer = null;try {writer = new BufferedWriter(new FileWriter(getFileName()));String response = httpGet();writer.write(response);} catch (IOException e) {e.printStackTrace();} finally {try {if (writer != null)writer.flush();<strong>Ridgeline</strong> <strong>4.0</strong> <strong>REST</strong> <strong>API</strong> <strong>Quick</strong> <strong>Start</strong> 20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!