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

     1  package lidarr
     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  	Path            string        `json:"path"`
    16  	FreeSpace       int64         `json:"freeSpace"`
    17  	TotalSpace      int64         `json:"totalSpace"`
    18  	UnmappedFolders []*starr.Path `json:"unmappedFolders"`
    19  }
    20  
    21  // GetRootFolders returns all configured root folders.
    22  func (l *Lidarr) GetRootFolders() ([]*RootFolder, error) {
    23  	return l.GetRootFoldersContext(context.Background())
    24  }
    25  
    26  // GetRootFoldersContext returns all configured root folders.
    27  func (l *Lidarr) GetRootFoldersContext(ctx context.Context) ([]*RootFolder, error) {
    28  	var output []*RootFolder
    29  
    30  	req := starr.Request{URI: bpRootFolder}
    31  	if err := l.GetInto(ctx, req, &output); err != nil {
    32  		return nil, fmt.Errorf("api.Get(%s): %w", &req, err)
    33  	}
    34  
    35  	return output, nil
    36  }