bunnyshell.com/sdk@v0.16.0/response.go (about)

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