Add Cost Template

This API enables you to add a cost template.

Syntax

The syntax for calling this method is:

POST <Base_Url>/costTemplate

A sample API call is as follows:

POST https://123.123.123.123/vCenter-CB/api/costTemplate

User Privilege

You must have a role with Create privilege on the cost template.

Request Body Parameters

This API needs a request XML with the following information.

XPath

Type

Min Occurs

Max Occurs

Description

CostTemplates/CostTemplate

1

1

Represents the cost template.

CostTemplates/CostTemplate/Name

xs:string

1

1

Name of the cost template. The cost template name must be unique.

CostTemplates/CostTemplate/Description

xs:string

0

1

A brief description of the cost template.

CostTemplates/CostTemplate/RateFactors

0

1

Represents the rate factors to be set.

CostTemplates/CostTemplate/RateFactors/RateFactor

1

unbounded

Represents the rate factor to be set on a computing resource.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource

1

1

Represents the computing resource for which the rate factor is to be set.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource/@id

xs:int

1

1

ID of the computing resource for which the rate factor is set.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource/Value

xs:double

1

1

The rate factor applied to the computing resource. The rate factor value must be a number between 0 and 999.99 with precision up to two decimal places.

CostTemplates/CostTemplate/FixedCosts/FixedCost

1

unbounded

Represents the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/@id

xs:int

1

1

ID of the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Propagate

xs:boolean

1

1

Indicates whether the fixed cost value is propagated to the child entities. Applicable values are true and false. If the value is false, the fixed cost is applied only on the entity. If the value is true, the fixed cost is applied on the descendents of the entity. By default, the fixed cost is applied only on the immediate children.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Depth

xs:int

0

1

Specifies how deep in the tree fixed cost should be propagated. Default value is 1. For example, if a fixed cost with depth 2 is applied on a folder, only its children and grand children will be applied with this fixed cost. 0 indicates any depth.

CostTemplates/CostTemplate/FixedCosts/FixedCost/EntityTypeIdFilter

xs:int

0

1

Specifies the filter on entity type for which propagated fixed cost should be applied. Default value is -1. For example, if you apply a propagated fixed cost at a hierarchy level and choose entity type id as 0, then the fixed cost will be applied only on the virtual machines in the hierarchy. -1 signifies any entity type..

CostTemplates/CostTemplate/Currency

0

1

Represents the currency to be set for this cost template.

CostTemplates/CostTemplate/Currency/@id

xs:int

0

1

ID of the currency to be set for this cost template.  If this parameter is not specified, the currency will be set to USD or the global currency that was set during vCenter Chargeback Manager upgrade.

A sample request XML is provided here.

API Response

The API returns a response XML that provides the following details of the newly created cost template.

XPath

Type

Min Occurs

Max Occurs

Description

CostTemplates/CostTemplate

1

1

Represents the cost template that is added.

CostTemplates/CostTemplate/@id

xs:int

1

1

ID of the cost template that is added.

CostTemplates/CostTemplate/Name

xs:string

1

1

Name of the cost template

CostTemplates/CostTemplate/Description

xs:string

1

1

A brief description of the cost template.

CostTemplates/CostTemplate/Currency

1

1

Represents the currency set for this cost template

CostTemplates/CostTemplate/Currency/@id

xs:int

1

1

ID of the currency

CostTemplates/CostTemplate/Currency/Name

xs:string

1

1

Name of the currency.

CostTemplates/CostTemplate/RateFactors/RateFactor

1

unbounded

Represents the rate factor set for the computing resource.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource

1

1

Represents the computing resource for which the rate factor is set.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource/@id

xs:int

1

1

ID of the computing resource for which the rate factor is set.

CostTemplates/CostTemplate/RateFactors/RateFactor/ComputingResource/Name

xs:string

1

1

Name of the computing resource for which the rate factor is set.

CostTemplates/CostTemplate/RateFactors/RateFactor/Value

xs:double

1

1

Rate factor applied to the computing resource.

CostTemplates/CostTemplate/FixedCosts/FixedCost

1

unbounded

Represents the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/@id

xs:int

1

1

ID of the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Name

xs:string

1

1

Name of the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Description

xs:string

1

1

Description of the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Type

1

1

Represents the fixed cost type.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Type/@id

xs:int

1

1

ID of the fixed cost type.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Type/Name

xs:string

1

1

Name of the fixed cost type.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Currency

1

1

Represents the currency set for the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Currency/@id

xs:int

1

1

ID of the currency set for the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Currency/Name

xs:string

1

1

Name of the currency set for the fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Propagate

xs:boolean

1

1

Indicates if the fixed cost value is being propagated to the child entities. If the value of this parameter is false, the fixed cost is applicable only to the entity. If the value is true, the fixed cost is applicable to the immediate children of the entity.

CostTemplates/CostTemplate/FixedCosts/FixedCost/Depth

xs:int

0

1

Specifies how deep in the tree fixed cost should be propagated. Default value is 1. For example, if a fixed cost with depth 2 is applied on a folder, only it’s children and grand children will be applied with this fixed cost.

CostTemplates/CostTemplate/FixedCosts/FixedCost/EntityTypeIdFilter

xs:int

0

1

Specifies the filter on entity type for which propagated fixed cost should be applied. Default value is -1. For example, if you apply a propagated fixed cost at a hierarchy level and choose entity type id as 0, then the fixed cost will be applied only on the virtual machines in the hierarchy. -1 signifies any entity type..

A sample response is provided here.

Error Response

The following table explains the error codes displayed by the API.

Error Code

Description

VCB_ERR_INVALID_COST_TEMPLATE_NAME

Cost template name is blank, not unique or contains more than 255 characters.

VCB_ERR_INVALID_COST_TEMPLATE_DESCRIPTION

Cost template description is empty or contains more than 512 characters.

VCB_ERR_INVALID_FIXED_COST_ID

Fixed cost ID is invalid.

VCB_ERR_INVALID_COMPUTING_RESOURCE_ID

Computing resource ID is invalid.

VCB_ERR_INVALID_RATE_FACTOR

Rate factor value is negative or has more than the maximum allowed.

VCB_ERR_INVALID_CURRENCY

Currency ID specified in the request XML is not supported.