Documentation

Skip to end of metadata
Go to start of metadata

Cost Codes Resource

Use optional cost codes to set pricing for virtual machine images. The pricing estimate will include the image cost when users in enterprises with a pricing model assigned deploy a virtual machine using an image with a cost code. Assign cost codes before creating a pricing model.

Main URI of the Resource

This class operates mainly over the Resource URI: /config/costcodes

Exposed Methods

Create New Cost Code

Method to create a cost code.

Synopsis: POST http://example.com/api/config/costcodes
Roles Required: ROLE_PRICING_MANAGE
Request Headers: Accept: application/vnd.abiquo.costcode+json; version=3.2; application/vnd.abiquo.costcode+xml; version=3.2;  Content-type:  application/vnd.abiquo.costcode+json; version=3.2; application/vnd.abiquo.costcode+xml; version=3.2;
Request Parameters:

Parameter

Required

Default Value

Description

 

 

 

 

Request Message Body Entity: CostCode Media Type
Response Message Body Entity: CostCode Media Type
Request Example:

 Click here to show or hide the request example

Create New Cost Code example
curl -X POST http://example.com/api/config/costcodes\
     -H 'Accept: application/vnd.abiquo.costcode+xml; version=2.4'  \
     -H 'Content-Type: application/vnd.abiquo.costcode+xml; version=2.4'    \
     -d @entity.xml \
     -u user:password --verbose

POST http://example.com/api/config/costcodes HTTP/1.1
Authorization: Basic YWRtaW46eGFiaXF1bw==
Accept: application/vnd.abiquo.costcode+xml;version=2.4
Content-Type: application/vnd.abiquo.costcode+xml;version=2.4
Content-Length: 156

HTTP/1.1 201 Created
Date: Wed, 16 Jan 2013 14:10:26 GMT
Location: http://example.com/api/config/costcodes/1
Set-Cookie: JSESSIONID=8C9AF9833A98ECCD59382D38A71C7F77; Path=/api
Set-Cookie: auth=YWRtaW46MTM1ODM0NzIyNjc5MjoxODQ3NmU1MDQ5YWJmNTZkYzg3MTgwYmMzOWZlNjlkYzpBQklRVU8; Expires=Wed, 16-Jan-2013 14:40:26 GMT; Path=/api
Server: Apache-Coyote/1.1
Content-Type: application/vnd.abiquo.costcode+xml;version=2.4
Content-Length: 406
<?xml version="1.0" encoding="UTF-8"?>
<costCode>
  <link href="http://example.com/api/config/costcodes/1" rel="edit" type="application/vnd.abiquo.costcode+xml"/>
  <link href="http://example.com/api/config/costcodes/1/currencies"
    rel="currencies" type="application/vnd.abiquo.costcodecurrencies+xml"/>
  <description>description</description>
  <id>1</id>
  <name>JC-test-costcode</name>
</costCode>

Download a template

You can download the template of the entity here (click right mouse button and 'Save Link As..')

Get Cost Codes

This method returns the list of cost codes.

Paging Method

This method works with paging. Check out Basic Behaviors for information about how it works

Synopsis: GET http://example.com/api/config/costcodes
Roles Required: ROLE_PRICING_VIEW, ROLE_APPLIB_VM_COST_CODE
Request Headers: Accept: application/vnd.abiquo.costcodes+json; version=3.2; application/vnd.abiquo.costcodes+xml; version=3.2;  Content-type: ;
Request Parameters:

Parameter

Required

Default Value

Description

startwith

false

0

first element to retrieve

by

false

name

ordering the request.

has

false

 

filter the request. With this parameter the response just contains the elements
which name matches the filter value.

limit

false

25

number of elements to return

asc

false

true

order ascendant or descendant. By default the sort mode is ascending.

 

 

 

 

Request Message Body Entity:
Response Message Body Entity: CostCodes Media Type
Request Example:

 Click here to show or hide the request example

Get Cost Codes example
curl -X GET http://example.com/api/config/costcodes\
     -H 'Accept: application/vnd.abiquo.costcodes+xml; version=2.4' \
     -u user:password --verbose

GET http://example.com/api/config/costcodes HTTP/1.1
Authorization: Basic YWRtaW46eGFiaXF1bw==
Accept: application/vnd.abiquo.costcodes+xml;version=2.4

HTTP/1.1 200 OK
Date: Wed, 16 Jan 2013 14:10:27 GMT
Set-Cookie: JSESSIONID=16C1AE916D44D0EA99F43B200C66361D; Path=/api
Set-Cookie: auth=YWRtaW46MTM1ODM0NzIyODA2ODpjZmIyMzY2ZDdmZjZhNWNiZmRkN2NiZGY2MDMxOWFiYTpBQklRVU8; Expires=Wed, 16-Jan-2013 14:40:28 GMT; Path=/api
Server: Apache-Coyote/1.1
Content-Type: application/vnd.abiquo.costcodes+xml;version=2.4
Content-Length: 954
<?xml version="1.0" encoding="UTF-8"?>
<costCodes>
  <link href="http://example.com/api/config/costcodes" rel="first"/>
  <link href="http://example.com/api/config/costcodes?startwith=0" rel="last"/>
  <totalSize>2</totalSize>
  <costCode>
    <link href="http://example.com/api/config/costcodes/2/currencies"
      rel="currencies" type="application/vnd.abiquo.costcodecurrencies+xml"/>
    <link href="http://example.com/api/config/costcodes/2" rel="edit" type="application/vnd.abiquo.costcode+xml"/>
    <description>description</description>
    <id>2</id>
    <name>JC-test-costcode</name>
  </costCode>
  <costCode>
    <link href="http://example.com/api/config/costcodes/3/currencies"
      rel="currencies" type="application/vnd.abiquo.costcodecurrencies+xml"/>
    <link href="http://example.com/api/config/costcodes/3" rel="edit" type="application/vnd.abiquo.costcode+xml"/>
    <description>description</description>
    <id>3</id>
    <name>JC-ccdefaultprice</name>
  </costCode>
