Master
Versions: Euwe / Fine / Latest /

Service Custom Actions

With button groups, custom buttons and related dialogs defined on Service Templates, the REST API provides visibility to custom buttons on service templates and related ordered services.

This is made available with the custom_actions and custom_action_buttons virtual attributes on service_templates and services.

  • custom_actions returns the custom buttons as layed out in the UI on the service. The information returned includes any Resource Actions and related Dialogs for the custom button.

  • custom_action_buttons returns the array of custom buttons without the custom button groups hierarchy or details on related dialogs.

Fetching custom actions and custom action buttons for a service_template or a deployed service

GET /api/service_templates/:id?attributes=custom_actions,custom_action_buttons

GET /api/services/:id?attributes=custom_actions,custom_action_buttons

Example Service Template with custom buttons:

Request:

GET /api/service_templates/7?attributes=custom_actions,custom_action_buttons

Response:

{
  "href": "http://localhost:3000/api/service_templates/7",
  "id": 7,
  "name": "SampleServiceCatalogItem2",
  "description": "Sample Service Catalog Item 2",
  "guid": "47edc73a-4cef-11e5-8525-000a27020067",
  "options": {
    "button_order": [
      "cb-1",
      "cb-2",
      "cbg-43",
      "cb-3"
    ]
  },
  "created_at": "2015-08-27T19:10:29Z",
  "updated_at": "2015-09-16T18:24:13Z",
  "display": true,
  "evm_owner_id": 1,
  "service_type": "atomic",
  "prov_type": "generic",
  "service_template_catalog_id": 7,
  "long_description": "",
  "tenant_id": 1,
  "custom_actions": {
    "buttons": [
      {
        "id": 1,
        "guid": "3d5975fe-57bb-11e5-8d22-000a27020067",
        "description": "Rescan Service Offering",
        "applies_to_class": "ServiceTemplate",
        "options": {
          "button_image": 2,
          "display": true
        },
        "userid": "admin",
        "created_on": "2015-09-10T12:55:40Z",
        "updated_on": "2015-09-16T14:28:17Z",
        "name": "Rescan",
        "visibility": {
          "roles": [
            "_ALL_"
          ]
        },
        "applies_to_id": 7,
        "resource_action": {
          "id": 7,
          "resource_id": 1,
          "resource_type": "CustomButton",
          "created_at": "2015-09-10T12:55:40Z",
          "updated_at": "2015-09-16T14:28:17Z",
          "ae_namespace": "SYSTEM",
          "ae_class": "PROCESS",
          "ae_instance": "Request",
          "ae_attributes": {
            "key1": "val1",
            "key2": "val2",
            "request": "InspectMe"
          }
        }
      },
      {
        "id": 2,
        "guid": "7c900d18-57c1-11e5-8d22-000a27020067",
        "description": "Ping Service Status",
        "applies_to_class": "ServiceTemplate",
        "options": {
          "button_image": 3,
          "display": true
        },
        "userid": "admin",
        "created_on": "2015-09-10T13:40:23Z",
        "updated_on": "2015-09-16T14:16:21Z",
        "name": "Ping",
        "visibility": {
          "roles": [
            "_ALL_"
          ]
        },
        "applies_to_id": 7,
        "resource_action": {
          "id": 8,
          "resource_id": 2,
          "resource_type": "CustomButton",
          "created_at": "2015-09-10T13:40:23Z",
          "updated_at": "2015-09-16T14:16:21Z",
          "ae_namespace": "SYSTEM",
          "ae_class": "PROCESS",
          "ae_instance": "Request",
          "ae_attributes": {
            "Class": "System",
            "rel2": "//ManageIQ/System/Request/InspectMe",
            "request": "InspectMe"
          }
        }
      }
    ],
    "button_groups": [
      {
        "id": 43,
        "name": "MyButtonGroup|ServiceTemplate|7",
        "description": "My Custom Buttons",
        "created_on": "2015-09-10T13:41:20Z",
        "updated_on": "2015-09-15T14:53:49Z",
        "guid": "9e4a9900-57c1-11e5-8d22-000a27020067",
        "set_data": {
          "button_order": [
            3
          ],
          "button_image": 1,
          "display": true,
          "applies_to_class": "ServiceTemplate",
          "applies_to_id": 7,
          "group_index": 1
        },
        "owner_type": "ServiceTemplate",
        "owner_id": 7,
        "buttons": [
          {
            "id": 3,
            "guid": "92ac7d88-5bb9-11e5-b2f7-000a27020067",
            "description": "Simulate Button Dialog",
            "applies_to_class": "ServiceTemplate",
            "options": {
              "button_image": 12,
              "display": true
            },
            "userid": "admin",
            "created_on": "2015-09-15T14:53:49Z",
            "updated_on": "2015-09-16T14:28:50Z",
            "name": "simulate",
            "visibility": {
              "roles": [
                "_ALL_"
              ]
            },
            "applies_to_id": 7,
            "resource_action": {
              "id": 12,
              "dialog_id": 2,
              "resource_id": 3,
              "resource_type": "CustomButton",
              "created_at": "2015-09-15T14:53:49Z",
              "updated_at": "2015-09-16T14:28:50Z",
              "ae_namespace": "SYSTEM",
              "ae_class": "PROCESS",
              "ae_instance": "Request",
              "ae_attributes": {
                "request": "InspectMe"
              },
              "dialog": {
                "description": "Test Dialog 2",
                "buttons": "submit,cancel",
                "label": "TestDialog2",
                "dialog_tabs": [
                  {
                    "description": "VM Sizing",
                    "display": "edit",
                    "label": "VmSizing",
                    "position": 0,
                    "dialog_groups": [
                      {
                        "description": "Memory",
                        "display": "edit",
                        "label": "Memory",
                        "position": 0,
                        "dialog_fields": [
                          {
                            "name": "DynamicMemory",
                            "description": "Amount of Memory for VM is Dynamic",
                            "type": "DialogFieldCheckBox",
                            "display": "edit",
                            "display_method_options": {
                            },
                            "required_method_options": {
                            },
                            "default_value": "f",
                            "values_method_options": {
                            },
                            "options": {
                            },
                            "label": "DynamicMemory",
                            "position": 0,
                            "dynamic": false,
                            "read_only": false,
                            "resource_action": {
                              "resource_type": "DialogField",
                              "ae_attributes": {
                              }
                            }
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          }
        ]
      }
    ]
  },
  "custom_action_buttons": [
    {
      "id": 1,
      "guid": "3d5975fe-57bb-11e5-8d22-000a27020067",
      "description": "Rescan Service Offering",
      "applies_to_class": "ServiceTemplate",
      "options": {
        "button_image": 2,
        "display": true
      },
      "userid": "admin",
      "created_on": "2015-09-10T12:55:40Z",
      "updated_on": "2015-09-16T14:28:17Z",
      "name": "Rescan",
      "visibility": {
        "roles": [
          "_ALL_"
        ]
      },
      "applies_to_id": 7
    },
    {
      "id": 2,
      "guid": "7c900d18-57c1-11e5-8d22-000a27020067",
      "description": "Ping Service Status",
      "applies_to_class": "ServiceTemplate",
      "options": {
        "button_image": 3,
        "display": true
      },
      "userid": "admin",
      "created_on": "2015-09-10T13:40:23Z",
      "updated_on": "2015-09-16T14:16:21Z",
      "name": "Ping",
      "visibility": {
        "roles": [
          "_ALL_"
        ]
      },
      "applies_to_id": 7
    },
    {
      "id": 3,
      "guid": "b9afcdfa-57c1-11e5-8d22-000a27020067",
      "description": "Simulate Button Dialog",
      "applies_to_class": "ServiceTemplate",
      "options": {
        "button_image": 3,
        "display": true
      },
      "userid": "admin",
      "created_on": "2015-09-10T13:42:06Z",
      "updated_on": "2015-09-16T14:27:30Z",
      "name": "Simulate",
      "visibility": {
        "roles": [
          "_ALL_"
        ]
      },
      "applies_to_id": 7
    }
  }
  "actions": [
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/service_templates/7"
    },
    {
      "name": "delete",
      "method": "delete",
      "href": "http://localhost:3000/api/service_templates/7"
    }
  ]
}

When service templates define custom buttons, the ordered services are extended with custom actions which can be triggered via a POST action.

Note that the custom actions are exposed as actions on the deployed services, not the service_templates. The action name to trigger the action is the lower-cased name of the custom button.

As an example, here’s a service without custom buttons:

{
  "href": "http://localhost:3000/api/services/91",
  "id": 91,
  "name": "new_service_91",
  "description": "This is a description for the new service 91",
  ...
  "actions": [
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/services/91"
    },
    {
      "name": "retire",
      "method": "post",
      "href": "http://localhost:3000/api/services/91"
    },
    {
      "name": "delete",
      "method": "delete",
      "href": "http://localhost:3000/api/services/91"
    }
  ]
}

Here is an example of a service with custom buttons:

{
  "href": "http://localhost:3000/api/services/92",
  "id": 92,
  "name": "enhanced_service_92",
  "description": "This is a description for the enhanced service 92",
  "guid": "24c193a2-57c8-11e5-9332-000a27020067",
  "service_template_id": 7,
  "options": {
    "button_order": [
      "cb-1",
      "cb-2",
      "cb-3"
    ],
    "dialog": {
      "dialog_DynamicMemory": "t"
    }
  },
  "display": true,
  "created_at": "2015-09-10T14:28:02Z",
  "updated_at": "2015-09-10T14:28:02Z",
  "evm_owner_id": 1,
  "miq_group_id": 1,
  "actions": [
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/services/92"
    },
    {
      "name": "retire",
      "method": "post",
      "href": "http://localhost:3000/api/services/92"
    },
    {
      "name": "delete",
      "method": "delete",
      "href": "http://localhost:3000/api/services/92"
    },
    {
      "name": "rescan",
      "method": "post",
      "href": "http://localhost:3000/api/services/92"
    },
    {
      "name": "ping",
      "method": "post",
      "href": "http://localhost:3000/api/services/92"
    },
    {
      "name": "simulate",
      "method": "post",
      "href": "http://localhost:3000/api/services/92"
    }
  ]
}

Here, the rescan, ping and simulate are custom buttons for the service and are returned after the common actions.

For example, to request the rescan custom action shown above, this is simply a POST action as follows:

Request:

POST /api/services/92
{
  "action" : "rescan"
}

Response:

Responses from custom action are the normal action responses from the REST API:

{
  "success": true,
  "message": "Invoked custom action rescan for services id: 92",
  "href": "http://localhost:3000/api/services/92"
}