Skip to content

Ansible Module: nokia.nsp.rest

Execute NSP REST API calls

Notes

Requires ansible.netcommon.httpapi connection using Network OS nokia.nsp.nsp.

Success is 2xx; 404 for DELETE is also considered success (resource already absent).

For file operations use nokia.nsp.upload and nokia.nsp.download.

Option dest handles text files only with UTF-8 encoding.

Synopsis

Parameters

Parameter Type Comments
path str REST API endpoint without base URL
Required: always
method str HTTP method to use
Choices: GET, POST, PUT, DELETE, PATCH
Default: GET
body raw API request body
Dict/list are serialized as JSON
dest path Write response body content as file
If file exists, will be overwritten
For binary downloads use nokia.nsp.download
headers dict This module automatically sets the authorization, content-type and accept headers.
User can enforce content-type and accept headers by passing them in headers.
User may also pass additional headers as needed.
If not set, Accept defaults to application/json
If not set, Content-Type is inferred from body to become either application/json or text/plain.
Default: {}
timeout int Socket timeout in seconds
Default: 30

Examples

- name: Execute WFM action via REST API
  nokia.nsp.rest:
    method: POST
    path: /wfm/api/v1/action-execution
    headers:
      Content-Type: application/json
      Accept: application/json
    body:
      name: nsp.ping
      examples: Default
      description: "Test ping action"
      input:
        host: localhost
        duration: 1
  register: result

- name: List files in NSP file storage
  nokia.nsp.rest:
    method: GET
    path: /nsp-file-service-app/rest/api/v1/directory?dirName=/nokia
  register: file_list

Return Values

Parameter Type Comments
status int HTTP status code
Returned: always
content str Response body content as string
Returned: when server returns a response body
json raw Response body parsed as JSON
Returned: when response is valid JSON
elapsed int Seconds elapsed for the request
Returned: always
path str Destination file path (if dest specified)
Returned: when dest is specified
changed bool Whether the request changed state
Returned: always
headers dict Response headers
Returned: always

New in version "0.1.0"