API

Option (Object)

From GoGrid



Contents

An Option is a special object representing a single option of an object's attribute. It is used where an object attribute's value is a set of defined options which are called Lookups.

They are special, because as an HTTP request parameter in a REST API Request, the value of the attribute can be the id or name of that option.

See common.lookup.list for a list of options and list of lookups.


Attributes


Name Type Version Description
id int 1.0 A unique identifier for this option.
name string 1.0 A friendly name to name this option. Note that there is a 20 character limit for the name value.

Simple Example

For example, the legal values of the Server object's ram attribute are a set of options such as 512MB and 1GB whose id's are 1 and 2 respectively.


HTTP Request

When sending an API Request to add a server, the HTTP request parameters for the ram attribute can be:

# 512 MB
https://api.grid.com/.../?ram=1
https://api.grid.com/.../?ram=512MB

# 1GB
https://api.grid.com/.../?ram=2
https://api.grid.com/.../?ram=1GB


JSON Response

When receiving an instance of these server RAM option values as a JSON HTTP response :

512 MB JSON Response:

{ id=1, name="512MB", description="512MB of RAM." } 

1 GB JSON Response:

{ id=2, name="1GB", description="1GB of RAM." } 

XML Response

When receiving an instance of these server RAM option values as an XML HTTP response :

512 MB XML Response:

<object name="option">
  <attribute name="id">1</attribute>
  <attribute name="name">512MB</attribute>
  <attribute name="description">512MB of RAM.</attribute>
</object>


1GB XML Response:

<object name="option">
  <attribute name="id">2</attribute>
  <attribute name="name">1GB</attribute>
  <attribute name="description">1GB of RAM.</attribute>
</object>


CSV Response

When receiving an instance of these server ram option values as a CSV HTTP response :

512MB CSV Response:

1, 512MB, 512MB of RAM. 

1GB CSV Response:

2, 1GB, 1GB of RAM.

JSON Representation

{ id=1, name="My Name", description="This is my name." } 

XML Representation

<object name="option">
  <attribute name="id">1</attribute>
  <attribute name="name">My Name</attribute>
  <attribute name="description">This is my name.</attribute>
</object>

CSV Representation

# id,name,description
1,My Name,This is my name.
Personal tools