github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/cmd/juju/action/action.go (about) 1 // Copyright 2014, 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package action 5 6 import ( 7 "io" 8 9 "github.com/juju/errors" 10 11 "github.com/juju/juju/api/action" 12 "github.com/juju/juju/apiserver/params" 13 "github.com/juju/juju/cmd/modelcmd" 14 ) 15 16 // type APIClient represents the action API functionality. 17 type APIClient interface { 18 io.Closer 19 20 // Enqueue takes a list of Actions and queues them up to be executed by 21 // the designated ActionReceiver, returning the params.Action for each 22 // queued Action, or an error if there was a problem queueing up the 23 // Action. 24 Enqueue(params.Actions) (params.ActionResults, error) 25 26 // ListAll takes a list of Tags representing ActionReceivers and returns 27 // all of the Actions that have been queued or run by each of those 28 // Entities. 29 ListAll(params.Entities) (params.ActionsByReceivers, error) 30 31 // ListPending takes a list of Tags representing ActionReceivers 32 // and returns all of the Actions that are queued for each of those 33 // Entities. 34 ListPending(params.Entities) (params.ActionsByReceivers, error) 35 36 // ListCompleted takes a list of Tags representing ActionReceivers 37 // and returns all of the Actions that have been run on each of those 38 // Entities. 39 ListCompleted(params.Entities) (params.ActionsByReceivers, error) 40 41 // Cancel attempts to cancel a queued up Action from running. 42 Cancel(params.Actions) (params.ActionResults, error) 43 44 // ApplicationCharmActions is a single query which uses ApplicationsCharmsActions to 45 // get the charm.Actions for a single Service by tag. 46 ApplicationCharmActions(params.Entity) (map[string]params.ActionSpec, error) 47 48 // Actions fetches actions by tag. These Actions can be used to get 49 // the ActionReceiver if necessary. 50 Actions(params.Entities) (params.ActionResults, error) 51 52 // FindActionTagsByPrefix takes a list of string prefixes and finds 53 // corresponding ActionTags that match that prefix. 54 FindActionTagsByPrefix(params.FindTags) (params.FindTagsResults, error) 55 56 // FindActionsByNames takes a list of names and finds a corresponding list of 57 // Actions for every name. 58 FindActionsByNames(params.FindActionsByNames) (params.ActionsByNames, error) 59 } 60 61 // ActionCommandBase is the base type for action sub-commands. 62 type ActionCommandBase struct { 63 modelcmd.ModelCommandBase 64 } 65 66 // NewActionAPIClient returns a client for the action api endpoint. 67 func (c *ActionCommandBase) NewActionAPIClient() (APIClient, error) { 68 return newAPIClient(c) 69 } 70 71 var newAPIClient = func(c *ActionCommandBase) (APIClient, error) { 72 root, err := c.NewAPIRoot() 73 if err != nil { 74 return nil, errors.Trace(err) 75 } 76 return action.NewClient(root), nil 77 }