github.com/Files-com/files-sdk-go/v3@v3.1.81/usagesnapshot.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 UsageSnapshot struct {
    11  	Id                           int64                  `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
    12  	StartAt                      *time.Time             `json:"start_at,omitempty" path:"start_at,omitempty" url:"start_at,omitempty"`
    13  	EndAt                        *time.Time             `json:"end_at,omitempty" path:"end_at,omitempty" url:"end_at,omitempty"`
    14  	HighWaterUserCount           string                 `json:"high_water_user_count,omitempty" path:"high_water_user_count,omitempty" url:"high_water_user_count,omitempty"`
    15  	CurrentStorage               string                 `json:"current_storage,omitempty" path:"current_storage,omitempty" url:"current_storage,omitempty"`
    16  	HighWaterStorage             string                 `json:"high_water_storage,omitempty" path:"high_water_storage,omitempty" url:"high_water_storage,omitempty"`
    17  	UsageByTopLevelDir           map[string]interface{} `json:"usage_by_top_level_dir,omitempty" path:"usage_by_top_level_dir,omitempty" url:"usage_by_top_level_dir,omitempty"`
    18  	RootStorage                  string                 `json:"root_storage,omitempty" path:"root_storage,omitempty" url:"root_storage,omitempty"`
    19  	DeletedFilesCountedInMinimum string                 `json:"deleted_files_counted_in_minimum,omitempty" path:"deleted_files_counted_in_minimum,omitempty" url:"deleted_files_counted_in_minimum,omitempty"`
    20  	DeletedFilesStorage          string                 `json:"deleted_files_storage,omitempty" path:"deleted_files_storage,omitempty" url:"deleted_files_storage,omitempty"`
    21  	TotalBillableUsage           string                 `json:"total_billable_usage,omitempty" path:"total_billable_usage,omitempty" url:"total_billable_usage,omitempty"`
    22  	TotalBillableTransferUsage   string                 `json:"total_billable_transfer_usage,omitempty" path:"total_billable_transfer_usage,omitempty" url:"total_billable_transfer_usage,omitempty"`
    23  	BytesSent                    string                 `json:"bytes_sent,omitempty" path:"bytes_sent,omitempty" url:"bytes_sent,omitempty"`
    24  	SyncBytesReceived            string                 `json:"sync_bytes_received,omitempty" path:"sync_bytes_received,omitempty" url:"sync_bytes_received,omitempty"`
    25  	SyncBytesSent                string                 `json:"sync_bytes_sent,omitempty" path:"sync_bytes_sent,omitempty" url:"sync_bytes_sent,omitempty"`
    26  }
    27  
    28  func (u UsageSnapshot) Identifier() interface{} {
    29  	return u.Id
    30  }
    31  
    32  type UsageSnapshotCollection []UsageSnapshot
    33  
    34  type UsageSnapshotListParams struct {
    35  	ListParams
    36  }
    37  
    38  func (u *UsageSnapshot) UnmarshalJSON(data []byte) error {
    39  	type usageSnapshot UsageSnapshot
    40  	var v usageSnapshot
    41  	if err := json.Unmarshal(data, &v); err != nil {
    42  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    43  	}
    44  
    45  	*u = UsageSnapshot(v)
    46  	return nil
    47  }
    48  
    49  func (u *UsageSnapshotCollection) UnmarshalJSON(data []byte) error {
    50  	type usageSnapshots UsageSnapshotCollection
    51  	var v usageSnapshots
    52  	if err := json.Unmarshal(data, &v); err != nil {
    53  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    54  	}
    55  
    56  	*u = UsageSnapshotCollection(v)
    57  	return nil
    58  }
    59  
    60  func (u *UsageSnapshotCollection) ToSlice() *[]interface{} {
    61  	ret := make([]interface{}, len(*u))
    62  	for i, v := range *u {
    63  		ret[i] = v
    64  	}
    65  
    66  	return &ret
    67  }