Unisphere Rest Api Programmers Guide PDF
Unisphere Rest Api Programmers Guide PDF
EMC believes the information in this publication is accurate as of its publication date. The information is subject to change
without notice.
The information in this publication is provided as is. EMC Corporation makes no representations or warranties of any kind with
respect to the information in this publication, and specifically disclaims implied warranties of merchantability or fitness for a
particular purpose. Use, copying, and distribution of any EMC software described in this publication requires an applicable
software license.
EMC², EMC, and the EMC logo are registered trademarks or trademarks of EMC Corporation in the United States and other
countries. All other trademarks used herein are the property of their respective owners.
For the most up-to-date regulatory document for your product line, go to EMC Online Support (https://support.emc.com).
EMC Corporation
Hopkinton, Massachusetts 01748-9103
1-508-435-1000 In North America 1-866-464-7381
www.EMC.com
2 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CONTENTS
Preface 5
Chapter 1 Welcome 7
The Unisphere Management REST API............................................................. 8
Examples in this guide.................................................................................... 8
EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide 3
CONTENTS
4 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Additional resources
As part of an effort to improve its product lines, EMC periodically releases revisions of its software and hardware.
Therefore, some functions described in this document might not be supported by all versions of the software or
hardware currently in use. The product release notes provide the most up-to-date information on product features.
Contact your EMC technical support professional if a product does not function properly or does not function as
described in this document.
Where to get help
Support, product, and licensing information can be obtained as follows:
Product information
For product and feature documentation or release notes, go to Unity Technical
Documentation at: www.emc.com/en-us/documentation/unity-family/index.htm. You
can also access this page from the Unity product family page at: www.emc.com/en-us/
storage/unity.htm. In the Why Unity section, click Unity Product Resources.
Troubleshooting
For information about EMC products, software updates, licensing, and service, go to EMC
Online Support (registration required) at: https://Support.EMC.com. After logging in,
locate the appropriate Support by Product page.
Technical support
For technical support and service requests, go to EMC Online Support at: https://
Support.EMC.com. After logging in, locate Create a service request. To open a service
request, you must have a valid support agreement. Contact your EMC Sales
Representative for details about obtaining a valid support agreement or to answer any
questions about your account.
Special notice conventions used in this document
EMC uses the following conventions for special notices:
DANGER
Indicates a hazardous situation which, if not avoided, will result in death or serious
injury.
WARNING
Indicates a hazardous situation which, if not avoided, could result in death or serious
injury.
CAUTION
Indicates a hazardous situation which, if not avoided, could result in minor or moderate
injury.
NOTICE
Note
EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide 5
Additional resources
6 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 1
Welcome
Welcome 7
Welcome
Note
The attributes in the example response text may differ from the response text you receive
when running the same request.
8 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 2
REST API overview
"content": {
"origin": 1,
10 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
REST API overview
"addresses": [
"10.254.177.14",
"10.255.134.14"
],
"id": "0"
}
}
]
}
12 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 3
JSON request components
Note
Set- Login session ticket Because the API uses cookie-based authentication, the
Cookie: HTTP client must support cookies in order to use the API.
14 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON request components
Request parameters
The REST API supports the following request parameters:
filter Collection Filters the response data against a set of criteria. Only
query request matching resource instances are returned. Filtering is case
insensitive.
Request parameters 15
JSON request components
groupby Collection Groups the specified values and applies the @sum
query request function to each group.
For example, you could use groupby with @sum to return
a summary of disk sizes for each disk type.
For more information, see Aggregating response data on
page 64.
orderby Collection Specifies how to sort response data. You can sort
query request response data in ascending or descending order by the
attributes of the queried resource type. And you can use
dot notation syntax to sort response data by the attributes
of related resource types.
For more information, see Sorting response data on page
61 and Extending queries to include related data on page
73.
16 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON request components
per_page Collection Specifies the number of resource type instances that form
query request a page. If this parameter is not specified, the server
returns all resource instances that meet the request
criteria in the page specified by page (or in page 1, if page
is also not specified).
Note
timeout Most non-GET Executes the request in the background. Most active
requests management requests (ones that attempt to change the
configuration) support this option. The documentation for
each API method in the Unisphere Management REST API
Reference Guide specifies whether the method supports
this option.
For more information, see Working with asynchronous
requests on page 90.
To use request parameters, append the parameters to the request URI. The first request
parameter appended to the URI begins with a ? character. Additional request parameters
begin with & instead of ?. You can combine request parameters and can use them in any
order. If a request parameter is repeated, all but the last one is ignored.
Example 1
The following request uses a fields query parameter to return the name, and rpm
attributes, a filter query parameter to return disk instances that have an RPM of
15000, and a compact query parameter to omit metadata from each instance in the
query response. It also sets the with_entrycount query parameter to true, so that the
entry count is included in the response data. For readability purposes, this example omits
URI encoding for the space character (%20) and % character (%25).
Request parameters 17
JSON request components
Request
GET api/types/disk/instances?fields=rpm,name&filter=rpm eq
15000&compact=true&with_entrycount=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?filter=rpm
eq 15000&fields=rpm,name,id&per_page=2000&compact=true",
"updated": "2015-12-02T21:03:14.446Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 20,
"entries": [
{
"content": {
"id": "dpe_disk_0",
"name": "DPE Disk 0",
"rpm": 15000
}
},
{
"content": {
"id": "dpe_disk_1",
"name": "DPE Disk 1",
"rpm": 15000
}
},
{
"content": {
"id": "dpe_disk_2",
"name": "DPE Disk 2",
"rpm": 15000
}
},
.
.
.
Example 2
The following request uses the per_page and page query parameters to group returned
disk instances into chunks of two instances per page and to return only the instances
on page three. It also uses fields query parameter to return the name, pool and
tierType attributes, and the compact query parameter to omit metadata from each
instance in the query response:
Request
GET api/types/disk/instances?
per_page=3&page=2&fields=name,pool,tierType&compact=true
Response
{
"@base": "https://10.245.23.125/api/types/disk/instances?
fields=name,tierType,id,pool.id&per_page=3&compact=true",
"updated": "2015-11-19T22:47:53.424Z",
"links": [
{
18 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON request components
"rel": "self",
"href": "&page=2"
}
],
"entries": [
{
"content": {
"id": "dae_0_1_disk_3",
"tierType": 20,
"name": "DAE 0 1 Disk 3",
"pool": {
"id": "pool_1"
}
}
},
{
"content": {
"id": "dae_0_1_disk_4",
"tierType": 20,
"name": "DAE 0 1 Disk 4",
"pool": {
"id": "pool_1"
}
}
},
{
"content": {
"id": "dae_0_1_disk_5",
"tierType": 20,
"name": "DAE 0 1 Disk 5",
"pool": {
"id": "pool_1"
}
}
}
]
}
URI patterns
In a REST API, the client sends Uniform Resource Identifiers (URIs) to the server. Each URI
acts as a template for which you specify a resource type, ID, and desired action.
Basic URI patterns
The following table describes the basic URI patterns that the Unisphere Management
REST API supports:
URI patterns 19
JSON request components
Note
20 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON request components
URI for uploading a NAS server POST Uploads a NAS server configuration file to the
configuration file specified NAS server. You must POST the NAS
/upload/ server configuration file using a multipart/
<protocolType>/ form-data format, as if from a simple web
nasServer/ page.
<nasServerId> For more information, see Downloading and
uploading NAS server configuration files on
page 94.
URI for downloading an x.509 GET Downloads the specified x.509 certificate file
certificate file from the storage system to the local host.
/download/ For more information, see Downloading and
x509Certificate/ uploading x.509 certificates on page 97.
<cert_id>
URI for uploading an x.509 POST Uploads an x.509 certificate from the local
certificate file host to the storage system. You must POST
/upload/ the x.509 certificate file using a multipart/
x509Certificate/ form-data format, as if from a simple web
page.
For more information, see Downloading and
uploading x.509 certificates on page 97.
URI for downloading the GET Downloads the keystore file for Data at Rest
keystore file for Data at Rest Encryption from the storage system to the
Encryption local host.
/download/encryption/ For more information, see Downloading Data
keystore at Rest Encryption files on page 99.
URI for downloading the key GET Downloads the key manager audit logs and
manager audit logs and checksum files together as a single .zip file
checksum files for Data at Rest from the storage system to the local host.
Encryption For more information, see Downloading Data
/download/encryption/ at Rest Encryption files on page 99.
auditLogAndChecksum?
date=<YYYY-mm>
URI for downloading the GET Downloads the checksum file for a specified
checksum file for a specified audit log from the storage system to the local
key manager audit log host.
/download/encryption/ For more information, see Downloading Data
checksum? at Rest Encryption files on page 99.
URI patterns 21
JSON request components
URI for uploading license files POST Uploads an upgrade candidate or language
/upload/license pack file from the local host to the storage
system. You must POST the upgrade
candidate or language pack file using a
multipart/form-data format, as if from a
simple web page.
For more information, see Uploading license
files on page 103.
Note
Examples
Retrieving all instances of the user resource type
GET /api/types/user/instances
GET /api/instances/user/001
POST /api/types/user/instances
DELETE /api/instances/user/001
POST /api/instances/user/001/action/modify
22 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON request components
Verifying connectivity from the storage server to the specified LDAP server (an instance-
level action)
POST /api/instances/ldapServer/server1/action/verify
Recommending Ethernet ports to use for creating link aggregations (a class-level action)
POST /api/types/ethernetPort/action/RecommendForAggregation
GET /download/x509Certificate/vasa_http-vc1-cacert-1
POST /api/upload/license
Request body
A JSON request body for the Unisphere Management REST API consists of a collection of
name:value pairs for a single resource type. The request body has the following syntax:
l For number or boolean values:
{
<attributeName1>:<value1>,
<attributeName2>:<value2>,
.
.
.
}
l For IP, string, or datetime values:
{
<attributeName1>:"<value1>",
<attributeName2>:"<value2>",
.
.
.
}
For example, the request body for a create request for the user resource type could
contain the following values:
{
"name": "June",
"role": "operator",
"password": "Operator_EMC1!"
}
Request body 23
JSON request components
24 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 4
JSON response components
26 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON response components
When you log into the REST API, the response also includes a Set-Cookie header,
which contains information about the login session. The response can include other
cookies as well. You must include these cookies in each request that uses this login
session.
Component Description
"@base" Name of the base URI. The base URI is used at both the collection level
and the instance level.
"updated" Date and time the response was generated. The update time is used at
both the collection level and the instance level.
"links" List of one or more hyperlinks. Each hyperlink has two sub-components:
l "rel" - Relationship name.
l "href" - Link URI. This gets appended to the value of "@base" to
create the full link.
The first hyperlink in a response body is the self-link to the requested
resource, which informs users how the data was retrieved. Subsequent
hyperlinks in a response body are related URIs that the user can use to
retrieve additional information.
The hyperlinks are used at both the collection level and the instance
level.
"entryCount" Number of instances in the complete list. This component is used at the
collection level only, and is only returned if the with_entrycount
query parameter is set to true.
"entries" List of all instances in the current page of the specified collection that
meet the request criteria. This component is used at the collection level
only.
"content" Set of name:value pairs for one resource. Not all requests return
name:value pair content.
The format of a response body depends on how the request was processed and whether
the request was successful. The REST API supports the following types of response
bodies:
28 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON response components
404 Not Found GET, POST, and DELETE Resource does not exist.
requests This can be caused by:
l An invalid resource type name for a
GET instance request or action
POST request.
l An invalid ID for a specific instance
in a GET, POST, or DELETE
request.
l An invalid URI pattern.
405 Method Not POST and DELETE requests Specified resource does not support
Allowed the request's operation.
For example, requesting a DELETE on a
hardware resource can cause this error.
406 Not GET, POST, and DELETE Accept headers cannot be satisfied.
Acceptable requests
409 Conflict GET, POST, and DELETE Request cannot be completed due to a
requests conflict with the current state of the
resource.
The response body contains an error
message that describes the problem
with the request.
503 Service GET, POST, and DELETE The REST service is temporarily
Unavailabl requests unavailable.
e
Collection resource
A collection resource occurs in response to a GET collection request that results in a 200
OK HTTP status code. By default, the response body for a list contains the id for all
Collection resource 29
JSON response components
instances in the resource type collection. You can specify additional fields to return by
using the ?fields query parameter. You also can limit the amount of data returned by
using the ?page, ?per_page, ?filter, and ?compact query parameters.
The following example illustrates the components of a collection resource. It shows a
collection resource returned in response to a GET collection request for the alert
resource type. In this example, the query returns the id, severity, and description
of each alert in the storage system. Paging is set to 10 instances per page. Spaces
outside the quoted strings are used for readability, and are not significant.
Request
GET https://10.245.23.125/api/types/alert/instances
?fields=severity,description?per_page=10
Response
{
"@base": "https://10.245.23.125/api/types/alert/instances?
fields=severity,description
?per_page=10,id&per_page=2000"
Collection base URI and paging specification for this response. All links within this scope use this
base URI. The per_page parameter (?per_page=10) specifies 10 instances per page.
"updated": "2015-11-19T21:18:30.613Z",,
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
A self-link and a set of hyperlinks to the first, previous, and next pages in the list, relative to the
page in this response. In JSON, this is called an array. Only the relevant hyperlinks appear, so if
you are on page 1, the hyperlink to the previous page does not appear.
"entries": [
{
"@base": "https://10.245.23.125/api/instances/alert",
"updated": "2015-11-19T21:18:30.613Z",
"links": [
{
"rel": "self",
"href": "/alert_1"
}
],
"content": {
"id": "alert_1",
"severity": 4,
"description": "The DNS client configured for the NAS server has
faulted.
Contact your service provider."
}
}, {
"@base": "https://10.245.23.125/api/instances/alert",
"updated": "2015-11-19T21:18:30.613Z",
"links": [
{
"rel": "self",
"href": "/alert_2"
30 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON response components
}
],
"content": {
"id": "alert_2",
"severity": 6,
"description": "The component is operating normally. No action is
required."
}
},
List of all instances in the specified collection that meet the request criteria. The response
includes the following information for each instance:
l Instance base URI. This URI uses a different pattern than the collection URI.
l Date and time the response was generated.
l Self-link to this resource.
l Attribute values as a set of name:value pairs.
Using the ?compact=true query parameter suppresses the instance base URI and links.
Instance resource
An instance resource occurs in response to a GET instance request that results in a 200
OK HTTP status code. By default, this response body contains all available information
about the requested resource instance. (The same information appears in the "entries"
array of the collection resource.) You can limit the amount of data returned by using the ?
fields, and ?compact query parameters.
The following example illustrates the components of an instance resource. It shows an
instance resource returned in response to a GET instance request for the alert resource
type with an id of alert_1. Spaces outside the quoted strings are used for readability, and
are not significant.
Request
GET https://10.245.23.125/api/instances/alert/alert_1?
fields=severity,description
Response
{
"@base": "https://10.245.23.125/api/instances/alert",
Instance base URI. All links within this scope use this base URI.
"updated": "2015-11-19T21:36:40.360Z",
"links": [
{
"rel": "self",
"href": "/ alert_1"
}
],
Self-link to this resource. Using the ?compact=true query parameter suppresses this link.
Instance resource 31
JSON response components
"content": {
"id": "alert_1",
"severity": 4,
"description": "The DNS client configured for the NAS server has faulted.
Contact your service provider."
}
}
Returned content, in which the attribute values are a set of name:value pairs.
32 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON response components
Example 1 Example
Request
POST https://10.6.9.55/api/types/user/instances
Request body
{
"name": "Operator4",
"role": "operator",
"password":"Password456!"
}
Response
{
"@base": "https://10.6.9.55/api/instances/user",
Base URI for this response. All links within this scope use this base URI.
"updated": "2013-03-13T17:13:27.616Z",
"links": [
{
"rel": "self",
"href": "/user_Operator4"
}
],
"content": {
"id": "user_Operator4"
}
}
POST https://10.108.127.27/api/instances/user/user_Fredsmith/
action/modify?timeout=1
Response:
{
"tasks": [
{
"name": "Common UIS job",
"state": 0
}
],
"stateChangeTime": "2014-02-11T08:29:10.916Z",
"submitTime": "2014-02-11T08:29:10.351Z",
"estRemainTime": "00:01:40.000",
"progressPct": 0,
"methodName": "user.modify",
"id": "N-67",
"name": "Common UIS job",
"state": 2
}
Message entity
A message entity is an instance of the message global embedded type. It occurs in
response to an unsuccessful request; that is, a request that returns a 4nn or 5nn HTTP
status code. Unlike the response bodies returned by successful requests, a message
entity cannot be queried independently.
The server localizes message entity text according to the locale specified in the Accept-
languages request header or the language request parameter.
The following example shows a message entity returned from a request in which the alert
resource type is misspelled. For a description of the message entity attributes, see the
Unisphere Management REST API Reference Guide.
Request:
GET https://10.6.7.21/api/instances/alrt
34 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON response components
Response
{
"error": {
"errorCode": 131149829,
"httpStatusCode": 404,
"messages": [
{
"en-US": "The requested resource does not exist.
(Error Code:0x7d13005)"
}
],
"created": "2014-01-14T08:12:34.803Z"
}
}
Message entity 35
JSON response components
36 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 5
JSON encodings
JSON encodings 37
JSON encodings
38 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
JSON encodings
more of the
embedded
reference property
values.
In the example, ref
refers to a pool
resource with an id
value of 123.
[ <value1>,
<value2>, <value3>,...]
where:
l Square brackets enclose the list.
l Commas separate each value.
l <value> can be another list or any of the base value encoding formats.
JSON lists can be empty.
Examples
The following example shows an empty list:
"ScheduleDays" : [ ]
"scheduleDays" : [ 2 ]
"scheduleDays" : [ 2, 3, 4 ]
40 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 6
Preparing to make a request
42 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Preparing to make a request
Attribute Description
id Unique identifier of the loginSessionInfo
resource instance.
user Information about the user logged into this session, as
defined by the user resource type.
roles List of roles for the user logged into this session, as
defined by the role resource type.
For example:
"content": {
"id": "admin",
"roles": [
{
"id": "administrator"
}
],
"user": {
"id": "user_admin"
},
"idleTimeout": 3600,
"isPasswordChangeRequired": false
}
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
<TGC>
<All other cookies returned in the first GET request of the
session>
Operation:
POST
URI pattern:
/api/types/loginSessionInfo/action/logout
Body
{
“localCleanupOnly” : "true"
}
The server returns a 204 No Content HTTP status code and an empty response body
in response to a successful local logout.
If you set the localCleanupOnly argument to "false" or you do not specify it, the
client will log out of all storage systems in the overall SSO session.
Operation GET
:
URI /api/types/basicSystemInfo/instances
pattern:
Body Empty
If the request succeeds, it returns a 200 OK HTTP status code and basic system
information in the response body. If it does not succeed, it returns a 4nn or 5nn HTTP
status code and a message entity.
The following table describes the information returned in response to a successful
request to the basicSystemInfo resource type:
Argument Description
id Unique identifier of the basicSystemInfo resource instance.
model Model name of this storage system. This value comes from the model
attribute of the system resource.
name Name of this storage system. This value comes from the name
attribute of the system resource.
softwareVersion Software version of this storage system. This value comes from the
version attribute of the installedSoftwareVersion resource.
apiVersion Latest version of the REST API that this storage system supports.
earliestAPIVersion Earliest version of the REST API that this storage system supports.
44 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 7
Querying a resource
Querying a resource 45
Querying a resource
Accept: application/json
Operation
GET
URI pattern
/api/types/<resourceType>/instances
where <resourceType> is the resource type for the collection you want to return.
For additional functionality, such as paging, filtering, and localizing return
messages, you can append one or more request parameters to the URI.
Body
Empty.
If the request succeeds, the server returns a 200 OK HTTP status code and a collection
resource in the response body. If the request does not succeed, the server returns a 4nn
or 5nn HTTP status code and a message entity in the response body.
By default, the response to a GET collection request includes only the unique identifier
(id attribute) of the specified resource type. You can use the following request parameters
to customize the returned data:
Request Description
parameters
per_page and Groups returned resource type instances into chunks that form pages, and
page returns only the specified page.
filter Returns the resource type instances that match the specified criteria.
fields Requests data for a specified set of attributes.
compact Omits metadata from the resource type instances in the response.
The collection resource returned by a collection query contains a base URI and self-link
for each instance in the list. You can create an instance query for a particular instance by
appending the base URI to the instance's self-link.
Example
The following request returns the unique identifiers of all resources in the alert
resource collection. The fields parameter specifies that the value for the severity
and description attributes should also be returned. This example shows two returned
instances:
46 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Header
Accept: application/json
Request
GET https://10.108.53.216/api/types/alert/instances?
fields=severity,description
Request body
Empty.
Response body
"entries": [
{
"@base": "https://10.245.23.125/api/instances/alert",
"updated": "2015-11-19T21:18:30.613Z",
"links": [
{
"rel": "self",
"href": "/alert_1"
}
],
"content": {
"id": "alert_1",
"severity": 4,
"description": "The DNS client configured for the NAS
server has faulted. Contact your service provider."
}
},
{
"@base": "https://10.245.23.125/api/instances/alert",
"updated": "2015-11-19T21:18:30.613Z",
"links": [
{
"rel": "self",
"href": "/alert_2"
}
],
"content": {
"id": "alert_2",
"severity": 6,
"description": "The component is operating normally. No
action is required."
}
},
Operation
GET
URI pattern
/api/instances/<resourceType>/<id>
where <resourceType> is the resource type of the desired instance and <id> is the
unique identifier of the desired instance.
For additional functionality, such as returning specific attributes, paging, filtering,
and localizing return messages, you can append one or more request parameters to
the URI.
Body
Empty.
If the request succeeds, the server returns a 200 OK HTTP status code and an instance
resource in the response body. If the request does not succeed, the server returns a 4nn
or 5nn HTTP status code and a message entity in the response body.
By default, the response to a GET collection request includes only the unique identifier
(id attribute) of the specified resource type. You can use the following request parameters
to customize what data is returned:
Example
The following request returns the values for the id, name, and rpm attributes for the
disk resource instance with an id of dpe_disk_4. The id attribute is returned
automatically, while the fields parameter specifies that the value for the name and
rpm attributes should also be returned.
Header:
Accept: application/json
Request
GET https://10.108.53.216/api/instances/disk/dpe_disk_4?
fields=name,rpm
Response body
{
"@base": "https://10.108.53.216/api/instances/disk",
"updated": "2015-10-27T21:30:58.013Z",
"links": [
{
"rel": "self",
"href": "/dpe_disk_4"
}
],
"content": {
"id": "dpe_disk_4",
"name": "DPE Disk 4",
"rpm": 15000
48 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
}
}
Examples
The following request omits metadata from the returned alert resource type instances:
Header
Accept: application/json
Request
GET https://10.108.53.216/api/types/alert/instances?
fields=severity,component,message,resolution&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/alert/instances?
filter=severity eq
3&fields=severity,component,message,resolution,id&per_page=2000&co
mpact=true",
"updated": "2015-10-28T13:01:50.054Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "alert_4",
"severity": 3,
"component": {
"id": "nas_4",
"resource": "nasServer"
},
"message": "All DNS servers configured for DNS client of
NAS server DHWindows2 are not reachable.",
"resolution": "0"
}
},
{
"content": {
"id": "alert_7",
"severity": 3,
"component": {
"id": "nas_6",
"resource": "nasServer"
},
"message": "All LDAP servers configured for LDAP client
of NAS server DHWindows3 are not reachable.",
"resolution": "0"
}
}
]
}
50 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
l If an attribute has a valid, empty string value, the server returns the value as
<attribute>:"".
l Although a response normally contains only the requested attributes, this is not
guaranteed. You should therefore be prepared to ignore unrequested properties.
Example
The following request retrieves values for the slotNumber attribute in the disk
resource collection:
Header
Accept: application/json
Request
GET https://10.108.53.216/api/types/disk/instances?
fields=name,slotNumber&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?
fields=name,slotNumber,id&per_page=2000&compact=true",
"updated": "2015-10-28T13:09:19.005Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "dpe_disk_0",
"slotNumber": 0,
"name": "DPE Disk 0"
}
},
{
"content": {
"id": "dpe_disk_1",
"slotNumber": 1,
"name": "DPE Disk 1"
}
},
.
.
.
Note
page Identifies the page to As the first parameter on the request URI: ?
return in a response. If this page=<page_number>.
parameter is not specified, As a subsequent parameter on the request
the server returns all URI:
resource instances that
&page=<page_number>
meet the request criteria in
page 1. where <page_number> is the specific page
you want the server to return. If the page
parameter is not specified, the server returns
all resource type instances that meet the
request criteria on page 1.
with_entrycount When true, returns a link to As the first parameter on the request URI: ?
the last page in the with_entrycount=true.
response and also returns As a subsequent parameter on the request
the URI: &with_entrycount=true
entryCount:<count>
response component,
where <count> indicates the
number of resource
instances in the complete
list, irrespective of any
type of filtering.
The default for
with_entrycount is
false.
52 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Considerations
The REST API server limits the number of returned resource type instances in a page to
2000 and uses page number 1 as the default page. The per_page and page
parameters can override these defaults.
When a query request includes both the per_page and page parameters, the server
does the following:
1. Constrains the data based on the filter query parameter, if it is specified in the
request.
2. Returns a chunk of data on a single page, as specified by the per_page and page
parameters.
The server removes extra data before returning data to the client. Because of this, using
the per_page and page parameters can save bandwidth.
To help you access other pages of response data, the REST API returns links to the
previous and next page. If you set the with_entrycount parameter to true, the REST
API also returns a link to the last page in the response and the number of resource
instances in the complete list, irrespective of any filtering. This information can help you
create meaningful scroll bars for responses in a GUI application.
Note
Even when two requests are the same, the contents of the returned list can change
between the requests. The requests are independent, and adjacent pages can have
missing or overlapped data due to changes in the data between the queries. You can use
the orderby request parameter to ensure that results are consistent between requests
with different paging.
Accept: application/json
Request
https://10.103.73.108/api/types/disk/instances?per_page=2&page=3
Response
{
"@base": "https://10.103.73.108/api/types/disk/instances?
fields=name,id&per_page=2",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "&page=3"
},
{
"rel": "first",
"href": "&page=1"
},
{
"rel": "prev",
"href": "&page=2"
},
{
"rel": "next",
"href": "&page=4"
}
],
"entries":
[
{
"@base": "https://10.103.73.108/api/instances/disk",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "/dpe_disk_4"
}
],
"content":
{
"id": "dpe_disk_4",
"name": "DPE Disk 4"
}
},
{
"@base": "https://10.103.73.108/api/instances/disk",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "/dpe_disk_5"
}
],
"content":
{
"id": "dpe_disk_5",
"name": "DPE Disk 5"
}
}
]
}
Accept: application/json
54 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Request
https://10.103.73.108/api/types/disk/instances?
fields=name&per_page=2&page=3&with_entrycount=true
Response
{
"@base": "https://10.103.73.108/api/types/disk/instances?
fields=name,id&per_page=2",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "&page=3"
},
{
"rel": "first",
"href": "&page=1"
},
{
"rel": "prev",
"href": "&page=2"
},
{
"rel": "next",
"href": "&page=4"
}
{
"rel": "last",
"href": "&page=13"
}
],
"entryCount": 25,
"entries":
[
{
"@base": "https://10.103.73.108/api/instances/disk",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "/dpe_disk_4"
}
],
"content":
{
"id": "dpe_disk_4",
"name": "DPE Disk 4"
}
},
{
"@base": "https://10.103.73.108/api/instances/disk",
"updated": "2016-01-19T06:51:53.510Z",
"links":
[
{
"rel": "self",
"href": "/dpe_disk_5"
}
],
"content":
{
"id": "dpe_disk_5",
"name": "DPE Disk 5"
}
}
]
}
Note
Syntax
As the first parameter on the request URI: ?filter=<filter_expr>
As a subsequent parameter on the request URI: &filter=<filter_expr>
where <filter_expr> is defined by the following syntax using Backus-Naur Form
(BNF):
56 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
| sum_expr
| concatList_expr
Note
The interpretation of gt, ge, lt, and le is type dependent. For example, gt used with
dateTime attributes means the date value to the right of gt must be more recent than
the date value to the left of gt.
%25 to represent %
%5F to represent _
%5C to represent /
For example:
ServerName lk "server%25"
matches instances where ServerName equals server1, server2,
server3, server10, and so forth. In this example, %25 is the
encoded character for %.
ServerName lk "serv%5Fer"
58 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
in IN (Like the SQL IN function) Tests for a match against one of a list of
values.
For example:
ServerName in ("server1", "server2", "server3")
matches instances where ServerName equals server1, server2, or
server3.
Note
Accept: application/json
Request
GET https://10.108.53.216/api/types/alert/instances?
fields=severity,component,message,resolution,resource&filter=sever
ity eq 3&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/alert/instances?
filter=severity eq
3&fields=severity,component,message,resolution,id&per_page=2000&co
mpact=true",
"updated": "2015-10-28T13:01:50.054Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "alert_4",
"severity": 3,
"component": {
"id": "nas_4",
"resource": "nasServer"
},
"message": "All DNS servers configured for DNS client of
NAS server DHWindows2 are not reachable.",
"resolution": "0"
}
},
{
"content": {
"id": "alert_7",
"severity": 3,
"component": {
"id": "nas_6",
"resource": "nasServer"
},
"message": "All LDAP servers configured for LDAP client
of NAS server DHWindows3 are not reachable.",
"resolution": "0"
}
}
]
}
Accept: application/json
Request
GET https://10.108.53.216/api/types/user/instances?
fields=name,role &filter=name lk \"userA%\"&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/user/instances?
fields=name,id,role.id&per_page=2000&compact=true",
"updated": "2015-10-28T13:15:20.183Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "user_admin",
"name": "admin",
"role": {
"id": "administrator"
}
}
}
]
}
60 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
GET https://10.108.53.216/api/types/user/instances?
fields=name,role&filter=role.id lk "admin%25"&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/user/instances?
filter=role.id lk \"admin%
\"&fields=name,id,role.id&per_page=2000&compact=true",
"updated": "2015-10-28T13:17:50.371Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "user_admin",
"name": "admin",
"role": {
"id": "administrator"
}
}
}
]
}
Note
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.216/api/types/disk/instances?
fields=name,size &orderby=name&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?
fields=name,size&orderby=name&per_page=2000&compact=true",
"updated": "2015-10-28T13:29:39.374Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "dpe_disk_0",
"name": "DPE Disk 0",
"size": 30565990400
}
},
{
"content": {
"id": "dpe_disk_1",
"name": "DPE Disk 1",
"size": 30565990400
}
},
{
62 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
"content": {
"id": "dpe_disk_2",
"name": "DPE Disk 2",
"size": 30565990400
}
},
.
.
.
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.216/api/types/disk/instances?
fields=name,parentDpe.name&orderby=parentDpe.name&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?
fields=id,name,parentDpe.name,parentDpe.id&orderby=parentDpe.name&
per_page=2000&compact=true",
"updated": "2015-10-28T18:53:40.256Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "disk_0",
"name": "Disk 0",
"parentDpe": {
"id": "dpe_a",
"name": "DPE_A"
}
}
},
{
"content": {
"id": "disk_1",
"name": "Disk 1",
"parentDpe": {
"id": "dpe_b",
"name": "DPE_B"
}
}
},
{
"content": {
"id": "disk_2",
Note
You can use @sum without the groupby parameter, if you are grouping by the id
attribute of a resource.
Syntax
As the first parameter on the request URI: ?groupby=<groupby_expr>
As a subsequent parameter on the request URI: &groupby=<groupby_expr>
where <groupby_expr> is defined by the following syntax using Backus-Naur Form
(BNF):
In the syntax for <groupby_expr>, prop_expr is the name of an attribute. Its type
can be int,float, string, InetSocketAddress, Date, Boolean, Enum, or a list
whose element is among the above types.
Note
Example - Summarizing the size and rawSize of drives grouped by drive type
The following request returns a summary of size and rawSize of drives based on the type
to which they belong.
64 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Header
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.216/api/types/disk/instances?
fields=diskTechnology,abc::@sum(size),def::@sum(rawSize)&groupby=d
iskTechnology"&compact=true
Response
{
"@base": "https://10.103.75.136/api/types/disk/instances?
fields=type,abc::@sum(size),def::@sum(rawSize)&groupby=type",
"updated": "2014-05-30T06:57:24.045Z",
"links": [
{"rel": "self",
"href": "&page=1"
}
]
"entries": [
{
"updated": "2015-11-12T10:07:05.467Z",
"content": {
"diskTechnology": 1,
"abc": 285741154304,
"def": 381681664000
}
}
]
}
Note
FunctionName : ‘@count’
| ‘@enum’
| ‘@enumString’
| ‘@sum’
| ‘@str’
66 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Note
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/pool/instances
?fields=sizeUsed,sizeTotal,percent::sizeUsed*100/sizeTotal
&compact=true&with_entrycount=true
{
"@base": "https://10.108.53.165/api/types/pool/instances
?fields=sizeUsed,sizeTotal,percent::sizeUsed*100/sizeTotal,
id&per_page=2000&compact=true",
"updated": "2016-06-02T02:54:05.489Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 1,
"entries": [
{
"content": {
"id": "pool_1",
"sizeTotal": 118916907008,
"sizeUsed": 15837691904,
"percent": 13.318284
}
}
]
}
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/storageResource/instances
?fields=type,lunName::type eq 8 ? name : ""
&compact=true&with_entrycount=true
{
"@base": "https://10.108.53.165/api/types/storageResource/
instances?fields=type,lunName::type eq 8 ? name :
\"\",id&per_page=2000&compact=true",
"updated": "2016-06-02T02:58:32.695Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 3,
"entries": [
{
"content": {
"id": "res_1",
"type": 1,
"lunName": ""
}
},
{
"content": {
"id": "res_2",
"type": 1,
"lunName": ""
}
68 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
},
{
"content": {
"id": "sv_1",
"type": 8,
"lunName": "LUN00"
}
}
]
}
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.216/api/types/storageResource/instances?
fields=name,type,newName::@concat(name, type) &compact=true
{
"@base": "https://10.108.53.216/api/types/storageResource/
instances?
fields=name,type,newName::@concat(name,type),id&per_page=2000&comp
act=true",
"updated": "2015-10-28T14:51:23.427Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "res_1",
"type": 1,
"name": "FileSystem1",
"newName": "FileSystem11"
}
},
{
"content": {
"id": "sv_1",
"type": 8,
"name": "LUNPersonal",
"newName": "LUNPersonal8"
}
},
{
"content": {
"id": "sv_2",
"type": 8,
"name": "LUNCorporate",
"newName": "LUNCorporate8"
}
}
]
}
Example 4 - Defining a new attribute by concatenating elements from a list into a single
string value
The following example defines a new attribute called newProp for pool resources by
concatenating the values of the tiers.name attribute. It concatenates these
values in descending order and separates them with commas.
Header
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.49.220/api/types/pool/instances
?fields=id,tiers.name,newProp::
@concatList(tiers.name,separator=",",order="desc")
&compact=true
{
"@base": "https://10.108.49.220/api/types/pool/instances?
fields=id,tiers.name,newProp::@concatList(tiers.name,separator=\",
\",order=\"desc\")&per_page=2000&compact=true",
"updated": "2016-06-02T03:07:13.424Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 1,
"entries": [
{
"content": {
"id": "pool_1",
"tiers": [
{
"name": "Extreme Performance"
},
{
"name": "Performance"
},
{
"name": "Capacity"
}
],
"newProp": "Performance,Extreme Performance,Capacity"
}
}
70 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Example 5 - Defining a new attribute by using the text value of an attribute defined as an
enum
The following example defines a new attribute called newProp for each disk resource
by using the text value of the tierType attribute, which is an enum.
Header
Accept: application/json
Content-Type: application/json
Request
GET https://10.108.53.165/api/types/disk/instances?fields=id,
newProp::@enum(tierType)&filter=tierType != 0 &compact=true
&with_entrycount=true
{
"@base": "https://10.108.53.165/api/types/disk/instances?
filter=tierType != 0
&fields=id,newProp::@enum(tierType)&per_page=2000&compact=true",
"updated": "2016-06-02T03:02:42.236Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 7,
"entries": [
{
"content": {
"id": "dpe_disk_0",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_1",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_2",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_3",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_4",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_5",
"newProp": "Performance"
}
},
{
"content": {
"id": "dpe_disk_6",
"newProp": "Performance"
}
}
]
}
Example 6 - Defining a new attribute by using the localized text value of an attribute
defined as an enum
The following example defines a new attribute for the capabilityProfile resource
type called se by using the localized text of the spaceEfficiencies attribute, which
is a collection enum. In this example, the text is localized to American English.
Header
Accept: application/json
Content-Type: application/json
accept-language: en_US
Request
GET https://10.103.73.73/api/types/capabilityProfile
/instances?fields=se::@enumString(spaceEfficiencies)
&compact=true&with_entrycount=true
{
"@base": "https://10.103.73.73/api/types/capabilityProfile/
instances?
fields=se::@enumString(spaceEfficiencies),id&per_page=2000&compact
=true",
"updated": "2016-06-02T03:09:44.668Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entryCount": 1,
"entries": [
{
"content": {
"id": "cp_1",
"se": [
"Thin",
"Thick"
]
}
}
]
}
72 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
Accept: application/json
Request
https://10.108.53.216/api/types/disk/instances ?
fields=name,pool,parentDpe,parentDpe.name&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?
fields=name,parentDpe.name,id,pool.id,parentDpe.id,parentDpe.id&pe
r_page=2000&compact=true",
"updated": "2015-10-28T15:12:40.655Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "dpe_disk_0",
"name": "DPE Disk 0",
"parentDpe": {
"id": "dpe",
"name": "DPE_1"
}
}
},
{
"content": {
"id": "dpe_disk_1",
"name": "DPE Disk 1",
"parentDpe": {
"id": "dpe",
"name": "DPE_2"
}
}
},
.
.
.
Accept: application/json
Request
GET https://10.108.53.216/api/types/alert/instances?
fields=severity,component,message,component.resource&filter=compon
ent.resource eq "nasServer"
Response
{
"@base": "https://10.108.53.216/api/types/alert/instances?
filter=component.resource eq \"nasServer
\"&fields=severity,component,message,component.resource,id&per_pag
e=2000",
"updated": "2015-10-28T19:04:21.310Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"@base": "https://10.108.53.216/api/instances/alert",
"updated": "2015-10-28T19:04:21.310Z",
"links": [
{
"rel": "self",
74 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
"href": "/alert_3"
}
],
"content": {
"id": "alert_3",
"severity": 6,
"component": {
"id": "nas_1",
"resource": "nasServer"
},
"message": "Network interface N/A is operating normally"
}
},
{
"@base": "https://10.108.53.216/api/instances/alert",
"updated": "2015-10-28T19:04:21.310Z",
"links": [
{
"rel": "self",
"href": "/alert_4"
}
],
"content": {
"id": "alert_4",
"severity": 3,
"component": {
"id": "nas_4",
"resource": "nasServer"
},
"message": "All DNS servers configured for DNS client of
NAS server DHWindows2 are not reachable."
}
},
.
.
.
Accept: application/json
Request
GET https://10.108.53.216/api/types/disk/instances?
fields=id,name,parentDpe.name &orderby=parentDpe.name&compact=true
Response
{
"@base": "https://10.108.53.216/api/types/disk/instances?
fields=id,name,parentDpe.name,parentDpe.id&orderby=parentDpe.name&
per_page=2000&compact=true",
"updated": "2015-10-28T18:09:32.692Z",
"links": [
{
"rel": "self",
"href": "&page=1"
}
],
"entries": [
{
"content": {
"id": "disk_1",
"name": "Disk 1",
"parentDpe": {
"id": "dpe",
"name": "DPE_1"
}
}
},
{
"content": {
"id": "disk_0",
"name": "Disk 0",
"parentDpe": {
"id": "dpe",
"name": "DPE_2"
}
}
},
{
"content": {
"id": "disk_2",
"name": "Disk 2",
"parentDpe": {
"id": "dpe",
"name": "DPE_3"
}
}
},
.
.
.
76 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Querying a resource
l If the requested locale is not available, the API defaults to en-US instead of returning
an error message.
l All time values are supplied in Coordinated Universal Time (UTC) format.
l The language request parameter is useful for testing from a plain browser or from
an environment where headers are inconvenient.
Example 1: Using the Accept-language request header to localize
The following request returns the alert resource instances and specifies that the
response be localized to Japanese.
Request Header
Accept: application/json
Accept-language:ja-JP
Request
GET https://10.6.7.41/api/types/alert/instances?
fields=message,component,messageId,severity,resolution,timestamp,d
escription&compact=true
Response
{
"@base": "https://10.6.7.41/api/types/alert/instances?
fields=message,component,messageId,severity,resolution,timestamp,
description&compact=true",
"updated": "2014-01-16T03:08:53.889Z",
"links": [
{
"rel": "self",
"href": "&page=1"
},
{
"rel": "next",
"href": "&page=2"
},
],
"entries": [
{
"content": {
"message": "ストレージ システムのライト キャッシュが無効に
なっています。",
"id": 5962,
"component": "AlertRaidppSources",
"messageId": "29199",
"severity": 4,
.
.
.
Accept: application/json
Request
GET https://10.6.7.41/api/types/alert/instances?
fields=message,component,messageId,severity,resoultion,
timestamp&compact=true &language=ja-JP
78 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 8
Creating other types of requests
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/api/types/<resourceType>/instances/
where <resourceType> is the resource type of the instance you want to create.
Body
{
"argument1":<value>,
"argument2":<value>,
"argument3":<value>
.
.
.
}
where the comma-separated list contains all required arguments and any optional
arguments. Use double quotes around a string, dateTime, or IPAddress value.
Note
The unique identifier of the new instance is generated automatically by the server.
If the request succeeds, it returns a 201 Created HTTP status code and a minimal
instance resource in the response body. This resource contains the id argument, a self-
link for the new resource instance, and the arguments used to populate the new instance.
If the request does not succeed, the server returns a 4nn or 5nn HTTP status code and a
message entity in the response body.
Example
The following request creates a new instance of the user resource type.
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
80 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
Request
POST https://10.245.23.125/api/types/user/instances
Request body
{
"name":"user_Operator5",
"role":"operator",
"password":"MyPassword1!"
}
Response body
.
.
.{
"@base": "https://10.245.23.125/api/instances/user",
"updated": "2015-11-24T21:57:35.233Z",
"links": [
{
"rel": "self",
"href": "/user_Operator5"
}
],
"content": {
"id": "user_Operator5"
}
}
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/api/instances/<resourceType>/<id>/action/modify
where <resourceType> is the resource type of the instance you want to modify
and <id> is the unique identifier of the instance you want to modify.
Body
{
"argument1":<value>,
"argument2":<value>,
.
.
.
}
where the comma-separated list contains all required arguments and any optional
arguments. Use double quotes around a string, dateTime, or IPAddress value.
If the request succeeds, it returns a 204 No Content HTTP status code and an empty
response body. If the request does not succeed, the server returns a 4nn or 5nn HTTP
status code in the response header and a message entity in the response body.
Example
The following request changes the role value to storageadmin for the user resource
that has an id of user_June:
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
POST https://10.108.127.27/api/instances/user/user_June/action/
modify
Request body
{
"role":"storageadmin"
}
Response body
Empty.
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
82 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
If a resource type has request arguments for the DELETE operation, you must also
use the following header:
Content-Type:
application/json
Operation
DELETE
URI pattern
/api/instances/<resourceType>/<id>
where <resourceType> is the resource type of the instance you want to delete,
and <id> is the unique identifier of the resource you want to delete.
Body
For most resource types, the body of a DELETE request is empty. However, if a
resource type has request arguments for the DELETE operation, they are passed as
a comma-separated list of name:value pairs.
If the request succeeds, it returns a 204 No Content HTTP status code and an empty
response body. If the request does not succeed, the server returns a 4nn or 5nn HTTP
status code in the response header and a message entity in the response body.
Example
The following request deletes the user resource that has an id of user_June:
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
DELETE https://10.108.127.27/api/instances/user/user_June
Request body
Empty.
Response body
Empty.
the ipPort resource type's Recommend operation to recommend ports on the specified
SP to use for creating NAS servers.
To perform a resource-specific action on a resource type, use the following request
components:
Headers
For operations without request arguments:
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/api/types/<resourceType>/action/<operationName>
where <resourceType> is the resource type of the instance for which you want to
perform the desired action.
For additional functionality, such as making the request an asynchronous request
and localizing response messages, you can append one or more request parameters
to the URI.
Body
For operations without request arguments:
Empty.
For operations with input data:
{
"argument1":value,
"argument2":value,
.
.
.
}
where the comma-separated list contains all required arguments and any optional
arguments. Use double quotes around a string, dateTime, or IPAddress value.
The success response for a class-level resource-specific action differs depending on
whether the action performed has output data:
l For actions that do not have output data, a successful request returns 204 No
Content HTTP status code and an empty response body.
84 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
l For actions that have output data, a successful request returns 200 OK HTTP status
code, and the body will have the specified out attributes in an instance resource
response body.
If the request does not succeed, the server returns a 4nn or 5nn HTTP status code in the
response header and a message entity in the response body
Example
The following example uses the Recommend operation for the ipPort resource type to
recommend ports on the specified SP to use for creating NAS servers:
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
POST https://10.108.125.206/api/types/ipPort/action/
recommendForInterface
Request body
{
"storageProcessor":{"id":"spa"}
}
Response body
{
"@base": "_https://10.108.125.206/api/types/ipPort/action/
RecommendForInterface",
"updated": "2013-04-24T20:46:53.730Z",
"links":
[
{
"rel": "self",
"href": "/"
}
],
"content":
{
"recommendedPorts":
[
{
"spa_iom_0_eth1"
},
{
"spa_iom_0_eth2"
}
]
}
}
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/api/instances/<resourceType>/<id>/action/<actionName>
where <resourceType> is the resource type of the instance for which you want to
perform the desired action.
For additional functionality, such as making the request an asynchronous request
and localizing response messages, you can append one or more request parameters
to the URI.
Body
For operations without request arguments:
Empty.
For operations with input data:
{
"argument1":<value>,
"argument2":<value>,
.
.
.
}
where the comma-separated list contains all required arguments and any optional
arguments. Use double quotes around a string, dateTime, or IPAddress value.
86 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
POST https://10.108.125.206/api/types/
ethernetPort/action/recommendForInterface
Request body
{
"storageProcessor":{"id":"spa"}
}
Response body
{
"@base": "_https://10.108.125.206/api/types/ethernetPort/action/
RecommendForInterface",
"updated": "2013-04-24T20:46:53.730Z",
"links":
[
{
"rel": "self",
"href": "/"
}
],
"content":
{
"recommendedPorts":
[
{
"spa_iom_0_eth1"
},
{
"spa_iom_0_eth2"
}
]
}
}
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/api/types/job/instances/
Body
For each nested request:
{
"name" : <request_name>",
"object" : <request_resource_type>
"action": <request_action>,
"parametersIn":{<request_arguments>}
}
where:
l <request_name> is the user-specified name of the nested request. The name
must be unique within the aggregated request. It can consist of alphabetic
characters, digits, and underscores.
l <request_resource_type> is the target resource type of the nested
request, for example, pool or nasServer.
l <request_action> is the target action for the nested request, for example,
Create or Modify.
l <request_arguments> are the regular arguments for the specified request
action, expressed as name-value pairs or lists.
88 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
Note
For an instance-level action, you must specify the target instance identifier in the
body.
where:
l <task_request_name> is the name of the nested request that is passing the
value.
l <out_parameter_name> is the name of the input argument in the nested
request to receive the value.
If the request succeeds, it returns a 201 Created HTTP status code for synchronous
requests or a 202 Accepted HTTP status code for asynchronous requests, along with a
minimal instance resource in the response body. This resource contains the id
argument, a self-link for the new resource instance, and the arguments used to populate
the new instance.
If the request does not succeed, the server returns a 4nn or 5nn HTTP status code and a
message entity in the response body.
Usage
All nested requests must share the same HTTP headers and URL parameters.
Example
The following example shows an aggregated request that creates the following resources:
l A pool named POOL40388.
l A LUN named testLun, which is associated with the new pool.
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
POST https://10.108.53.216/api/types/job/instances?timeout=0
Request body
{
"tasks": [{
"object": "pool",
"action": "create",
"name": "poolStep",
"parametersIn": {
"addRaidGroupParameters": [{
"raidType": 1,
"numDisks": 5,
"stripeWidth": 5,
"dskGroup": {
"id": "dg_18"
}
}],
"name": "POOL40388"
}
},
{
"object": "storageResource",
"action": "createLun",
"name": "lunStep",
"parametersIn": {
"lunParameters": {
"pool": "@poolStep.id",
"isThinEnabled": 0,
"size": 1073741824
},
"name": "testLun"
}
}],
"description": "CreateLUN"
}
{
"@base": "https://10.103.73.112/api/instances/job",
"updated": "2016-03-03T15:56:17.785Z",
"links": [{
"rel": "self",
"href": "/B-42"
}],
"content": {
"id": "B-42"
}
}
Note
For this example, a successful return code is a 201 Created HTTP status code,
because the request is a synchronous request.
90 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Creating other types of requests
?timeout=<seconds>
As a subsequent parameter on the request URI:
&timeout=<seconds>
Usage
The following considerations apply to asynchronous requests:
l A valid asynchronous request returns a 202 Accepted HTTP status code and a
minimal job resource instance in the response body.
l Depending on the type of error, an invalid asynchronous request can either return
immediately or return after the timeout with the appropriate error code in the
response header and a message entity in the response body.
To view the status of an asynchronous request, retrieve data for the appropriate job
resource instance. For example, if an asynchronous modify user request returns a job
resource instance with an ID of N-67, you can use an instance query to retrieve the
asynchronous request data from this job resource.
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
POST https://10.108.53.216/api/instances/user/user_1/action/
modify?timeout=0
Request body
{
"role":"operator"
}
Response body
{
"id": "N-116",
"state": 2,
"instanceId": "root/emc:EMC_UEM_TransactionJobLeaf
%InstanceID=N-116",
"description": "job.uisconfig.job.ModifyUser",
"stateChangeTime": "2015-11-20T18:53:03.875Z",
"submitTime": "2015-11-20T18:53:03.680Z",
"estRemainTime": "00:01:40.000",
"progressPct": 0,
"tasks": [
{
"state": 0,
"name": "job.uisconfig.job.ModifyUser"
}
],
"owner": "System",
"clientData": "",
"methodName": "user.modify",
"isJobCancelable": false,
"isJobCancelled": false
}
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.53.216/api/instances/job/N-116?
fields=description,tasks
Request body
Empty.
Response body
{
"@base": "https://10.108.53.216/api/instances/job",
"updated": "2015-11-20T18:59:23.635Z",
"links": [
{
"rel": "self",
"href": "/N-116"
}
],
"content": {
"id": "N-116",
"description": "Modify User",
"tasks": [
{
"state": 2,
"name": "job.uisconfig.job.ModifyUser172",
"description": "Modify User",
"messages": [
{
"errorCode": 0,
"messages": [
{
"locale": "en_US",
"message": "Success"
}
]
}
]
}
]
}
}
92 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 9
Downloading and uploading files
File Description
LDAP schema When configuring NAS server LDAP settings, the NAS
server attempts to connect to the LDAP server and
detect the default LDAP schema, based on the LDAP
type. You can download the default schema file,
customize it, and then upload the customized file to
the NAS server. If the schema is valid, it is applied to
the NAS server configuration.
LDAP Configuration Authority (CA) If the storage system uses LDAPS (LDAP using SSL) to
certificate communicate with the LDAP server, you might be
required to upload the CA certificate to the NAS
server. If the verification fails, or the LDAP server does
not present a certificate, the connection is refused.
User mapping file (applies to When configuring a multiprotocol NAS server, the
multiprotocol NAS servers only) following types of user mappings are required:
l A Windows user must map to a corresponding
Unix user in order to access a file system.
l A Unix user must map to a corresponding
Windows user when using NFS to access a file
system configured with a Windows access policy.
Note
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
94 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
Operation
GET
URI pattern
/download/<protocolType>/nasServer/<nasServerId>
Body
Empty.
A successful download request returns a 200 OK HTTP status code. If the request does
not succeed, the server returns a 4nn or 5nn HTTP status code in the response header
and a message entity in the response body.
Syntax for uploading a configuration file from a NAS server
To upload a configuration file from the local host to a NAS server, use the following
request components:
Header
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
Operations
POST
URI pattern
/upload/<protocolType>/nasServer/<nasServerId>
Body
None.
Usage
You must POST the configuration file using a multipart/form-data format as if from a
simple web page form, like that shown in the following example:
<html>
<body>
A successful upload request returns 200 OK HTTP status code. If the request does not
succeed, the server returns a 4nn or 5nn HTTP status code in the response header and a
message entity in the response body.
Example 1: Downloading an LDAP schema file from a NAS server
The following example downloads an LDAP schema file from NAS server nas_1 to the
local host.:
Header
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.253.216/download/1/nasServer/nas_1
Request body
Empty.
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
filename="ldap1.conf"
96 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
Request body
Empty.
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
Operation
GET
URI pattern
/download/x509Certificate/<cert_id>
Body
Empty.
A successful download request returns a 200 OK HTTP status code. If the request does
not succeed, the server returns a 4nn or 5nn HTTP status code in the response header
and a message entity in the response body.
Syntax for uploading a configuration file from a NAS server
To upload an x.509 certificate from the local host to the storage system, use the following
request components:
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
Operations
POST
URI pattern
/upload/x509Certificate
Body
See the Usage row.
Usage
You must POST the certificate file using a multipart/form-data format as if from a
simple web page form, like that shown in the following example:
For a list of enumeration values, see the Unisphere Management REST API Reference
Guide.
A successful upload request returns a 200 OK HTTP status code. If the request does
not succeed, the server returns a 4nn or 5nn HTTP status code in the response header
and a message entity in the response body.
Example 1: Downloading an x.509 certificate
The following example downloads the vasa_http-vc1-cacert-1 certificate file to
the local host:
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.53.216/download/x509Certificate/vasa_http-vc1-
servercert-1
Request body
Empty.
98 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
Accept: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
<html>
<body>
<form enctype="multipart/form-data" method="post"
action="https://10.108.253.216/upload/x509Certificate">
<input type="file" name="filename"/>
<input type="text" name="paramMap"/>
<input type="submit"/>
</form>
</body>
filename="certificate1.pem"
paramMap={"type":1,"service":2, "passphrase":"ddd","scope":
{"nasServer":"nas_0"}}
Request body
Empty.
Accept: application/json
X-EMC-REST-CLIENT: true
Operation
GET
URI pattern
/download/encryption/keystore
Body
Empty.
A successful download request returns a 200 OK HTTP status code. If the request does
not succeed, the server returns a 4nn or 5nn HTTP status code in the response header
and a message entity in the response body.
Syntax for downloading key manager audit logs and checksum files together
To download the key manager audit logs and checksum files together as a single .tar file
from the storage system to the local host, use the following request components:
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
Operations
GET
URI pattern
/download/encryption/auditLogAndChecksum?date=<YYYY-mm>
where <YYYY-mm> is the year and month of the audit log to download. If no date is
specified, the entire audit log is downloaded.
Body
Empty.
A successful download request returns 200 OK HTTP status code. If the request does not
succeed, the server returns a 4nn or 5nn HTTP status code in the response header and a
message entity in the response body.
Syntax for downloading the checksum file for a specified audit log
To download the checksum file for a specified audit log from the storage system to the
local host, use the following request components:
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
Operations
GET
URI pattern
/download/encryption/checksum?audit_log=<audit_log_file_name>
100 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
Body
Empty.
A successful download request returns a 200 OK HTTP status code. If the request does
not succeed, the server returns a 4nn or 5nn HTTP status code in the response header
and a message entity in the response body.
Example 1: Downloading the keystore file
The following example downloads the keystore file to the local host.
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.53.216/download/encryption/keystore
Request body
Empty.
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.253.216/download/encryption/
auditLogAndChecksum?date=2015-11
Request body
Empty.
Headers
Accept: application/json
X-EMC-REST-CLIENT: true
Request
GET https://10.108.253.216/download/encryption/checksum ?
audit_log=
APM00143414369_2015_02_03_19_50_38_0000000000000001_00000000000000
2C.log
Request body
Empty.
Note
When you upload an upgrade candidate file onto the storage system, it replaces the
previous version. There can only be one upgrade candidate on the system at a time.
For information about the candidateSoftwareVersion resource type, see the
Unisphere Management REST API Reference Guide.
Syntax
To upload a system software upgrade candidate or language pack file, use the following
components:
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operation
POST
URI pattern
/upload/files/types/candidateSoftwareVersion
Body
Empty.
102 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
Usage
You must post the upgrade file using a multipart/form-data format as if from a
simple web page form, like that shown in the following example:
A successful upload request returns 200 OK HTTP status code. If the request does not
succeed, the server returns a 4nn or 5nn HTTP status code in the response header and a
message entity in the response body.
Example
The following example uploads the upgrade candidate file update1.gpg from the local
host to the storage server:
Header
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
<html>
<body>
<form enctype="multipart/form-data" method="post"
action="https://10.108.253.216/upload/files/types/
candidateSoftwareVersion
<input type="file" name="filename"/>
<input type="submit"/>
</form>
</body>
filename="update1.gpg"
Request body
Empty.
Syntax
To upload a license file, use the following components:
Headers
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Operations
POST
URI pattern
/upload/license
Body
Empty.
Usage
You must POST the upgrade file using a multipart/form-data format as if from a
simple web page form, like that shown in the following example:
A successful upload request returns 200 OK HTTP status code. If the request does not
succeed, the server returns a 4nn or 5nn HTTP status code in the response header and
a message entity in the response body.
Example
The following example uploads the license file license1.lic from the local host to the
storage server:
Header
Accept: application/json
Content-Type: application/json
X-EMC-REST-CLIENT: true
EMC-CSRF-TOKEN: <token>
Request
<html>
<body>
<form enctype="multipart/form-data" method="post"
action="https://10.108.253.216/upload/license"
<input type="file" name="filename"/>
104 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Downloading and uploading files
<input type="submit"/>
</form>
</body>
filename="license1.lic"
Request body
Empty.
106 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
CHAPTER 10
Perl example
#!/usr/bin/perl
#Required Debian Packages: apt-get install perl libwww-perl libjson-
perl
use strict;
use LWP::UserAgent;
use HTTP::Cookies;
use JSON;
use Data::Dumper;
my $IP_ADDR = '';
my $USER = '';
my $PASS = '';
my $EMC_CSRF_TOKEN;
use constant {
GET => 'GET',
POST => 'POST',
DELETE => 'DELETE',
};
my $ua = LWP::UserAgent->new(
ssl_opts => { SSL_verify_mode => 'SSL_VERIFY_NONE'},
cookie_jar => {}
);
my $json = JSON->new->allow_nonref();
sub request{
#http://perl101.org/subroutines.html
my $type = $_[0];
my $url = $_[1];
my $post_data = $_[2];
108 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide
Perl example
if($ua->cookie_jar->as_string eq ""){
$req->authorization_basic($USER, $PASS);
}
if (defined $post_data){
$req->content( $json-
>encode($post_data));
}
my $resp = $ua->request($req);
if ($resp->is_success) {
if(!defined($EMC_CSRF_TOKEN)){
$EMC_CSRF_TOKEN = $resp-
>header('EMC-CSRF-TOKEN');
}
my $message = $resp->decoded_content;
#print "Received reply: $message\n";
return $json->decode($message);
} else {
print "HTTP error code: ", $resp->code,
"\n";
print "HTTP error message: ", $resp->message, "\n";
return 0;
}
#print $ua->cookie_jar->as_string;
}
sub getInputLine{
my $lowercase = $_[0];
my $question = $_[1];
my $cmp = $_[2];
if(defined $question){
print $question;
}
my $input = <STDIN>;
chomp($input);
$input = $lowercase ? lc($input) : $input;
#print $input;
if(defined $cmp){
return $input eq $cmp;
}else{
return $input;
}
}
do{
my $pool_id = getInputLine(1, 'CLI_ID of pool to add LUN to: ');
my $lun_name = getInputLine(0, 'LUN Name: ');
my $lun_size = getInputLine(1, 'LUN Size (Gigabytes): ');
my $lun_isThinEnabled = getInputLine(1, 'LUN type (thick/thin): ',
'thin');
110 EMC Unity All Flash, EMC Unity Hybrid, EMC UnityVSA 4.1 Unisphere Management REST API Programmer's Guide