response.go raw

   1  /*
   2  Intelligent DNS API
   3  
   4  No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
   5  
   6  API version: 1.0.0
   7  */
   8  
   9  // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
  10  
  11  package idns
  12  
  13  import (
  14  	"net/http"
  15  )
  16  
  17  // APIResponse stores the API response returned by the server.
  18  type APIResponse struct {
  19  	*http.Response `json:"-"`
  20  	Message        string `json:"message,omitempty"`
  21  	// Operation is the name of the OpenAPI operation.
  22  	Operation string `json:"operation,omitempty"`
  23  	// RequestURL is the request URL. This value is always available, even if the
  24  	// embedded *http.Response is nil.
  25  	RequestURL string `json:"url,omitempty"`
  26  	// Method is the HTTP method used for the request.  This value is always
  27  	// available, even if the embedded *http.Response is nil.
  28  	Method string `json:"method,omitempty"`
  29  	// Payload holds the contents of the response body (which may be nil or empty).
  30  	// This is provided here as the raw response.Body() reader will have already
  31  	// been drained.
  32  	Payload []byte `json:"-"`
  33  }
  34  
  35  // NewAPIResponse returns a new APIResponse object.
  36  func NewAPIResponse(r *http.Response) *APIResponse {
  37  
  38  	response := &APIResponse{Response: r}
  39  	return response
  40  }
  41  
  42  // NewAPIResponseWithError returns a new APIResponse object with the provided error message.
  43  func NewAPIResponseWithError(errorMessage string) *APIResponse {
  44  
  45  	response := &APIResponse{Message: errorMessage}
  46  	return response
  47  }
  48