discovery.restfulPut

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


Performs a put 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 against which the request is performed.
  • protocol – specifies one of the following RESTful protocols to use. The specified protocol is used to determine the appropriate credential type to use and for handling any device specific behavior.
    • "VPLEX" — VPLEX protocol
    • "" — 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 used is a client credentials grant as described on the IETF Tools website.
  • 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).

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:

message := table();
message['description'] :="Description change via PUT";
result := discovery.restfulPut(process, "oauth2", "/api/v1.1/vault/credentials/2666c43545320f1995a40a31101507e7", 
								json.encode(message), use_http:=true);

If the request fails the discovery.restfulPut function returns none.

Was this page helpful? Yes No Submitting... Thank you

Comments