Update Syslog REST API

This PUT operation updates an existing Unified CVP device with the updated Syslog server configuration as specified in the request.

Parameters of Update Syslog REST API

URL

https://<ipaddress>:8111//cvp-config/server/<id>

HTTP Method

PUT

API Type

Synchronous

Input/Output Format

JSON, XML

Response Elements

syslog: Highlevel element to wrap syslog configuration of the device.

primary: Represents the primary Syslog server.

secondary: Represents the secondary Syslog server.

active: Represents the Active Syslog server.

host :Represents the host name or ip address of the Syslog server.

port : Represents the port number of the Syslog server.

backup: Represents the backup for the active Syslog server.

Code Snippets

Sample Request

PUT https://api.cvp.com:8111/cvp-config/server/<id>

Sample XML Response


<?xml version="1.0" encoding="UTF-8"?>
<server>
   <refURL>https://<ipaddress>:8111/cvp-config/server/{Id}</refURL>
   <hostname>hostname</hostname>
   <ipaddr>ipaddress</ipaddr>
   <type>VXML</type>
   <infrastructure>
     <syslog>
      <primary>
       <active>
         <host>primsrv1.cisco.com</host>
         <port>1624</port>
       </active>
       <backup>
         <host>primsrv2.cisco.com</host>
         <port>1624</port>
       </backup>
       </primary>
     <secondary>
       <active>
         <host>secondarysrv1.cisco.com</host>
         <port>1624</port>
       </active>
       <backup>
         <host>secondarysrv2.cisco.com</host>
         <port>1624</port>
       </backup>
     </secondary>
    </syslog>
   </infrastructure>
</server>

Sample JSON Response


{
  "server": {
    "infrastructure": {
      "syslog": {
        "primary": {
          "active": {
            "port": "1624",
            "host": "primsrv1.cisco.com"
          },
          "backup": {
            "port": "1624",
            "host": "primsrv2.cisco.com"
          }
        },
        "secondary": {
          "active": {
            "port": "1624",
            "host": "secondarysrv1.cisco.co"
          },
          "backup": {
            "port": "1624",
            "host": "secondarysrv2.cisco.co"
          }
        }
      }
    },
    "hostname": "hostname",
    "ipaddr": "ipaddress",
    "refURL": "https://<ipaddress>:8111/cvp-config/server/{Id}",
    "type": "VXML"
  }
}


Code Examples



import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.ClientFilter;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.client.urlconnection.HTTPSProperties;

public class GetSyslogTest {
  /**
	// Updates the syslog configuration for the given server.
	 * <p>
	 *
	//Query the deployed servers using GET Server List REST API.  
 //Pass the response and obtain the server reference URL.
  *
	 * @param srvRefUrl
	 *            - Server Reference URL.
	 * @return
	 */
	public String updateSyslog(String srvRefUrl) {

		/*
		 * Example srvRefUrl
		 * https://10.78.26.35:8111/cvp-config/server/
8a94edd0-0e3a-4e7e-9a9a-cad5162c04e5
		 */
		String jsonResponse = null;
		String jsonInput = readFile("syslog1.json");
		try {
			Client client = getSSLClient();
			ClientFilter authFilter = new HTTPBasicAuthFilter(userName,
					password);
			client.addFilter(authFilter);

			WebResource webResource = null;
			webResource = client.resource(srvRefUrl);
			ClientResponse res = webResource.type(MediaType.APPLICATION_JSON)
					.accept(MediaType.APPLICATION_JSON)
					.put(ClientResponse.class, jsonInput);
			System.out.println(res);
			if (res != null && res.getStatus() == 200) {
				jsonResponse = res.getEntity(new GenericType<String>() {
				});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(jsonResponse);
		return jsonResponse;
	}
}