(Supporting Network Advisor 12.3.0)
Table Of Contents
- Contents
- About This Document
- Overview of the Network Advisor REST API
- Getting Started
- Using the Brocade Network Advisor REST API
- Introduction
- Logging in and out
- Specifying content type
- Versioning (backward compatibility)
- Using the Topology API
- Using the SAN Fabric Discovery API
- Using the Traffic Flow API
- Using the Summary Data API
- Using the Events API
- Using the Zoning API
- Using the Historical Performance Data API
- Fibre Channel Routing
- Handling errors
- Use Cases
- API Reference
- Request and Response Schemas
- Topology
- SAN fabric discovery
- Summary data
- SummaryResponse
- StatusSummary
- AssetClassificationSummary
- NetworkObjectCountSummary
- EventsSummary
- BottleneckViolationsSummary
- OutOfRangeViolationsSummary
- PortHealthViolationsSummary
- VmViolationsSummary
- SummariesResponse
- PortsMonitorSummaryData
- MonitorDistributionData
- ProductsMonitorSummaryData
- FlowMonitorSummaryData
- Events
- Zoning
- Historical performance data
- Authentication and session management
48 Brocade Network Advisor REST API Guide
53-1003160-01
Binding the schema
4
System.out.println("CALLING POST
http://10.24.48.103/rest/resourcegroups/All/fcfabrics/10:00:00:05:1E:40:40:00/del
etefabric");
/**
* Make the HTTP call
*/
int responseCode = con.getResponseCode();
System.out.println("Response code is " + responseCode);
if (HttpURLConnection.HTTP_NO_CONTENT != responseCode) {
PRINT_ERROR(con);
assert false : "Delete Fabric FAILED, responseCode = " + responseCode;
}
} catch (IOException ie) {
System.out.println(ie.toString());
} finally {
if (null != con) {
con.disconnect();
}
}
Binding the schema
Most of the POST operations supported by the Network Advisor REST API require input data. This
data is passed in the form of an XML payload.
To access the XML payload using Java, this example uses the Java Architecture for XML (JAXB)
binding. JAXB simplifies access to an XML document from a Java program by presenting the XML
document to the program in a Java format. As part of the JAXB framework, JAXB provides APIs for
unmarshaling and marshalling XML data.
To bind the schema, perform the following steps.
1. Unmarshal the XML data into a Java object, as shown in the following Java code example.
JAXBContext jaxbContext =
JAXBContext.newInstance(InitiatorTargetsRequest.class);
Unmarshaller u = jaxbContext.createUnmarshaller();
Object element = u.unmarshal(new File("./InitiatorTargetsRequest.xml"));
In this example, you can see that in order to unmarshal the XML data into Java objects, you
first need the Java class that represents the XML data, meaning binding the XML schema to
the Java class. That means that you need to generate the set of Java classes that represent the
REST XML schema.
2. Marshal the jaxbContext object into the HttpURLConnection output stream, as shown in the
following Java code example.
Marshaller m = jaxbContext.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(element, con.getOutputStream());
The REST schema is published in the directory <INSTALL-DIR>/conf/rest-schema, where
<INSTALL-DIR> is the Network Advisor installation directory.
In this example, the standard JDK’s xjc application which is the XML-to-Java compiler was used to
generate the needed Java classes from the REST XML schema (xjc is included as part of JDK since
Java SE 6). Shown below is the ant target to use xjc to generate the java artifacts.