Default language.

Information
Important This documentation space contains information about the SaaS version of BMC Helix Discovery. If you are using the on-premises version of BMC Helix Discovery, see BMC Helix Discovery 25.2 (On-Premises).

discovery.restfulPatch


discovery.restfulPatch(target, protocol, path[, headers, body, port, use_http, address])

Performs a patch request on the target using the RESTful protocol specified and returns a node containing information on the discovered system.

The function takes the following parameters:

  • target – the device or data source against which the request is performed. See also, discovery-dataSource.
  • protocol – distinguishes the RESTful protocol for distinguishing credentials and handling any device specific behavior. The following protocols are supported:
    • "" — Generic protocol, no authentication
    • "basic_auth" — Generic protocol, HTTP basic authentication.
    • "digest_auth" — Generic protocol, HTTP Digest authentication.
    • "oauth2" — Generic protocol, OAuth2 authentication.
      The OAuth2 authentication method is a client credentials grant or user credentials grant, as described on the IETF Tools website.
      • User credentials grant is used if a username and password is specified in the credential or data source.
      • Client credentials grant does not support a username, but requires a Client ID and secret.
    • "VPLEX" — VPLEX protocol.
    • "vsphere_auth" — vSphere authentication protocol.
  • path — a string specifying the URL path on the target, for example /api/about. The IP address and access method are automatically added according to the credential and endpoint being discovered.
  • headers — an optional dictionary of HTTP headers to be sent with the request. You can use this to implement custom protocols that require certain HTTP headers to be present. For VPLEX the username and password fields are automatically added. It is not possible to override automatically added values.
  • body — string, optional. The HTTP body of the request.
  • port — an optional integer. Port on which HTTP server listens. Default value is 80 if use_http is True, otherwise 443 is used.
  • use_http — boolean, optional. Whether to use HTTP instead of HTTPS. Default value is False (HTTPS).
  • address – the particular IP address to connect to. If not specified, uses the address of the target device that is being scanned.

and returns a DiscoveryAPIResult node containing the following:

  • response_status – the response status.
  • response_reason – the response reason.
  • response_header – a table of header entries. Sensitive fields are removed.
  • response_body – the body of the response. When data is successfully retrieved and the response_body is a JSON encoded string, it can be decoded using the json-decode function.

For example:

// PATCH request, OAuth2 Authentication, HTTPS on default port
// PATCH request modifies a single value

message := table();
message['status'] := "stopped";

result := discovery.restfulPatch(process, "oauth2", "/api/v1.1/discovery",
                                 json.encode(message));

If the request fails, the discovery.restfulPatch function returns none.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Helix Discovery (SaaS)