Get All Topological Links Examples (Bulk Information Transfer)

Overview

GET /data/otn/networkinventory/alltopologicalinks request shall be used to retrieve list of all topological links stored in OMS

Here described is an example of Get All Topological Links

GET All Topological links

Below is code snippet to retrieve all the topological links.


public List<String> retrieveDataForTopologicalLinks (OMSRestTemplate restTemplate, String urlSuffix) {
	List<String> retData = new ArrayList <String>();

	/** Url to retrieve topological links json file*/
	String custUrl = restTemplate.getUrlPrefix() + urlSuffix;  //"/data/otn/networkinventory/alltopologicalinks";
	//?userid=ECmdKGhCKVqxOwMqdli62w==&password=zGwL2f+0s44QqnRUAhJSKQ==";

	/**retrieve json file path*/
	JsonNode response = restTemplate.getForObject(custUrl, JsonNode.class);

	System.out.println(" response : " + response);
	JsonNode respFiles = response.get("responseFiles");
	downloadFiles(restTemplate, retData, respFiles, ""); 

	return retData;
}

JSON Request


/data/otn/networkinventory/alltopologicalinks

JSON Response


{
	"responseHeader": {
		"originatorApp": "NPT",
		"objectType": "topologicallinks",
		"objectScope": "OTS/OS",
		"responseStatus": "SUCCESS",
		"fileGenerationTime": "08/06/2016 18:02:41",
		"errorCode": null,
		"errorReason": null,
		"errorParams": null
	},
	"responseFiles": [
		"http://135.250.16.166/OTNE_12-14/data_extraction/npt/inventory/alltopologicallinks/topologicallinks.json"
	]
}

Download the JSON Response files

Below is code snippet to download the response json files.


/**
*
* Download all the json files.
*
* @param restTemplate - Spring Rest Template
* @param retData - Response data which is returned
* @param networkDataFileList - JSON Response files to be downloaded
* @param urlPrefix - OMS base path
*
*/
private void downloadFiles(OMSRestTemplate restTemplate, List<String> retData, JsonNode networkDataFileList, String urlPrefix) {
	String url;
	Iterator<JsonNode> it = networkDataFileList.iterator();

	/** Iterator over all the files and download*/
	while (it.hasNext ()) {
		String filePath = it.next().textValue();
		url = urlPrefix + filePath.replace("oms1350/", "") ;  //+ "?userid=ECmdKGhCKVqxOwMqdli62w==&password=zGwL2f+0s44QqnRUAhJSKQ==";

		System.out.println( "URL : " + url);

		String jsonResp = restTemplate.getForObject(url, String.class);

		retData.add(jsonResp);

	}
}

JSON Request


/OTNE_12-14/data_extraction/npt/inventory/alltopologicallinks/topologicallinks.json

JSON Response


[
	{
		"connectionName": "10/112SCX10-1-14-L1/10/SFD-1-17-9190",
		"connectionRate": "OS",
		"connectionState": "Commissioned",
		"direction": "bidirectional",
		"comment": "",
		"A1End": {
			"PortName": "112SCX10-1-14-L1",
			"NEName": "NODE4_PHN-1",
			"PortRate": "OS"
		},
		"A2End": {
			"PortName": "",
			"NEName": "",
			"PortRate": ""
		},
		"Z1End": {
			"PortName": "SFD-1-17-9190",
			"NEName": "NODE4_PHN-1",
			"PortRate": "OS"
		},
		"Z2End": {
			"PortName": "",
			"NEName": "",
			"PortRate": ""
		}
	}
]

Main Class

Following shows the client code snippet in main class retrieve all the topological links.


public class BulkUplaodService extends Service {
	public class OmsRestClientApplication {
		public static void main(String[] args) {
			AuthInfo authInfo = new AuthInfo();
			authInfo.setServerIP("135.250.184.42");
			authInfo.setServerPort("8443");
			authInfo.setServerUser("alcatel");
			authInfo.setServerPwd("Lucent1.!");
			authInfo.setPresentationIP("135.250.184.43");

			/**create OMSRestTemplate instance**/
			OMSRestTemplate omsRestTemplate = new OMSRestTemplate ();

			/**authenticate*/
			omsRestTemplate.authenticate(authInfo);

			BulkUplaodService bSvc = new BulkUplaodService ();
			List<String> resp = bSvc.getAllTopologicalLinks(omsRestTemplate);
		}
	}
}