github.com/Files-com/files-sdk-go/v3@v3.1.81/exavaultapirequestlog.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	lib "github.com/Files-com/files-sdk-go/v3/lib"
     8  )
     9  
    10  type ExavaultApiRequestLog struct {
    11  	Timestamp     *time.Time `json:"timestamp,omitempty" path:"timestamp,omitempty" url:"timestamp,omitempty"`
    12  	Endpoint      string     `json:"endpoint,omitempty" path:"endpoint,omitempty" url:"endpoint,omitempty"`
    13  	Version       string     `json:"version,omitempty" path:"version,omitempty" url:"version,omitempty"`
    14  	RequestIp     string     `json:"request_ip,omitempty" path:"request_ip,omitempty" url:"request_ip,omitempty"`
    15  	RequestMethod string     `json:"request_method,omitempty" path:"request_method,omitempty" url:"request_method,omitempty"`
    16  	ErrorType     string     `json:"error_type,omitempty" path:"error_type,omitempty" url:"error_type,omitempty"`
    17  	ErrorMessage  string     `json:"error_message,omitempty" path:"error_message,omitempty" url:"error_message,omitempty"`
    18  	UserAgent     string     `json:"user_agent,omitempty" path:"user_agent,omitempty" url:"user_agent,omitempty"`
    19  	ResponseCode  int64      `json:"response_code,omitempty" path:"response_code,omitempty" url:"response_code,omitempty"`
    20  	Success       *bool      `json:"success,omitempty" path:"success,omitempty" url:"success,omitempty"`
    21  	DurationMs    int64      `json:"duration_ms,omitempty" path:"duration_ms,omitempty" url:"duration_ms,omitempty"`
    22  }
    23  
    24  // Identifier no path or id
    25  
    26  type ExavaultApiRequestLogCollection []ExavaultApiRequestLog
    27  
    28  type ExavaultApiRequestLogListParams struct {
    29  	Filter       ExavaultApiRequestLog  `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"`
    30  	FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"`
    31  	ListParams
    32  }
    33  
    34  func (e *ExavaultApiRequestLog) UnmarshalJSON(data []byte) error {
    35  	type exavaultApiRequestLog ExavaultApiRequestLog
    36  	var v exavaultApiRequestLog
    37  	if err := json.Unmarshal(data, &v); err != nil {
    38  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    39  	}
    40  
    41  	*e = ExavaultApiRequestLog(v)
    42  	return nil
    43  }
    44  
    45  func (e *ExavaultApiRequestLogCollection) UnmarshalJSON(data []byte) error {
    46  	type exavaultApiRequestLogs ExavaultApiRequestLogCollection
    47  	var v exavaultApiRequestLogs
    48  	if err := json.Unmarshal(data, &v); err != nil {
    49  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    50  	}
    51  
    52  	*e = ExavaultApiRequestLogCollection(v)
    53  	return nil
    54  }
    55  
    56  func (e *ExavaultApiRequestLogCollection) ToSlice() *[]interface{} {
    57  	ret := make([]interface{}, len(*e))
    58  	for i, v := range *e {
    59  		ret[i] = v
    60  	}
    61  
    62  	return &ret
    63  }