HP 3PAR StoreServ 7200 2-node HP 3PAR Web Service API 1.2 Developer's - Page 26

Null Members, Enumerations, Boolean, Integer

Page 26 highlights

For example, to create a volume, the only members required are the name of the volume, the name of the CPG that provides disk space for the volume, and the size of the volume. Optional members include the ID of the volume and a comment. When constructing a JSON object, optional members may be omitted or set to values that indicate the server should ignore them. The client sets only the fields of interest. The JSON object need not include all members. A client can perform one of two possible operations when creating the JSON object: • Include only the members required for the operation or • Include a member that is not required, but with a value that means it should be ignored. NOTE: A JSON object that has only ignored fields or null fields will be considered empty. A JSON array with no elements is considered empty. Objects and arrays composed of sub-objects or sub-arrays that are empty are themselves considered empty. Although objects and arrays can be present and named in input, if they are considered empty, the server may respond as if the objects and arrays are not present, and may return an error stating that required members are missing. When writing a client in a language that provides services for serializing a class into a JSON object, it is convenient to only have a single class that represents all required or optional members. The following sections specify the special values to use to ignore a member. Null Members The WSAPI supports properties with a value of null. Clients written in languages that provide classes (or objects) as alternatives to primitives may generate JSON objects such that the value of the property will be null. Null properties are ignored by the WSAPI. For example, a client written in Java that uses the Jackson JSON processor, with attributes cast as Boolean or Integer that are not initialized, will result in JSON properties with a value of null when using the Jackson JSON processor. Conversely, uninitialized attributes cast as boolean or int will result in JSON properties with a value of 0 (zero)-which may or may not be meaningful for the property. When the API server returns information, it does not include explict null values in the JSON object for properties that have no value or that are unset. For example, querying a volume that is not in a domain will return a JSON object with the domain field omitted rather than containing :null. Enumerations Some properties have values from a fixed set of limited values. For example, the state property of a storage volume can be one of the following: • Normal • Degraded • Failed When properties like these are present in a JSON object, they are represented numerically. In addition to the values shown in the definition of an enumeration, each enumeration can also have the value of -1, meaning that the API server has encountered a value that it does not recognize and therefore cannot assign a value from the valid set. This usually means that the user has entered an invalid enumeration value or that there is a defect in the API server. 26 Accessing the WSAPI

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107

For example, to create a volume, the only members required are the name of the volume, the name
of the CPG that provides disk space for the volume, and the size of the volume. Optional members
include the ID of the volume and a comment.
When constructing a JSON object, optional members may be omitted or set to values that indicate
the server should ignore them. The client sets only the fields of interest. The JSON object need not
include all members. A client can perform one of two possible operations when creating the JSON
object:
Include only the members required for the operation
or
Include a member that is not required, but with a value that means it should be ignored.
NOTE:
A JSON object that has only ignored fields or null fields will be considered empty.
A JSON array with no elements is considered empty.
Objects and arrays composed of sub-objects or sub-arrays that are empty are themselves
considered empty.
Although objects and arrays can be present and named in input, if they are considered empty,
the server may respond as if the objects and arrays are not present, and may return an error
stating that required members are missing.
When writing a client in a language that provides services for serializing a class into a JSON
object, it is convenient to only have a single class that represents all required or optional members.
The following sections specify the special values to use to ignore a member.
Null Members
The WSAPI supports properties with a value of null. Clients written in languages that provide classes
(or objects) as alternatives to primitives may generate JSON objects such that the value of the
property will be null. Null properties are ignored by the WSAPI.
For example, a client written in Java that uses the Jackson JSON processor, with attributes cast as
Boolean
or
Integer
that are not initialized, will result in JSON properties with a value of null
when using the Jackson JSON processor. Conversely, uninitialized attributes cast as
boolean
or
int
will result in JSON properties with a value of 0 (zero)—which may or may not be meaningful
for the property.
When the API server returns information, it does not include explict null values in the JSON object
for properties that have no value or that are unset. For example, querying a volume that is not in
a domain will return a JSON object with the domain field omitted rather than containing
<domain>:
null
.
Enumerations
Some properties have values from a fixed set of limited values. For example, the state property of
a storage volume can be one of the following:
Normal
Degraded
Failed
When properties like these are present in a JSON object, they are represented numerically.
In addition to the values shown in the definition of an enumeration, each enumeration can also
have the value of -1, meaningthat the API server has encountered a value that it does not recognize
and therefore cannot assign a value from the valid set. This usually means that the user has entered
an invalid enumeration value or that there is a defect in the API server.
26
Accessing the WSAPI