Spectrum Web Api PDF
Spectrum Web Api PDF
Contact CA Technologies
Contact CA Support
For your convenience, CA Technologies provides one site where you can access the
information that you need for your Home Office, Small Business, and Enterprise CA
Technologies products. At http://ca.com/support, you can access the following
resources:
■ Online and telephone contact information for technical assistance and customer
services
■ Information about user communities and forums
■ Product and documentation downloads
■ CA Support policies and guidelines
■ Other helpful resources appropriate for your product
Contents 5
connectivity ................................................................................................................................................................ 34
GET connectivity ................................................................................................................................................. 34
devices ........................................................................................................................................................................ 36
GET devices ......................................................................................................................................................... 36
landscapes .................................................................................................................................................................. 38
GET landscapes ................................................................................................................................................... 38
model ......................................................................................................................................................................... 39
POST model ......................................................................................................................................................... 39
GET model ........................................................................................................................................................... 40
PUT model ........................................................................................................................................................... 42
DELETE model ..................................................................................................................................................... 42
Example: Create a Model Based on Model Type ................................................................................................ 43
models ........................................................................................................................................................................ 44
POST models (GET Tunneling) ............................................................................................................................. 44
GET models ......................................................................................................................................................... 46
PUT models ......................................................................................................................................................... 48
events ......................................................................................................................................................................... 48
POST event .......................................................................................................................................................... 49
POST events ........................................................................................................................................................ 50
subscription ................................................................................................................................................................ 52
POST subscription ............................................................................................................................................... 52
GET subscription ................................................................................................................................................. 56
GET subscription/requests .................................................................................................................................. 56
DELETE subscription ............................................................................................................................................ 57
Chapter 5: Examples 59
Java Code Examples ................................................................................................................................................... 59
Program Arguments ............................................................................................................................................ 60
XML Examples ............................................................................................................................................................ 61
Simple URL Request in Browser ................................................................................................................................. 62
Simple URL Request with Parameters in a Browser ................................................................................................... 63
Using Throttle and Next ............................................................................................................................................. 64
Using URL and GET Tunneling for Same Request ....................................................................................................... 65
URL Request ........................................................................................................................................................ 66
GET Tunneling Request ....................................................................................................................................... 66
Appendix A: Attributes 69
Appendix B: Troubleshooting 71
Common Issues .......................................................................................................................................................... 71
Index 73
Contents 7
Chapter 1: Introduction
This section contains the following topics:
About the CA Spectrum Web Services API (see page 9)
REST Architecture (see page 10)
Supported Technologies (see page 10)
CA Spectrum Web Services API and OneClick (see page 11)
Performance Considerations (see page 12)
Limitations (see page 12)
Using the CA Spectrum Web Services API, CA Spectrum data can be accessed directly
from a browser or integrated into your own application. Because of the inherent
standards in the REST architecture, the CA Spectrum Web Services API makes the CA
Spectrum data model accessible to many different external development environments
and methods. The CA Spectrum Web Services API can be used with any language that
knows how to manage HTTP integration and provides a lightweight alternative to SOAP
services.
By using the CA Spectrum Web Services API, you can take advantage of functionality
provided by the OneClick server, such as using its search infrastructure to more easily
find groups of models. You can also perform many standard CA Spectrum functions for a
single SpectroSERVER or in a distributed SpectroSERVER (DSS) environment, such as the
following:
■ Access devices, models, relationships, attributes, actions and alarms
■ Manage devices, ports, containers, services, and links
■ Read, update, and clear alarms
■ Manage subscriptions and notifications
Chapter 1: Introduction 9
REST Architecture
You can use the CA Spectrum Web Services API to perform these functions and more,
similar to those provided by other CA Spectrum API tools such as the Command Line
Interface (CLI), Modeling Gateway, AlarmNotifier, Southbound Gateway, or the
SpectroSERVER Object Request Broker (SSORB) interface.
Note: The CA Spectrum Web Services API can be used for simple CLI ad hoc commands
and as an alternative to complex CLI scripting.
Important! The CA Spectrum Web Services API is a powerful tool. It does not provide
the safeguards that OneClick does, especially related to modeling. It should be used only
by CA Spectrum administrators who understand the potentially harmful effects on a
network modeling scheme of haphazardly creating and destroying models and
modifying model attributes.
REST Architecture
Representational State Transfer (REST) is a software architectural style that promotes
standardized behaviors between interacting elements, or clients and servers.
Conforming to the REST constraints is referred to as being RESTful.
RESTful architecture and applications are stateless, which means that no client context
information is stored between requests. Each request contains all the information
necessary to service the request.
Supported Technologies
The CA Spectrum Web Services API provides a flexible, lightweight RESTful approach for
integration of CA Spectrum data into your application. As an alternative to CORBA
integration, the CA Spectrum Web Services API is language-independent and can be
integrated into any development platform that supports HTTP integration, such as:
■ Java
■ Perl
■ Ruby on Rails
■ .net
The CA Spectrum Web Services API provides an HTTP/HTTPS interface, is both HTTP and
XML/JSON-based, and provides Java Beans for client development.
This approach allows full access to OneClick server functions, essentially using the same
code as the OneClick server. You can take advantage of OneClick features such as user
authentication, search capability, and defined alarm filters. Throttled reads provide bulk
query efficiency, and load-balanced OneClick servers provide high availability. The CA
Spectrum Web Services API is fully supported in a distributed SpectroSERVER
environment.
As with all RESTful services, the CA Spectrum Web Services API requests are stateless,
requiring each request to include all necessary information to perform the operation.
Chapter 1: Introduction 11
Performance Considerations
Performance Considerations
The CA Spectrum Web Services API is a client, very similar to OneClick. Because the CA
Spectrum Web Services API reuses much of the OneClick server code, performance of a
single API client should generally mimic the performance of the comparable OneClick
operation. The CA Spectrum Web Services API should not alter SpectroSERVER
performance except through normal request load.
Limitations
The following should be considered when using the CA Spectrum Web Services API:
■ The CA Spectrum Web Services API does not provide interfaces for the modeling
catalog where data is generally static.
■ While an HTML or browser application can be built on top of the CA Spectrum Web
Services API, the CA Spectrum Web Services API itself does not provide HTML.
■ The CA Spectrum Web Services API accepts XML only for input and produces XML or
JSON for output. If you choose JSON as output, you may need to parse it out and
produce XML for the next request.
Both requests and responses are regulated by defined schemas (see page 18).
Requests
To use the CA Spectrum Web Services API, you generate a request to the OneClick
server for which you receive results in response. The request can be in the form of a URL
or imbedded in XML content.
RESTful Web Service URLs are noun-oriented, and the HTTP operation itself represents
the verb. The following is the base URL when generating a request using the CA
Spectrum Web Services API:
http://<hostname><:portnumber>/spectrum/restful/<request>
request
Specifies the CA Spectrum Web Services API RESTful resource (see page 23). Any
request that requires a body will use the types defined in the Request.xsd (see
page 18).
Note: Because RESTful architecture and applications are stateless, no client context
is stored between requests. Each request contains all the information necessary to
service the request in the URL or XML content.
Request Types
There are two types of requests used in the CA Spectrum Web Services API. Both
request types offer the same performance.
URL Requests
Used when a resource targets a specific model. For example, DELETE <mh> deletes
a specific model. This type of request works well for simple requests with few
parameters, does not require body text, and can be used as a browser URL.
Note: All URL requests have GET Tunneling equivalents.
GET Tunneling Requests
Used when a resource targets multiple models using complex parameters. An HTTP
GET command can only support a limited number of parameters in a URL and does
not support a body. The GET Tunneling operation tunnels a GET request through a
POST body, allowing complex requests to be created. The XML body can contain
rich filters by using new and existing search criteria and pre-defined alarm filters.
Semantics of GET Tunneling requests are defined by Request.xsd and Filter.xsd
schemas (see page 18) and can be created manually or generated from request
beans.
This pairing tells the RESTful servlet that an attr ID will be followed by the desired
value for that ID when updating the value of the attribute.
Multiple attribute-value pairs can be specified.
&landscape=<landscape_handle>
Specifies which landscapes to include in query. Multiple landscape parameters can
be specified.
&mh=<model_handle>
Specifies the model handle.
&throttlesize=<num>
Specifies the number of items from the result set to retrieve per response. If the
throttlesize value is less than the total number of items in the result set, the results
contain a "next" link. This link can be used to retrieve more results. See Using
Throttle and Next (see page 64).
Note: Not all resources support the throttlesize parameter.
Security
This section contains the following topics:
■ User Security in OneClick (see page 16)
■ Secure Connections (see page 16)
All requests using the CA Spectrum Web Services API respect CA Spectrum user
model-based security.
Important! The CA Spectrum Web Services API is a powerful tool. It does not provide
the safeguards that OneClick does, especially related to modeling. It should be used only
by CA Spectrum administrators with strong knowledge of the CA Spectrum data model.
Secure Connections
The CA Spectrum Web Services API supports secure connections to the OneClick server.
To use secure connections, the OneClick server must be configured for Secure Sockets
Layer (SSL).
Note: For information about configuring OneClick for SSL, see the Administrator Guide.
Responses
Responses are in the form of an XML or JSON document, as determined by the client’s
accept header value/MIME type. This flexible output makes the output data easy to
integrate into client development. Responses are defined by Response.xsd schema (see
page 18).
Note: The CA Spectrum Web Services API supports both application/xml and
application/json MIME types in the accept header. If you choose JSON as output, you
may need to parse it out and produce XML for the next request.
error="<msg>"
Indicates the overall success or failure of the operation. If there is a failure,
additional information is provided. "EndOfResults" indicates that all items in the
result set have been returned.
throttle="<num>"
Indicates the number of items returned in this response, as specified by the
throttlesize parameter on the request. If the throttle number is less than the total
results found by the server, a "next" link is provided. If the complete set of data is
returned, there is no "next" link.
total-resource="<num>"
Indicates the total number of items in the result set. Resource varies depending on
the type of request (for example, alarms, landscape, model, models).
link rel="next" href="<URL>"
Note: The "next" link appears only if additional items remain in the result set.
Indicates that additional items remain in the result set and provides the URL to
obtain them according to the throttle value. This link conforms to the HATEOAS
(Hypermedia as the Engine of Application State) constraints and can be used in a
client or a browser to issue the "next" request. By using this link, the full cost of the
original call is avoided. The location is cached on the OneClick server and expires
after ten minutes of inactivity. After expiration, the URL returns the string "The
cursor is no longer valid".
Note: Each RESTful call has its own cache.
The following parameters appear in the generated URL:
id=<result_set_ID>
Specifies the location of the result set on the OneClick server. The data expires
after ten minutes of inactivity.
start=<element_num>
Indicates the start position within the result set.
throttlesize
Indicates the number of items to return in the next response.
Note: The format of the parameters within the generated link may vary depending
on your environment. For example, "&" may be generated as "&" This is due to
differences between XML, HTTP, and JSON formatting standards.
More information:
http://<hostname><:portnumber>/spectrum/restful/services
Note: The WADL is provided for advanced users and describes the simple URLs but does
not describe GET Tunneling. Use the schema files (see page 18) for GET Tunneling.
Used to define the required syntax for GET Tunneling, the schema files are also more
useful than WADL for advanced usage. The schema files are used to generate the JAXB
beans that can be used for java and java script development. These beans are available
in <$SPECROOT>/RestfulExamples/lib/spectrumrest.jar.
CA Spectrum provides the following XML Schema Definitions (.xsd) files, which are
located in <$SPECROOT>/RestfulExamples/src/xsd:
Filter.xsd
Specifies the XML for attribute filters and search criteria.
Note: This is the same XML that is used by the CA Spectrum Locator; however, the
Filter.xsd is only used by the CA Spectrum Web Services API.
Request.xsd
Defines the XML format used in GET Tunneling. All POST body XML must have a tag
like the following:
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request
../../../xsd/Request.xsd">
Response.xsd
Defines the XML or JSON format for all synchronous responses and XML format for
all asynchronous responses.
Note: The HEAD, OPTIONS, and TRACE verbs are not supported in the CA Spectrum Web
Services API.
* GET can only be performed against the result set created by POST (GET Tunneling).
action
Use the Action resource to issue an action request to the SpectroSERVER. An internal
action code determines which operation is performed by the action.
Base URL
http://<hostname><:portnumber>/spectrum/restful/action
GET action
GET action issues an action request to the SpectroSERVER. Initiated as an HTTP GET, the
action performed on the SpectroSERVER, including modifying data, is specified by an
action code. All actions return results, which differ by the requested action.
URL
http://<hostname><:portnumber>/spectrum/restful/action/<action_code>[?mh=<mod
el_handle>][&attr=<attr_ID>&val=<num>][&throttlesize=<num>]
HTTP Method
GET
Body
None
Body Content
Not used
Header
application/xml, application/json
Output
XML or JSON listing. Content differs depending on requested action.
URL Parameters
action_code
Specifies the action to perform on the SpectroSERVER. The following table contains
some common actions.
&mh=<model_handle>
(Optional) Specifies the target of the action.
&attr=<attr_ID>&val=<num>
(Optional) Specifies attribute values as input to the action. Multiple attribute-value
pairs can be specified.
&throttlesize=<num>
(Optional) Specifies a throttle size.
Example
The following URL initiates the ‘FIND_DEV_MODELS_BY_IP’ action (0x10093) against the
SearchManager model (0x400018):
http://<hostname><:portnumber>/spectrum/restful/action/0x10093?mh=0x400018&attr=0
&val=172.22.96.11&attr=1&val=172.22.96.5
Notes:
■ The SearchManager model handle will differ from SpectroSERVER to
SpectroSERVER.
■ You can also find device models by IP by embedding the correct locater search in
the POST body of a GET models (see page 44).
alarms
Use the Alarms resource to read, modify, and delete CA Spectrum alarms. Asynchronous
responses are supported.
Base URL
http://<hostname><:portnumber>/spectrum/restful/alarms
Important! This POST is a form of GET Tunneling. You cannot create an alarm with POST
alarms. CA Spectrum alarms are created in response to events, as defined by the Event
Disposition files.
URL
http://<hostname><:portnumber>/spectrum/restful/alarms
HTTP Method
POST
Body
Examples are provided in <$SPECROOT>/RestfulExamples/xml/Alarms. These XML
files provide examples of properly formed XML for different purposes. Use these
examples as a basis for your own XML:
■ GetAlarmsByModelHandles.xml
■ GetAlarmsBySearchCriteria.xml
■ GetAlarmsForAllDevices.xml
■ GetAlarmsByAlarmIDs.xml
■ GetAlarmsByAttributeFilter.xml
Body Content
application/xml
Header
application/xml, application/json
Output
XML or JSON listing all alarms in the SpectroSERVER or distributed SpectroSERVER
Example
GET alarms
GET alarms returns alarm IDs. You can retrieve specific alarm attributes by using the
&attr=<attr_id> parameter.
URL
http://<hostname><:portnumber>/spectrum/restful/alarms[?attr=<attr_ID>][&land
scape=<landscape_handle>][&throttlesize=<num>]
HTTP Method
GET
Body
None
Body Content
Not used
Header
application/xml, application/json
Output
XML or JSON listing alarms in the SpectroSERVER or distributed SpectroSERVER
URL Parameters
&attr=<attr_ID>
(Optional) Specifies the requested attributes. Multiple attribute parameters can be
specified.
Note: There are many attributes on a model; for best performance you should limit
attribute selection to attributes of interest (see page 69).
&landscape=<landscape_handle>
(Optional) Filters which landscapes are queried. Multiple landscape parameters can
be specified.
&throttlesize=<num>
(Optional) Specifies a throttle size.
PUT alarms
Use PUT alarms to update alarm attributes.
URL
http://<hostname><:portnumber>/spectrum/restful/alarms/<alarm_id>?attr=<attr_
ID>&val=<num>
HTTP Method
PUT
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing indicating success or failure
URL Parameters
alarm_ID
Specifies the alarm ID.
&attr=<attr_ID>&val=<num>
Specifies the attributes and values. Multiple attribute-value pairs can be specified.
DELETE alarms
To delete an alarm using DELETE alarms, include the alarm ID without any other
parameters.
URL
http://<hostname><:portnumber>/spectrum/restful/alarms/<alarm_id>
HTTP Method
DELETE
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing indicating success or failure
URL Parameters
alarm_ID
Specifies the alarm to delete.
associations
Use the Associations/Relation resource to create, read, or delete associations.
Note: The Associations noun is a pass-through noun. You must also specify the
Relation noun to create, read, or delete associations.
POST associations
POST associations creates an association. A specific relation is created between two
models. Only models on the same SpectroSERVER can be associated.
URL
http://<hostname><:portnumber>/spectrum/restful/associations/relation/<rel_ha
ndle>/leftmodel/<LMhandle>/rightmodel/<RMhandle>
HTTP Method
POST
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing association information
URL Parameters
rel_handle
Specifies the relation handle.
LMhandle
Specifies the handle of the left model in the relation.
RMhandle
Specifies the handle of the right model in the relation.
Note: To get the left or right model handle, you can use the CLI show associations
command, as follows:
For more information about this command, see the Command Line Interface User Guide.
GET associations
GET associations returns associations for a specific relation and model. Associations are
read based on the side of the association that the model handle is on.
URL
http://<hostname><:portnumber>/spectrum/restful/associations/relation/<rel_ha
ndle>/model/<model_handle>?side=[left|right]
HTTP Method
GET
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing association information
URL Parameters
rel_handle
Specifies the relation handle.
model_handle
Specifies the handle of the model in the relation.
side=[left|right]
Specifies the side of the association that the model handle is on.
DELETE associations
DELETE associations removes associations by deleting a specific relation between two
models.
URL
http://<hostname><:portnumber>/spectrum/restful/associations/relation/<rel_ha
ndle>/leftmodel/<LMhandle>/rightmodel/<RMhandle>
HTTP Method
DELETE
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing indicating success or failure
URL Parameters
rel_handle
Specifies the relation handle.
LMhandle
Specifies the handle of the left model in the relation.
RMhandle
Specifies the handle of the right model in the relation.
attribute
Use the Attribute resource to retrieve strings for enumerated attributes.
Base URL
http://<hostname><:portnumber>/spectrum/restful/attribute
GET attribute
GET attribute returns XML describing the enumerations for the specified attribute.
URL
http://<hostname><:portnumber>/spectrum/restful/attribute/<attr_ID>/enums
HTTP Method
GET
Body
None
Body Content
application/xml, application
Header
application/xml, application/json
Output
XML describing the enumerations for the specified attribute
URL Parameters
attr_ID
Specifies the attribute ID.
Note: Do not use external attributes.
Example
The following URL requests the enumerations for the model class attribute (0x11ee8):
http://localhost:8080/spectrum/restful/attribute/0x11ee8/enums
connectivity
Use the Connectivity resource to retrieve connectivity information for a specified device
model's IP address.
Base URL
http://<hostname><:portnumber>/spectrum/restful/connectivity
GET connectivity
GET connectivity returns XML describing all the connectivity from a requested end
point.
URL
http://<hostname><:portnumber>/spectrum/restful/connectivity/<ip_address>
HTTP Method
GET
Body
None
Body Content
application/xml, application
Header
application/xml, application/json
Output
XML describing the connectivity
URL Parameters
ip_address
Specifies the IP address to retrieve connectivity information for.
Example
The following URL requests connectivity information for the specified IP address:
http://localhost:8080/spectrum/restful/connectivity/172.22.94.134
<connection-element-right>
<ipaddress>172.22.94.25</ipaddress>
<mh>0x4007bb</mh>
<name>cis7204-96.6.ca.com.6.ca.com_Fa4/0</name>
<type>Gen_IF_Port</type>
<class>Port</class>
</connection-element-right>
</connection-response>
<connection-response>
<connection-element-left>
<ipaddress>172.22.94.134</ipaddress>
devices
Use the Devices resource to retrieve CA Spectrum devices and attribute information.
GET devices
GET devices returns all device model handles. You can retrieve specific model attributes
by using the &attr=<attr_id> parameter.
URL
http://<hostname><:portnumber>/spectrum/restful/devices[?attr=<attr_ID>][&lan
dscape=<landscape_handle>][&throttlesize=<num>]
HTTP Method
GET
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing all device model handles and requested attributes in the
SpectroSERVER or distributed SpectroSERVER
URL Parameters
&attr=<attr_ID>
(Optional) Specifies the requested attributes. Multiple attribute parameters can be
specified.
Note: There are many attributes on a model; for best performance you should limit
attribute selection to attributes of interest (see page 69).
&landscape=<landscape_handle>
(Optional) Filters which landscapes are queried. Multiple landscape parameters can
be specified.
&throttlesize=<num>
(Optional) Specifies a throttle size.
Example
The following URL requests the name and model type of all devices:
http://<hostname><:portnumber>/spectrum/restful/devices?attr=0x1006e&attr=0x10000
landscapes
Use the Landscapes resource to retrieve landscape information.
Base URL
http://<hostname><:portnumber>/spectrum/restful/landscapes
GET landscapes
GET landscapes returns information about all landscapes.
URL
http://<hostname><:portnumber>/spectrum/restful/landscapes
HTTP Method
GET
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing all landscapes in SpectroSERVER or distributed SpectroSERVER
Example
http://localhost/spectrum/restful/landscapes
model
Use the model resource to create or delete a model and to read or modify model
attributes. An example that illustrates model creation is included in this section. For
more information, see Example: Create a Model Based on Model Type (see page 43).
Note: The model resource operates on a single model at a time. For groups of models,
use the models (see page 44) resource.
Base URL
http://<hostname><:portnumber>/spectrum/restful/model
POST model
POST model creates a new model and returns the model handle.
URL
http://<hostname><:portnumber>/spectrum/restful/model[?landscapeid=<landscape
_handle>][&mtypeid=<mtype_handle>][&port=<snmp_port>][&commstring=<comm_str>]
[&retry=<retry_cnt>][&timeout=<timeout_val>][&ipaddress=<ip_address>][&parent
mh=<model_handle>][&relationid=<rel_handle>][&attr=<attr_id>&val=<num>]
HTTP Method
POST
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing the model handle of the created model or the error if the model
cannot be created
URL Parameters
&landscapeid=<landscape_handle>
(Optional) Specifies the landscape where the model will be created.
&mtypeid=<mtype_handle>
(Optional) Specifies the model type handle of the model to be created. Required if
the ipaddress parameter is not specified (see below).
&port=<snmp_port>
(Optional) Specifies the SNMP management port on the device.
Default: 161
&commstring=<comm_str>
(Optional) Specifies the community string.
Default: public
&retry=<retry_cnt>
(Optional) Specifies the retry count.
Default: 3
&timeout=<timeout_val>
(Optional) Specifies the timeout value.
Default: 3000
&ipaddress=<ip_address>
(Optional) Specifies the IP address.
&parentmh=<model_handle>
(Optional) Specifies the parent (left Association) model.
&relationid=<rel_handle>
(Optional) Specifies the association from the parent to this model.
Default: Collects
&attr=<attr_id>&val=<num>
(Optional) Specifies and attribute ID and value.
GET model
GET model reads attributes from the specified model.
URL
http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>[?attr=<a
ttr_ID>]
HTTP Method
GET
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing of the requested attributes
URL Parameters
model_handle
Specifies the model.
&attr=<attr_ID>
(Optional) Specifies the requested attributes. Multiple attribute parameters can be
specified.
PUT model
PUT model updates attributes on the specified model.
URL
http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>?attr=<at
tr_ID>&val=<num>
HTTP Method
PUT
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing of the requested attributes
URL Parameters
model_handle
Specifies the model to update.
&attr=<attr_ID>&val=<num>
Specifies the attributes and values to update. Multiple attribute-value pairs can be
specified.
DELETE model
DELETE model deletes the specified model.
URL
http://<hostname><:portnumber>/spectrum/restful/model/<model_handle>
HTTP Method
DELETE
Body
None
Body Content
Not Used
Header
application/xml, application/json
Output
XML or JSON listing indicating success or failure
URL Parameters
model_handle
Specifies the model to delete.
The basic format to use is shown in the following URL. Variables are indicated with
italics:
http://hostname:portnumber/spectrum/restful/model[?mtypeid=
modeltype_of_a_device][&parentmh=model_handle][&relationid=rel_handle][&attr=
attr_id&val=<num>]
Example
http://host IP address:portnumber/spectrum/restful/model
?mtypeid=0x00010290&parentmh=0x40000005&attr=0x12d7f&val=10.13.12.111
relationid
(Optional) The relation ID to identify an association between two models in the
model domain (a relation).
attr
The attribute ID of ipaddress. The value is the device IP address.
models
Use the Models resource to retrieve and update models and attributes.
Note: The models resource operates on groups of models. For a single model, use the
model (see page 39) resource.
Base URL
http://<hostname><:portnumber>/spectrum/restful/models
Important! POST models is a form of GET Tunneling used to retrieve multiple models.
You cannot create a model with POST models. To create a model, use POST model (see
page 39).
URL
http://<hostname><:portnumber>/spectrum/restful/models
HTTP Method
POST
Body
Examples are provided in <$SPECROOT>/RestfulExamples/xml/Models. These XML
files provide examples of properly formed XML for different purposes. Use these
examples as a basis for your own XML:
■ GetCiscoRouterModels.xml
■ GetModelsByModelHandles.xml
■ GetModelsFromExistingSearch.xml
Body Content
application/xml
Header
application/xml, application/json
Output
XML or JSON listing of models satisfying the request input in the SpectroSERVER or
distributed SpectroSERVER
URL
http://<hostname><:portnumber>/spectrum/restful/models
Body
<rs:target-models>
<rs:models-search>
<rs:search-criteria
xmlns="http://www.ca.com/spectrum/restful/schema/filter">
<action-models>
<filtered-models>
<equals>
<model-type>SearchManager</model-type>
</equals>
</filtered-models>
<action>FIND_DEV_MODELS_BY_IP</action>
<attribute id="AttributeID.NETWORK_ADDRESS">
<value>172.22.96.6</value>
</attribute>
</action-models>
</rs:search-criteria>
</rs:models-search>
</rs:target-models>
</rs:model-request>
GET models
GET models returns model handles and requested attributes. To retrieve specific model
attributes, use the &attr=<attr_id> parameter.
Important! GET models can be used only after a POST (GET Tunneling) models has been
performed. POST models generates the result set, and GET models is used to retrieve
model handles and attribute information for the items within that result set.
URL
http://<hostname><:portnumber>/spectrum/restful/models?id=<result_set_pointer
>[&attr=<attr_ID>][&landscape=<landscape_handle>][&throttlesize=<num>]
HTTP Method
GET
Body
None
Body Content
Not used
Header
application/xml, application/json
Output
XML or JSON listing of models satisfying the request input in the SpectroSERVER or
distributed SpectroSERVER
URL Parameters
?id=<result_set_pointer>
Specifies the location of the result set on the OneClick server. This value is
generated by using POST (GET Tunneling) models (see page 44) and appears on the
"next" relative link (see page 16). The location expires on the OneClick server after
ten minutes of inactivity.
&attr=<attr_ID>
(Optional) Specifies the requested attributes. Multiple attribute parameters can be
specified.
Note: There are many attributes on a model; for best performance you should limit
attribute selection to attributes of interest (see page 69). Not all models support
the same set of attributes. Unsupported attributes will return ‘NoSuchAttribute’
&landscape=<landscape_handle>
(Optional) Filters which landscapes are queried. Multiple landscape parameters can
be specified.
&throttlesize=<num>
(Optional) Specifies a throttle size.
PUT models
PUT models updates attributes across multiple models. The models can be selected by a
variety of techniques including search criteria. Not all selected models need to support
the attributes being modified.
URL
http://<hostname><:portnumber>/spectrum/restful/models
HTTP Method
PUT
Body
Uses Request.xsd:update-models-request. The Request.xsd is located in
<$SPECROOT>/RestfulExamples/src/xsd
Body Content
application/xml, application
Header
application/xml, application/json
Output
XML or JSON listing of model-response indicating the success or failure of each
update.
events
Use the events resource to create events.
POST event
POST event creates a new event.
URL
http://<hostname><:portnumber>/spectrum/restful/events/<eventType>/model/<mod
el handle>[?varbind=<varbind id>][&val=<varbind value>]
HTTP Method
POST
Body
None
Body Content
Not Used
Header
application/xml, application/json
Encoding
UTF-8
Output
XML or JSON listing the model handle of the created model or the error if the model
cannot be created.
URL Parameters
<event type>
Specifies the event type to be created.
<model handle>
Specifies the model handle on which the event will be created.
<varbind id>
Specifies the varbind id.
<varbind value>
Specifies the varbind value.
POST events
Use POST events to create one or more events on one or more models. POSTing an
events request lets you provide an XML document that specifies the events to create
and the models on which to create them. The document contains a list of model
handles, XML search criteria, or a reference to existing search criteria on the OneClick
server.
URL
http://<hostname><:portnumber>/spectrum/restful/events
HTTP Method
POST
Body
Examples are provided in <$SPECROOT>/RestfulExamples/xml/Events. These XML
files provide examples of properly formed XML for different purposes. Use these
examples as a basis for your own XML:
■ CreateEventByModelHandleList.xml
■ CreateEventByModelSearch.xml
■ CreateMultipleEventsByModelHandle.xml
Body Content
application/xml
Header
application/xml, application/json
Encoding
UTF-8
Output
XML or JSON listing of models satisfying the request input in the SpectroSERVER or
distributed SpectroSERVER
Example: Create an event 0x10f06 on all RTR_Cisco Model Types, with 4 varbinds
The following is an example of creating an event 0x10f06 on all RTR_Cisco Model Types,
with 4 varbinds
URL
Body
<!--This sample event request will create an event of type 0x10f06 (generates a High
Memory Utilization alarm) on all models found by the specified locater search (all
models derived from RTR_Cisco) -->
<rs:event-request throttlesize="10"
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request
../../../xsd/Request.xsd">
<rs:event>
<rs:target-models>
<rs:models-search>
<rs:search-criteria
xmlns="http://www.ca.com/spectrum/restful/schema/filter">
<filtered-models>
<is-derived-from>
<attribute id="AttributeID.MTYPE_HANDLE">
</attribute>
</is-derived-from>
</filtered-models>
</rs:search-criteria>
</rs:models-search>
</rs:target-models>
<rs:event-type id="0x10f06"/>
<rs:varbind id="0">75</rs:varbind>
<rs:varbind id="1">99</rs:varbind>
<rs:varbind id="3">mem_instance</rs:varbind>
<rs:varbind id="5">name</rs:varbind>
</rs:event>
</rs:event-request>
subscription
Use the Subscription resource to create or retrieve subscriptions. A subscription is a
request to be notified of activity on any of the following:
■ Model types/attributes. Registers watches for model creation/deletion of type and
attribute changes on those types.
Note: ModelType subscriptions watch for new models.
■ Models/attributes. Registers watches on specified models and related attribute
changes.
■ Alarms/attributes. Registers watches for alarm creation/clearing and attribute
changes.
Base URL
http://<hostname><:portnumber>/spectrum/restful/subscription
POST subscription
POST subscription creates a new subscription. Subscriptions are pull or push. A pull
subscription requires that the client poll the subscription ID whereas a push subscription
requires that the client provide a URL to which notifications can be POSTed.
Notifications contain change information in XML or JSON format.
Note: Push subscriptions are useful when the integration client is another OneClick
server.
URL
http://<hostname><:portnumber>/spectrum/restful/subscription
HTTP Method
POST
Body
Uses Request.xsd:subscription-request. The Request.xsd is located in
<$SPECROOT>/RestfulExamples/src/xsd
For specific examples of Subscription XML, see the following:
■ In <$SPECROOT>/RestfulExamples/xml/Alarms:
■ PullAlarmsSubscription.xml
■ In <$SPECROOT>/RestfulExamples/xml/Models
■ PullAttrWatchForAllDevices.xml
■ In <$SPECROOT>/RestfulExamples/xml/MTypes:
■ PullWatchForNewMTypes.xml
■ PushWatchForNewMTypes.xml
■ PushWatchForNewMTypesBatchMode.xml
■ PushWatchForNewMTypesNoExpiration.xml
Body Content
application/xml, application
Header
application/xml, application/json
Output
XML or JSON listing the subscription-id
subscription-id
Identifies the subscription. This value is used with GET subscription (see
page 56) and DELETE subscription (see page 57) and expires if not used.
Body Parameters
The following parameters are used in the subscription request body XML.
■ For pull subscriptions:
max-notifications
Specifies the number of notification items.
Default: 100
max-queue-size
Specifies the number of notifications to queue.
Default: 10000
pull-interval
Specifies the frequency of polling in milliseconds.
Note: Subscriptions expire if not polled.
Minimum: 5000
■ For push subscriptions:
destination-url
Specifies the URL where notifications will be POSTed.
A test notification servlet has been provided that prints results to the CA
Spectrum tomcat log. This servlet is installed with CA Spectrum, and no
additional configuration is required. To use the servlet, set the destination-url
to:
http://<hostname><:portnumber>/spectrum/restful/TestNotifications
batch-notifications
max-notifications
Specifies the number of notifications in a batch. If this number is reached,
notification is sent immediately.
Default: 100
max-time
Specifies the time in milliseconds to wait before sending notifications. If
this number is reached, notifications are sent immediately.
Default: 1000
heartbeat-interval
Specifies the interval in milliseconds that the subscription is validated. The
subscription servlet sends a message every hearbeat-interval to the receiving
servlet (designated by the destination-url) to indicate that the subscription is
active. If the receiving servlet stops receiving the heartbeat message, it knows
that the subscription has stopped (for example, if the OneClick server stops or
restarts). If the receiving servlet becomes unavailable, notifications stop.
Note: The TestNotifications servlet does not print the heartbeat message.
Example
<rs:destination-url>http://<hostname><:portnumber>/spectrum/restful/TestNotificat
ions</rs:destination-url>
<rs:username><user></rs:username>
<rs:password><password></rs:password>
GET subscription
Use GET subscription to return XML describing all the changes of interest based on the
initial subscription request.
HTTP Method
GET
Body
None
Body Content
application/xml, application
Header
application/xml, application/json
URL Parameters
subscription_ID
Specifies the subscription ID. This value is returned from the original subscription
request (POST subscription (see page 52)) or GET subscription/requests (see
page 56). It is used to obtain the set of changes since the last request.
GET subscription/requests
Use GET subscription/requests to return a string of the current, active subscriptions.
This request is used primarily for debugging or verification purposes to see if a particular
model, type or attribute is registered for notification.
Note: To pull the actual model, model type, and attribute changes, see GET subscription
(see page 56).
URL
http://<hostname><:portnumber>/spectrum/restful/subscription/requests
HTTP Method
GET
Body
None
Body Content
application/xml, application
Header
application/xml, application/json
Output
HTML page listing the subscription-id and other subscription-related information for
each current, active subscription
subscription-id
Identifies a subscription. This value is used with GET subscription (see page 56)
and DELETE subscription (see page 57).
DELETE subscription
DELETE subscription deletes the specified subscription.
URL
http://<hostname><:portnumber>/spectrum/restful/subscription/<subscription_ID
>
HTTP Method
DELETE
Body
None
Body Content
application/xml, application
Header
application/xml, application/json
URL Parameters
subscription_ID
Specifies the subscription to delete. This value is returned from the original
subscription request (POST subscription (see page 52)) or GET subscription/requests
(see page 56).
Note: Each of the example programs requires certain parameter values to be provided.
See Program Arguments (see page 60).
For more information, see the readme.txt files and internal documentation.
Chapter 5: Examples 59
Java Code Examples
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.
Note: To use a secure connection, the OneClick server must be configured for SSL.
For information about configuring OneClick for SSL, see the Administrator Guide.
XML Examples
The CA Spectrum Web Services API provides example XML for GET Tunneling requests.
The files are located in <$SPECROOT>/RestfulExamples/xml.
Chapter 5: Examples 61
Simple URL Request in Browser
Models
■ GetCiscoRouterModels.xml
■ GetModelsByModelHandles.xml
■ GetModelsFromExistingSearch.xml
■ PullAttrWatchForAllDevices.xml
■ PutModelsByModelHandles.xml
ModelTypes (MTypes)
■ PullWatchForNewMTypes.xml
■ PushWatchForNewMTypes.xml
■ PushWatchForNewMTypesBatchMode.xml
■ PushWatchForNewMTypesNoExpiration.xml
Chapter 5: Examples 63
Using Throttle and Next
link rel="next"
Indicates the URL to retrieve the next items in the result set. This link can be
used in a browser or a program to issue the next request.
id=<result_set_ID>
Specifies the location of the result set on the OneClick server. The data
expires after ten minutes of inactivity.
start=<element_num>
Indicates the position within the result set.
2. Use the "next" relative link from the previous response to request the next three
items in the result set:
http://comp001/spectrum/restful/alarms?id=c6a367df-0b3e-4461-aa8d-
aad451a45bf7&start=3&throttlesize=3
Chapter 5: Examples 65
Using URL and GET Tunneling for Same Request
URL Request
This examples uses GET devices, in a simple URL request format, to retrieve attributes
for all devices, throttling at 100.
Initial request
http://localhost/spectrum/restful/devices?attr=0x1006e&attr=0x10000&attr=0x10032&
attr=0x12de2&throttlesize=100
All matching devices are found and cached. The first 100 devices are returned, and, if
there are more than 100, a link to get the next 100.
Subsequent request
Using the link from the initial request response, the following request pulls the next set
of results from the cache:
http://localhost/spectrum/restful/devices?id=0120a63a-e2d3-4175-9563-c17c90c783a7
&start=100&throttlesize=100
The following portions of Request.xsd are of interest for this example. This request uses
the model-request type. The type definition determines the parameters that can be
specified, in this case, "target-models", "requested-attribute", and "throttlesize".
<xs:complexType name="model-request">
<xs:sequence>
<xs:element name="target-models" type="rs:target-models" minOccurs="1"
maxOccurs="1" />
<xs:element name="requested-attribute" type="rs:requested-attribute"
minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="throttlesize" type="xs:int" />
</xs:complexType>
.
.
.
<xs:complexType name="target-models">
<xs:choice>
<xs:element name="model" type="rs:model" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="models-search" type="rs:models-search" minOccurs="0"
maxOccurs="1"/>
</xs:choice>
</xs:complexType>
.
.
.
<!-- Elements -->
Chapter 5: Examples 67
Appendix A: Attributes
The follow table contains alarm and model attributes that are commonly used when
using the CA Spectrum Web Services API. Italicized items are model attributes that
might be of interest for alarms. Non-italicized items are alarm-specific attributes.
Appendix A: Attributes 69
Using URL and GET Tunneling for Same Request
Common Issues
If you are experiencing problems when using the CA Spectrum Web Services API, check
the following:
■ Is the URL constructed correctly?
■ Is the correct verb used with the noun?
■ Is the Request XML for GET Tunneling constructed correctly?
■ Have the proper credentials been entered?
■ Has the "accept" header and "Content-type" been set correctly for XML or JSON?
■ Do any CA Spectrum Web Services API errors appear in the tomcat log?
More information:
Appendix B: Troubleshooting 71
"Next" Link Does not Work
Solution:
The format of the parameters within the generated link may vary depending on your
environment. For example, "&" may be generated as "&" This is due to differences
between XML, HTTP, and JSON formatting standards. Notice the difference in the
prefixes for the start and throttlesize parameters in the following URLs:
http://localhost/spectrum/restful/models?id=5b03b5ba-64ed-4603-b3e1-8e71919fccd8&
amp;start=2&throttlesize=2
http://localhost/spectrum/restful/models?id=5b03b5ba-64ed-4603-b3e1-8e71919fccd8&
start=2&throttlesize=2
S
support, contacting • 3
T
technical support, contacting • 3
Index 73