Introduction

Some Day 2 Actions are not submittable and are only used to retreive and display additional information to the portal users. For example, via the Get S3 Credentials action a portal user can retreive the credentials of an S3 User by opening the action in the user interface.

Because these actions are not submittable and the data gets loaded when the form is opened, getting these return values requires a different API call than e.g. submitting a day 2 or catalog request.

If you want to retreive such form values via API, follow the following steps:

GET
Step 1 - Request form template

This request is used to get the template for a specific resource action form.

Request

curl --location --request GET 'https://{{va-fqdn}}/catalog-service/api/consumer/resources/{{ressourceId}}/actions/{{actionId}}/forms/request' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{token}}'
POST
Step 2 - Get Form Update

Below you find an example of a form action to get the S3 Credentials via forms API. Depending on the resource-action-guid, this api request triggers a different action and requires a different data object.

curl --location --request POST 'https://{{va-fqdn}}/catalog-service/api/consumer/resources/{{resource-guid}}/actions/{{resource-action-guid}}/forms/request/update' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "affectedElements": [
        "provider-accessKeyID",
        "provider-secretAccessKey"
    ]
}'

Example Response JSON

{
    "elementUpdates": [
        {
            "id": "provider-accessKeyID",
            "facetValues": {
                "facets": [
                    {
                        "type": "fixedValue",
                        "value": {
                            "type": "string",
                            "value": "AKIA123451234512345"   // <--- Get this value
                        }
                    },
                    ...
                ]
            },
            ...
        },
        {
            "id": "provider-secretAccessKey",
            "facetValues": {
                "facets": [
                    {
                        "type": "fixedValue",
                        "value": {
                            "type": "string",
                            "value": "123451234512345"   // <--- Get this value
                        }
                    },
                ]
            },
            ...
        },
        ...
}

Parsing Examples

const RESPONSE_JSON = {} // get from call above

function getFacetValue(key, payload) {
  // no error handling provided
  const element = payload.elementUpdates.find((x) => x.id === key)
  const facet = element.facetValues.facets.find((x) => x.type === 'fixedValue')
  return facet.value.value
}

const accessKeyID = getFacetValue('provider-accessKeyID', RESPONSE_JSON)
const secretAccessKey = getFacetValue('provider-secretAccessKey', RESPONSE_JSON)
local RESPONSE_JSON = {} # get from call above

echo $RESPONSE_JSON | jq -r "{s3_key: .elementUpdates[] | select (.id == \"provider-accessKeyID\").facetValues.facets[] | select (.type == \"fixedValue\").value.value, s3_secret: .elementUpdates[] | select (.id == \"provider-secretAccessKey\").facetValues.facets[] | select (.type == \"fixedValue\").value.value}"
This is an information message

Further Information

You can find further information in the official vRealize Automation Catalog Service API (v7.5)open in new window documentation by VMware/Broadcom.

Last Updated: