Master
Versions: Euwe / Fine / Latest /

Trigger a Custom Action on a Service

This page shows an ordered service that has a custom button with a dialog and how the custom action is triggered.

Here is the ordered service with the expanded custom actions:

Request:

GET /api/services/110?attributes=custom_actions

Response:

{
  "href": "http://localhost:3000/api/services/110",
  "id": 110,
  "name": "SampleServiceTemplate",
  "description": "Sample Service Template",
  "guid": "a3ab175c-8ca1-11e5-939f-000a27020067",
  "service_template_id": 9,
  "options": {
    "button_order": [
      "cb-10"
    ],
    "dialog": {
      "dialog_hostname": "myhostname",
      "dialog_ipaddress": "192.168.100.1",
      "dialog_environmenttype": "medium"
    }
  },
  "display": true,
  "created_at": "2015-11-16T20:35:56Z",
  "updated_at": "2015-11-16T20:35:56Z",
  "evm_owner_id": 1,
  "miq_group_id": 1,
  "tenant_id": 1,
  "custom_actions": {
    "buttons": [
      {
        "id": 10,
        "guid": "cdcec41c-8ca0-11e5-8c79-000a27020067",
        "description": "Query VM",
        "applies_to_class": "ServiceTemplate",
        "options": {
          "button_image": 4,
          "display": true
        },
        "userid": "admin",
        "created_on": "2015-11-16T20:29:58Z",
        "updated_on": "2015-11-16T20:29:58Z",
        "name": "QueryVM",
        "visibility": {
          "roles": [
            "_ALL_"
          ]
        },
        "applies_to_id": 9,
        "resource_action": {
          "id": 38,
          "dialog_id": 4,
          "resource_id": 10,
          "resource_type": "CustomButton",
          "created_at": "2015-11-16T20:29:58Z",
          "updated_at": "2015-11-16T20:29:58Z",
          "ae_namespace": "SYSTEM",
          "ae_class": "PROCESS",
          "ae_instance": "Request",
          "ae_attributes": {
            "attr1": "value1",
            "attr2": "value2",
            "request": "System/Project/InspectME"
          },
          "dialog": {
            "description": "Sample Dialog Description",
            "buttons": "submit",
            "label": "SampleDialog",
            "dialog_tabs": [
              {
                "description": "VM Tab Description",
                "display": "edit",
                "label": "VMTabLabel",
                "position": 0,
                "dialog_groups": [
                  {
                    "description": "Vm Info Description",
                    "display": "edit",
                    "label": "VmInfoLabel",
                    "position": 0,
                    "dialog_fields": [
                      {
                        "name": "hostname",
                        "description": "Hostname of the VM",
                        "type": "DialogFieldTextBox",
                        "display": "edit",
                        "display_method_options": {
                        },
                        "required": false,
                        "required_method_options": {
                        },
                        "default_value": "default_hostname",
                        "values_method_options": {
                        },
                        "options": {
                          "protected": false
                        },
                        "label": "HostNameLabel",
                        "position": 0,
                        "dynamic": false,
                        "read_only": false,
                        "resource_action": {
                          "resource_type": "DialogField",
                          "ae_attributes": {
                          }
                        }
                      },
                      {
                        "name": "ipaddress",
                        "description": "IP Address of VM",
                        "type": "DialogFieldTextBox",
                        "display": "edit",
                        "display_method_options": {
                        },
                        "required": false,
                        "required_method_options": {
                        },
                        "default_value": "",
                        "values_method_options": {
                        },
                        "options": {
                          "protected": false
                        },
                        "label": "IpaddressLabel",
                        "position": 1,
                        "dynamic": false,
                        "read_only": false,
                        "resource_action": {
                          "resource_type": "DialogField",
                          "ae_attributes": {
                          }
                        }
                      }
                    ]
                  }
                ]
              },
              {
                "description": "Environment Tab Description",
                "display": "edit",
                "label": "EnvironmentTab",
                "position": 1,
                "dialog_groups": [
                  {
                    "description": "Environment Box Description",
                    "display": "edit",
                    "label": "EnvironmentBoxLabel",
                    "position": 0,
                    "dialog_fields": [
                      {
                        "name": "environmenttype",
                        "description": "Environment Type Description",
                        "type": "DialogFieldRadioButton",
                        "data_type": "string",
                        "display": "edit",
                        "display_method_options": {
                        },
                        "required": true,
                        "required_method_options": {
                        },
                        "values": [
                          [
                            "large",
                            "Large Environment"
                          ],
                          [
                            "medium",
                            "Medium Environment"
                          ],
                          [
                            "small",
                            "Small Environment"
                          ]
                        ],
                        "values_method_options": {
                        },
                        "options": {
                          "sort_by": "description",
                          "sort_order": "ascending"
                        },
                        "label": "EnvTypeLabel",
                        "position": 0,
                        "dynamic": false,
                        "read_only": false,
                        "resource_action": {
                          "resource_type": "DialogField",
                          "ae_attributes": {
                          }
                        }
                      }
                    ]
                  }
                ]
              }
            ]
          }
        }
      }
    ],
    "button_groups": [

    ]
  },
  "actions": [
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/services/110"
    },
    {
      "name": "retire",
      "method": "post",
      "href": "http://localhost:3000/api/services/110"
    },
    {
      "name": "set_ownership",
      "method": "post",
      "href": "http://localhost:3000/api/services/110"
    },
    {
      "name": "delete",
      "method": "delete",
      "href": "http://localhost:3000/api/services/110"
    },
    {
      "name": "queryvm",
      "method": "post",
      "href": "http://localhost:3000/api/services/110"
    }
  ]
}

Showing the queryvm custom action being returned in the actions list.

The following is the request triggering a queryvm action on the service:

Request:

POST /api/services/110
{
  "action" : "queryvm",
  "resource" : {
    "hostname": "updated_hostname",
    "ipaddress": "192.168.100.2",
    "environmenttype" : "medium"
  }
}

Response:

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