Page tree
    Skip to end of metadata
    Go to start of metadata

    discovery.restfulGet(target, protocol, path[, header])

    Performs a GET 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 – distinguishes the RESTful protocol for distinguishing credentials and handling any device specific behaviour. VPLEX is the only protocol currently supported.
    • path – for example /vplex/clusters. The IP address and access method are automatically added according to the credential and endpoint being discovered.
    • header – an optional table with additional values to be passed in the headers of the request. For VPLEX the username and password fields are automatically added. It is not possible to override automatically added values.

    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.

    For example:

    result := discovery.restfulGet(process, 'VPLEX', '/vplex/clusters');
    
    if result then
      log.info('result status %result.response_status%');
      log.info('result reason %result.response_reason%');
      log.info('result headers %result.response_headers%');
      log.info('result body %result.response_body%');
    
      if result.response_body then
        decoded := json.decode(result.response_body);
        log.info('decoded body %decoded%');
      else
        log.info('no body to decode');
      end if;
    else
      log.info('discovery.restfulGet failed');
    end if;
    

    When data is successfully retrieved using the VPLEX protocol response_body is a JSON string which can be decoded using the json.decode function.

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

     

    • No labels