</costCodes>


 

Main URI of the Resource

This class operates mainly over the Resource URI: /config/costcodes/{costcode}

Exposed Methods

Get Cost Code

Get information of an existing cost code.

Synopsis: GET http://example.com/api/config/costcodes/{costcode}
Roles Required: ROLE_PRICING_VIEW
Request Headers: Accept: application/vnd.abiquo.costcode+json; version=3.2; application/vnd.abiquo.costcode+xml; version=3.2;  Content-type: ;
Request Parameters:

Parameter

Required

Default Value

Description

 

 

 

 

Request Message Body Entity:
Response Message Body Entity: CostCode Media Type
Request Example:

 Click here to show or hide the request example

Get Cost Code example
curl --verbose 'http://example.com/api/config/costcodes/4' \
        -X GET \
        -H "Accept:application/xml" \
        -u "user:password"

> GET /api/config/costCodes/4 HTTP/1.1
> Accept: application/vnd.abiquo.costcode+xml;version=2.4

< HTTP/1.1 200 OK
< Date:  Wed, 16 Jan 2012 09:51:39 GMT
< Content-Length: 561
< Server: Apache-Coyote/1.1
< Content-Type: application/vnd.abiquo.costcodes+xml;version=2.4

<costCode>
        <link href="http://localhost:80/api/config/costcodes/4/currencies" type="application/costcodecurrenciesdto+xml" rel="currencies"/>
        <link href="http://localhost:80/api/config/costcodes/4" type="application/vnd.abiquo.costcode+xml" rel="edit"/>
        <description>a</description>
        <id>4</id>
        <name>a</name>
</costCode>


Remove an existing Cost Code

Remove an existing cost code.

Synopsis: DELETE http://example.com/api/config/costcodes/{costcode}
Roles Required: ROLE_PRICING_MANAGE
Request Headers: Accept: ; Content-type: ;
Request Parameters:

Parameter

Required

Default Value

Description

 

 

 

 

Request Message Body Entity:
Response Message Body Entity:
Request Example:

 Click here to show or hide the request example

Remove an existing Cost Code example
curl -X DELETE http://example.com/api/config/costcodes/2\
     -u user:password --verbose

DELETE http://example.com/api/config/costcodes/2 HTTP/1.1
Authorization: Basic YWRtaW46eGFiaXF1bw==

HTTP/1.1 204 No Content
Date: Wed, 16 Jan 2013 14:10:28 GMT
Set-Cookie: JSESSIONID=BF7B2E23B6B0910A649E08CADE6CD71B; Path=/api
Set-Cookie: auth=YWRtaW46MTM1ODM0NzIyODc4MDoyOTkyZmJhYTQyYjk5YWU2ZGJjZTNhMjBkNTNhZmM5ZDpBQklRVU8; Expires=Wed, 16-Jan-2013 14:40:28 GMT; Path=/api
Server: Apache-Coyote/1.1

Update Cost Code

Update a cost code.

Synopsis: PUT http://example.com/api/config/costcodes/{costcode}
Roles Required: ROLE_PRICING_MANAGE
Request Headers: Accept: application/vnd.abiquo.costcode+json; version=3.2; application/vnd.abiquo.costcode+xml; version=3.2;  Content-type:  application/vnd.abiquo.costcode+json; version=3.2; application/vnd.abiquo.costcode+xml; version=3.2;
Request Parameters:

Parameter

Required

Default Value

Description

 

 

 

 

Request Message Body Entity: CostCode Media Type
Response Message Body Entity: CostCode Media Type
Request Example:

 Click here to show or hide the request example

Update Cost Code example
curl -X PUT http://example.com/api/config/costcodes/2\
     -H 'Accept: application/vnd.abiquo.costcode+xml; version=2.4'  \
     -H 'Content-Type: application/vnd.abiquo.costcode+xml; version=2.4'    \
     -d @entity.xml \
     -u user:password --verbose

PUT http://example.com/api/config/costcodes/2 HTTP/1.1
Authorization: Basic YWRtaW46eGFiaXF1bw==
Accept: application/vnd.abiquo.costcode+xml;version=2.4
Content-Type: application/vnd.abiquo.costcode+xml;version=2.4
Content-Length: 437

HTTP/1.1 200 OK
Date: Wed, 16 Jan 2013 14:10:27 GMT
Set-Cookie: JSESSIONID=E4987E9A01D8F6CE42A684CB8E39D031; Path=/api
Set-Cookie: auth=YWRtaW46MTM1ODM0NzIyODYzODoxNDFiNmQ1YWU4ZGY0ODExZWJmZThkMGQxZmUwY2U4NTpBQklRVU8; Expires=Wed, 16-Jan-2013 14:40:28 GMT; Path=/api
Server: Apache-Coyote/1.1
Content-Type: application/vnd.abiquo.costcode+xml;version=2.4
Content-Length: 409
<?xml version="1.0" encoding="UTF-8"?>
<costCode>
  <link href="http://example.com/api/config/costcodes/2/currencies"
    rel="currencies" type="application/vnd.abiquo.costcodecurrencies+xml"/>
  <link href="http://example.com/api/config/costcodes/2" rel="edit" type="application/vnd.abiquo.costcode+xml"/>
  <description>description</description>
  <id>2</id>
  <name>JC-costcode-updated</name>
</costCode>


Download a template

You can download the template of the entity here (click right mouse button and 'Save Link As..')