Java Code and XML Examples

Contents
casp941
Contents
Java Code Examples
The
Web Services API provides example Java code that demonstrates basic functionality, JAXB beans, and hard-coded XML. An Eclipse .project and .classpath are also provided. The files are located in <
$SPECROOT
>/RestfulExamples/src/test.
Each of the example programs requires certain parameter values to be provided. See Program Arguments.
The following examples are provided in the /client subfolder.
  • AlarmPoller
    Subscribe for and pull alarms.
  • CreateSimilarModels
    Create many models of the same type.
  • GenericPoster
    A generic way to POST XML.
  • GetAllAlarms
    A simple alarm reader.
  • GetAllDevices
    A simple example that reads attributes on devices.
  • GetAllLandscapes
    The simplest example.
  • GlobalCollectionExample
    Creates a new Global Collection Model.
For more information, see the readme.txt files and internal documentation.
Program Arguments
The following program arguments are used by the provided Java code examples.
  • server={
    server
    }
    Specifies the host name of the OneClick server.
  • username={
    username
    }
    Specifies a user name for the OneClick server.
  • password={
    password
    }
    Specifies the username password for the OneClick server.
  • method={
    method
    }
    Specifies the REST verb, or HTTP method.
    Values:
    GET, POST, PUT, DELETE
  • port={
    port
    }
    (Optional) Specifies the port number of the OneClick server.
    Default:
    80
  • accept={
    acceptType
    }
    (Optional) Specifies the accept header value/MIME type.
    Values:
    application/xml, application/json
    Default:
    application/xml
  • inputdata={
    inputdataType
    }
    (Optional) Specifies the body content type.
    Value:
    application/xml
  • secure=true|false
    (Optional) Specifies whether to secure the connection to the OneClick server.
    Default:
    False
    If set to True, the following parameters are required:
    • keystore_file={
      fqfn for keystore file
      }
      Specifies the fully-qualified keystore file name.
    • keystore_password={
      keystore password
      }
      Specifies the password for the keystore.
    • alias={
      certificate alias
      }
      Specifies the certificate alias name.
    To use a secure connection, the OneClick server must be configured for SSL. For information about configuring OneClick for SSL, see .
XML Examples
The
Web Services API provides example XML for GET Tunneling requests. The files are located in <
$SPECROOT
>/RestfulExamples/xml.
The following examples are provided:
  • Alarms
    • GetAlarmsByAlarmIDs.xml
    • GetAlarmsByAttributeFilter.xml
    • GetAlarmsByModelHandles.xml
    • GetAlarmsBySearchCriteria.xml
    • GetAlarmsForAllDevices.xml
    • PullAlarmsSubscription.xml
  • Events
    • CreateEventByModelHandleList.xml
    • CreateEventByModelSearch.xml
    • CreateMultipleEventsByModelHandle.xml
  • Models
    • GetCiscoRouterModels.xml
    • GetModelsByModelHandles.xml
    • GetModelsFromExistingSearch.xml
    • PullAttrWatchForAllDevices.xml
    • PutModelsByModelHandles.xml
  • ModelTypes (MTypes)
    • PullWatchForNewMTypes.xml
    • PushWatchForNewMTypes.xml
    • PushWatchForNewMTypesBatchMode.xml
    • PushWatchForNewMTypesNoExpiration.xml
Simple URL Request in Browser
This example shows a GET landscapes request and results in a browser window. The GET verb is implied in the browser environment. Parameters are not necessary on the URL to return a list of all landscapes in the distributed
SpectroSERVER
environment.
SPEC--simple browser request_SCR
Simple URL Request with Parameters in a Browser
This example uses the devices noun with URL parameters to request the name (0x1006e) and model type (0x10000) of all devices. The GET verb is implied in the browser environment.
SPEC--simple request w parms_SCR