Object Functions
This section describes the following object functions.
header
header(<string>)
header extracts a single response header from the API request. The return value type is a string. header may appear when defining datasource fields.
This example creates a new datasource from an API request and sets the field with the response header value.
datasource "aws_s3_object" 
  request do 
    auth $auth_aws 
    verb "GET" 
    host "my_bucket.s3.amazonaws.com" 
    path "/" 
    query "list-type", "2" 
  end 
  result do 
    encoding "xml" 
    collect xpath(response, "//ListBucketResult/Contents", "array") do 
      field "key", xpath(col_item,"Key") #the Key / File name 
      field "last_modified", header("LastModified") #last modified date 
      field "bucket", header("Name") #the bucket name 
    end 
  end 
end 
href
href(<object>)
href extracts a self href from the links section of a Flexera resource. The return value type is a string. href may appear when defining datasource fields or in validations. This function is provided as a shortcut as the response can otherwise be cumbersome to parse.
This example creates a new datasource from an array of Flexera instances with the href field set to the self href of the instance.
datasource "instances" 
  iterate @instances 
  field "id" val(iter_item, "resource_uid") 
  field "href", href(iter_item) # set to something like "/api/clouds/1/instances/AE3F0B9AE" 
end 
hrefs
hrefs(<array of objects>)
hrefs extracts a self href from the links sections of an array of RightScale resources. See href for details.
Example:
 
datasource "instances" do 
  field "all_hrefs" hrefs(@instances) # set to something like ["/api/clouds/1/instances/AAA", "/api/clouds/1/instances/BBB", ...] 
end 
val
val(<object>, field_name)
val extracts a field from an object returns the corresponding value. The return value type is the value of the field. val may appear when defining datasource fields or in validations.
Example:
val(@instance, "resource_uid") # returns the value of the instance resource_uid field
datasource "instances" do 
iterate @instances # iterate previously defined resources 
field "id", val(iter_item, "resource_uid") # rename "resource_uid" into "id" 
end 
vals
vals(<array of objects>, field_name)
vals extracts a field from an array of objects returns an array of the field values. vals may appear when defining datasource fields or in validations.
Example:
vals(@instances, "resource_uid") # returns an array of resource_uids.
datasource "instances" do 
field "all_ids", vals(data, "resource_uid")
end