github.com/Files-com/files-sdk-go/v3@v3.1.81/bandwidthsnapshot.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 BandwidthSnapshot struct {
    11  	Id                int64      `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
    12  	BytesReceived     string     `json:"bytes_received,omitempty" path:"bytes_received,omitempty" url:"bytes_received,omitempty"`
    13  	BytesSent         string     `json:"bytes_sent,omitempty" path:"bytes_sent,omitempty" url:"bytes_sent,omitempty"`
    14  	SyncBytesReceived string     `json:"sync_bytes_received,omitempty" path:"sync_bytes_received,omitempty" url:"sync_bytes_received,omitempty"`
    15  	SyncBytesSent     string     `json:"sync_bytes_sent,omitempty" path:"sync_bytes_sent,omitempty" url:"sync_bytes_sent,omitempty"`
    16  	RequestsGet       string     `json:"requests_get,omitempty" path:"requests_get,omitempty" url:"requests_get,omitempty"`
    17  	RequestsPut       string     `json:"requests_put,omitempty" path:"requests_put,omitempty" url:"requests_put,omitempty"`
    18  	RequestsOther     string     `json:"requests_other,omitempty" path:"requests_other,omitempty" url:"requests_other,omitempty"`
    19  	LoggedAt          *time.Time `json:"logged_at,omitempty" path:"logged_at,omitempty" url:"logged_at,omitempty"`
    20  }
    21  
    22  func (b BandwidthSnapshot) Identifier() interface{} {
    23  	return b.Id
    24  }
    25  
    26  type BandwidthSnapshotCollection []BandwidthSnapshot
    27  
    28  type BandwidthSnapshotListParams struct {
    29  	SortBy     map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"`
    30  	Filter     BandwidthSnapshot      `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"`
    31  	FilterGt   map[string]interface{} `url:"filter_gt,omitempty" required:"false" json:"filter_gt,omitempty" path:"filter_gt"`
    32  	FilterGteq map[string]interface{} `url:"filter_gteq,omitempty" required:"false" json:"filter_gteq,omitempty" path:"filter_gteq"`
    33  	FilterLt   map[string]interface{} `url:"filter_lt,omitempty" required:"false" json:"filter_lt,omitempty" path:"filter_lt"`
    34  	FilterLteq map[string]interface{} `url:"filter_lteq,omitempty" required:"false" json:"filter_lteq,omitempty" path:"filter_lteq"`
    35  	ListParams
    36  }
    37  
    38  func (b *BandwidthSnapshot) UnmarshalJSON(data []byte) error {
    39  	type bandwidthSnapshot BandwidthSnapshot
    40  	var v bandwidthSnapshot
    41  	if err := json.Unmarshal(data, &v); err != nil {
    42  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    43  	}
    44  
    45  	*b = BandwidthSnapshot(v)
    46  	return nil
    47  }
    48  
    49  func (b *BandwidthSnapshotCollection) UnmarshalJSON(data []byte) error {
    50  	type bandwidthSnapshots BandwidthSnapshotCollection
    51  	var v bandwidthSnapshots
    52  	if err := json.Unmarshal(data, &v); err != nil {
    53  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    54  	}
    55  
    56  	*b = BandwidthSnapshotCollection(v)
    57  	return nil
    58  }
    59  
    60  func (b *BandwidthSnapshotCollection) ToSlice() *[]interface{} {
    61  	ret := make([]interface{}, len(*b))
    62  	for i, v := range *b {
    63  		ret[i] = v
    64  	}
    65  
    66  	return &ret
    67  }