Module netapp_ontap.response

Copyright © 2021 NetApp Inc. All rights reserved.

This module defines a unified response object for all resource actions.

Classes

class NetAppResponse (http_response: requests.models.Response)

Contains the HTTP response received by a client from a server for a specific action. The object allows all responses to be examined in a consistent way. For example, is this an error or is an ongoing job?

Create and initialize a NetAppResponse object based on the result of an API call.

Args

http_response
The API response to wrap

Instance variables

is_err

Examine to determine if the response is an error.

Returns

True if the HTTP status code was 400 or greater, else it will return False.

is_job

Examine to determine if the response is a job.

Returns

True if the HTTP status code returned was 202, else it will return False.

Methods

def poll(self, connection: HostConnection = None, timeout: int = None, interval: int = None) -> NetAppResponse

Wait for the job associated with the response to complete.

Calls 'utils.poll' with the response object and blocks until the job completes (that is reaches a terminal state).

Args

connection
The host containing the job to connect to.
timeout
Seconds to wait before timing out of a poll request. If set, the value overrides the timeout set in connection. Otherwise, the timeout set in the connection is used.
interval
Seconds to wait between making REST API calls to check the the job status. If set, the value overrides the interval set in the connection object. Otherwise, the interval set in connection object is used.

Returns

The response received after the job completes. This is normally a success or failure indication for the job.