golift.io/starr@v1.0.0/readarr/rootfolder.go (about)

     1  package readarr
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"golift.io/starr"
     8  )
     9  
    10  const bpRootFolder = APIver + "/rootFolder"
    11  
    12  // RootFolder is the /api/v1/rootfolder endpoint.
    13  type RootFolder struct {
    14  	ID                       int64  `json:"id"`
    15  	Name                     string `json:"name"`
    16  	Path                     string `json:"path"`
    17  	DefaultMetadataProfileID int64  `json:"defaultMetadataProfileId"`
    18  	DefaultQualityProfileID  int64  `json:"defaultQualityProfileId"`
    19  	DefaultMonitorOption     string `json:"defaultMonitorOption"`
    20  	DefaultTags              []int  `json:"defaultTags"`
    21  	Port                     int    `json:"port"`
    22  	OutputProfile            string `json:"outputProfile"`
    23  	UseSsl                   bool   `json:"useSsl"`
    24  	Accessible               bool   `json:"accessible"`
    25  	IsCalibreLibrary         bool   `json:"isCalibreLibrary"`
    26  	FreeSpace                int64  `json:"freeSpace"`
    27  	TotalSpace               int64  `json:"totalSpace"`
    28  }
    29  
    30  // GetRootFolders returns all configured root folders.
    31  func (r *Readarr) GetRootFolders() ([]*RootFolder, error) {
    32  	return r.GetRootFoldersContext(context.Background())
    33  }
    34  
    35  // GetRootFoldersContext returns all configured root folders.
    36  func (r *Readarr) GetRootFoldersContext(ctx context.Context) ([]*RootFolder, error) {
    37  	var output []*RootFolder
    38  
    39  	req := starr.Request{URI: bpRootFolder}
    40  	if err := r.GetInto(ctx, req, &output); err != nil {
    41  		return nil, fmt.Errorf("api.Get(%s): %w", &req, err)
    42  	}
    43  
    44  	return output, nil
    45  }