Skip to content

Commit

Permalink
feat(command): Init command
Browse files Browse the repository at this point in the history
  • Loading branch information
SkYNewZ committed Apr 8, 2020
1 parent 25e2e95 commit 2980635
Show file tree
Hide file tree
Showing 9 changed files with 629 additions and 9 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func New(radarrURL, apiKey string, client HTTPClientInterface) (*Service, error)
s.Movies = newMovieService(s)
s.SystemStatus = newSystemStatusService(s)
s.Diskspace = newDiskspaceService(s)
s.Command = newCommandService(s)

return s, nil
}
Expand All @@ -52,4 +53,7 @@ type Service struct {

// https://github.com/Radarr/Radarr/wiki/API:Diskspace
Diskspace *DiskspaceService

// https://github.com/Radarr/Radarr/wiki/API:Command
Command *CommandService
}
2 changes: 2 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func TestNew(t *testing.T) {
serviceWithCustomHTTPClient.Movies = newMovieService(serviceWithCustomHTTPClient)
serviceWithCustomHTTPClient.Diskspace = newDiskspaceService(serviceWithCustomHTTPClient)
serviceWithCustomHTTPClient.SystemStatus = newSystemStatusService(serviceWithCustomHTTPClient)
serviceWithCustomHTTPClient.Command = newCommandService(serviceWithCustomHTTPClient)

client := http.Client{}
client.Timeout = time.Second * 10
Expand All @@ -28,6 +29,7 @@ func TestNew(t *testing.T) {
serviceWithDefaultHTTPClient.Movies = newMovieService(serviceWithDefaultHTTPClient)
serviceWithDefaultHTTPClient.Diskspace = newDiskspaceService(serviceWithDefaultHTTPClient)
serviceWithDefaultHTTPClient.SystemStatus = newSystemStatusService(serviceWithDefaultHTTPClient)
serviceWithDefaultHTTPClient.Command = newCommandService(serviceWithDefaultHTTPClient)

tests := []struct {
name string
Expand Down
115 changes: 115 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package radarr

import (
"time"
)

// Command describe a generic command
type Command struct {
Name string `json:"name"`
Body struct {
SendUpdatesToClient bool `json:"sendUpdatesToClient"`
UpdateScheduledTask bool `json:"updateScheduledTask"`
CompletionMessage string `json:"completionMessage"`
Name string `json:"name"`
Trigger string `json:"trigger"`
} `json:"body"`
Priority string `json:"priority"`
Status string `json:"status"`
Queued time.Time `json:"queued"`
Trigger string `json:"trigger"`
State string `json:"state"`
Manual bool `json:"manual"`
StartedOn time.Time `json:"startedOn"`
StateChangeTime time.Time `json:"stateChangeTime"`
SendUpdatesToClient bool `json:"sendUpdatesToClient"`
UpdateScheduledTask bool `json:"updateScheduledTask"`
ID int `json:"id"`
}

type Tasks []Command

// CommandService not usable for now
// contains Radarr commands operations
type CommandService struct {
s *Service
}

func newCommandService(s *Service) *CommandService {
return &CommandService{s}
}

// Status Queries the status of a previously started command mathing given unique ID
func (c *CommandService) Status(commandID string) *Command {
return nil
}

// StatusAll Queries the status of all currently started commands.
func (c *CommandService) StatusAll() *Tasks {
return nil
}

// RefreshMovie Refresh movie information from TMDb and rescan disk
func (c *CommandService) RefreshMovie(movieID ...int) *Command {
// name := "RefreshMovie"
return nil
}

// RescanMovie Rescan disk for movies
func (c *CommandService) RescanMovie(movieID ...int) *Command {
// name := "RescanMovie"
return nil
}

// MoviesSearch Search for one or more movies
func (c *CommandService) MoviesSearch(movieIDs ...[]int) *Command {
// name := "MoviesSearch"
return nil
}

// DownloadedMoviesScan Instruct Radarr to scan the DroneFactoryFolder or a folder defined by the path variable.
// Each file and folder in the DroneFactoryFolder is interpreted as separate download.
// But a folder specified by the path variable is assumed to be a single download (job) and the folder name should be the release name.
// The downloadClientId can be used to support this API endpoint in conjunction with Completed Download Handling, so Radarr knows that a particular download has already been imported.
func (c *CommandService) DownloadedMoviesScan(opts ...*DownloadedMoviesScanOptions) *Command {
// name := "DownloadedMoviesScan"
return nil
}

// RssSync Instruct Radarr to perform an RSS sync with all enabled indexers
func (c *CommandService) RssSync() *Command {
// name := "RssSync"
return nil
}

// RenameFiles Instruct Radarr to rename the list of files provided.
func (c *CommandService) RenameFiles(files ...[]int) *Command {
// name := "RenameFiles"
return nil
}

// RenameMovie Instruct Radarr to rename all files in the provided movies.
func (c *CommandService) RenameMovie(movieIDs ...[]int) *Command {
// name := "RenameMovie"
return nil
}

// CutOffUnmetMoviesSearch Instructs Radarr to search all cutoff unmet movies (Take care, since it could go over your indexers api limits!)
func (c *CommandService) CutOffUnmetMoviesSearch(filter *Filter) *Command {
// name := "CutOffUnmetMoviesSearch"
return nil
}

// NetImportSync Instructs Radarr to search all lists for movies not yet added to Radarr.
func (c *CommandService) NetImportSync() *Command {
// name := "NetImportSync"
return nil
}

// MissingMoviesSearch Instructs Radarr to search all missing movies.
// This functionality is similar to what CouchPotato does and runs a backlog search for all your missing movies.
// For example You can use this api with curl and crontab to instruct Radarr to run a backlog search on 1 AM everyday.
func (c *CommandService) MissingMoviesSearch(filter *Filter) *Command {
// name := "MissingMoviesSearch"
return nil
}
Loading

0 comments on commit 2980635

Please sign in to comment.