github.com/vmware/go-vmware-nsxt@v0.0.0-20230223012718-d31b8a1ca05e/api_response.go (about)

     1  /* Copyright © 2017 VMware, Inc. All Rights Reserved.
     2     SPDX-License-Identifier: BSD-2-Clause
     3  
     4     Generated by: https://github.com/swagger-api/swagger-codegen.git */
     5  
     6  package nsxt
     7  
     8  import (
     9  	"net/http"
    10  )
    11  
    12  type APIResponse struct {
    13  	*http.Response `json:"-"`
    14  	Message        string `json:"message,omitempty"`
    15  	// Operation is the name of the swagger operation.
    16  	Operation string `json:"operation,omitempty"`
    17  	// RequestURL is the request URL. This value is always available, even if the
    18  	// embedded *http.Response is nil.
    19  	RequestURL string `json:"url,omitempty"`
    20  	// Method is the HTTP method used for the request.  This value is always
    21  	// available, even if the embedded *http.Response is nil.
    22  	Method string `json:"method,omitempty"`
    23  	// Payload holds the contents of the response body (which may be nil or empty).
    24  	// This is provided here as the raw response.Body() reader will have already
    25  	// been drained.
    26  	Payload []byte `json:"-"`
    27  }
    28  
    29  func NewAPIResponse(r *http.Response) *APIResponse {
    30  
    31  	response := &APIResponse{Response: r}
    32  	return response
    33  }
    34  
    35  func NewAPIResponseWithError(errorMessage string) *APIResponse {
    36  
    37  	response := &APIResponse{Message: errorMessage}
    38  	return response
    39  }