github.com/artpar/rclone@v1.67.3/backend/sia/api/types.go (about)

     1  // Package api provides types used by the Sia API.
     2  package api
     3  
     4  import (
     5  	"strings"
     6  	"time"
     7  )
     8  
     9  // DirectoriesResponse is the response for https://sia.tech/docs/#renter-dir-siapath-get
    10  type DirectoriesResponse struct {
    11  	Directories []DirectoryInfo `json:"directories"`
    12  	Files       []FileInfo      `json:"files"`
    13  }
    14  
    15  // FilesResponse is the response for https://sia.tech/docs/#renter-files-get
    16  type FilesResponse struct {
    17  	Files []FileInfo `json:"files"`
    18  }
    19  
    20  // FileResponse is the response for https://sia.tech/docs/#renter-file-siapath-get
    21  type FileResponse struct {
    22  	File FileInfo `json:"file"`
    23  }
    24  
    25  // FileInfo is used in https://sia.tech/docs/#renter-files-get
    26  type FileInfo struct {
    27  	AccessTime       time.Time `json:"accesstime"`
    28  	Available        bool      `json:"available"`
    29  	ChangeTime       time.Time `json:"changetime"`
    30  	CipherType       string    `json:"ciphertype"`
    31  	CreateTime       time.Time `json:"createtime"`
    32  	Expiration       uint64    `json:"expiration"`
    33  	Filesize         uint64    `json:"filesize"`
    34  	Health           float64   `json:"health"`
    35  	LocalPath        string    `json:"localpath"`
    36  	MaxHealth        float64   `json:"maxhealth"`
    37  	MaxHealthPercent float64   `json:"maxhealthpercent"`
    38  	ModTime          time.Time `json:"modtime"`
    39  	NumStuckChunks   uint64    `json:"numstuckchunks"`
    40  	OnDisk           bool      `json:"ondisk"`
    41  	Recoverable      bool      `json:"recoverable"`
    42  	Redundancy       float64   `json:"redundancy"`
    43  	Renewing         bool      `json:"renewing"`
    44  	SiaPath          string    `json:"siapath"`
    45  	Stuck            bool      `json:"stuck"`
    46  	StuckHealth      float64   `json:"stuckhealth"`
    47  	UploadedBytes    uint64    `json:"uploadedbytes"`
    48  	UploadProgress   float64   `json:"uploadprogress"`
    49  }
    50  
    51  // DirectoryInfo is used in https://sia.tech/docs/#renter-dir-siapath-get
    52  type DirectoryInfo struct {
    53  	AggregateHealth              float64   `json:"aggregatehealth"`
    54  	AggregateLastHealthCheckTime time.Time `json:"aggregatelasthealthchecktime"`
    55  	AggregateMaxHealth           float64   `json:"aggregatemaxhealth"`
    56  	AggregateMaxHealthPercentage float64   `json:"aggregatemaxhealthpercentage"`
    57  	AggregateMinRedundancy       float64   `json:"aggregateminredundancy"`
    58  	AggregateMostRecentModTime   time.Time `json:"aggregatemostrecentmodtime"`
    59  	AggregateNumFiles            uint64    `json:"aggregatenumfiles"`
    60  	AggregateNumStuckChunks      uint64    `json:"aggregatenumstuckchunks"`
    61  	AggregateNumSubDirs          uint64    `json:"aggregatenumsubdirs"`
    62  	AggregateSize                uint64    `json:"aggregatesize"`
    63  	AggregateStuckHealth         float64   `json:"aggregatestuckhealth"`
    64  
    65  	Health              float64   `json:"health"`
    66  	LastHealthCheckTime time.Time `json:"lasthealthchecktime"`
    67  	MaxHealthPercentage float64   `json:"maxhealthpercentage"`
    68  	MaxHealth           float64   `json:"maxhealth"`
    69  	MinRedundancy       float64   `json:"minredundancy"`
    70  	MostRecentModTime   time.Time `json:"mostrecentmodtime"`
    71  	NumFiles            uint64    `json:"numfiles"`
    72  	NumStuckChunks      uint64    `json:"numstuckchunks"`
    73  	NumSubDirs          uint64    `json:"numsubdirs"`
    74  	SiaPath             string    `json:"siapath"`
    75  	Size                uint64    `json:"size"`
    76  	StuckHealth         float64   `json:"stuckhealth"`
    77  }
    78  
    79  // Error contains an error message per https://sia.tech/docs/#error
    80  type Error struct {
    81  	Message    string `json:"message"`
    82  	Status     string
    83  	StatusCode int
    84  }
    85  
    86  // Error returns a string for the error and satisfies the error interface
    87  func (e *Error) Error() string {
    88  	var out []string
    89  	if e.Message != "" {
    90  		out = append(out, e.Message)
    91  	}
    92  	if e.Status != "" {
    93  		out = append(out, e.Status)
    94  	}
    95  	if len(out) == 0 {
    96  		return "Siad Error"
    97  	}
    98  	return strings.Join(out, ": ")
    99  }