github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/apiserver/params/actions.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  import (
     7  	"time"
     8  
     9  	// TODO(jcw4) per fwereade 2014-11-21 remove this dependency
    10  	"gopkg.in/juju/charm.v5"
    11  )
    12  
    13  const (
    14  	// ActionCancelled is the status for an Action that has been
    15  	// cancelled prior to execution.
    16  	ActionCancelled string = "cancelled"
    17  
    18  	// ActionCompleted is the status of an Action that has completed
    19  	// successfully.
    20  	ActionCompleted string = "completed"
    21  
    22  	// ActionFailed is the status of an Action that has completed with
    23  	// an error.
    24  	ActionFailed string = "failed"
    25  
    26  	// ActionPending is the status of an Action that has been queued up but
    27  	// not executed yet.
    28  	ActionPending string = "pending"
    29  
    30  	// ActionRunning is the status of an Action that has been started but
    31  	// not completed yet.
    32  	ActionRunning string = "running"
    33  )
    34  
    35  // Actions is a slice of Action for bulk requests.
    36  type Actions struct {
    37  	Actions []Action `json:"actions,omitempty"`
    38  }
    39  
    40  // Action describes an Action that will be or has been queued up.
    41  type Action struct {
    42  	Tag        string                 `json:"tag"`
    43  	Receiver   string                 `json:"receiver"`
    44  	Name       string                 `json:"name"`
    45  	Parameters map[string]interface{} `json:"parameters,omitempty"`
    46  }
    47  
    48  // ActionResults is a slice of ActionResult for bulk requests.
    49  type ActionResults struct {
    50  	Results []ActionResult `json:"results,omitempty"`
    51  }
    52  
    53  // ActionResult describes an Action that will be or has been completed.
    54  type ActionResult struct {
    55  	Action    *Action                `json:"action,omitempty"`
    56  	Enqueued  time.Time              `json:"enqueued,omitempty"`
    57  	Started   time.Time              `json:"started,omitempty"`
    58  	Completed time.Time              `json:"completed,omitempty"`
    59  	Status    string                 `json:"status,omitempty"`
    60  	Message   string                 `json:"message,omitempty"`
    61  	Output    map[string]interface{} `json:"output,omitempty"`
    62  	Error     *Error                 `json:"error,omitempty"`
    63  }
    64  
    65  // ActionsByReceivers wrap a slice of Actions for API calls.
    66  type ActionsByReceivers struct {
    67  	Actions []ActionsByReceiver `json:"actions,omitempty"`
    68  }
    69  
    70  // ActionsByReceiver is a bulk API call wrapper containing Actions,
    71  // either as input paramters or as results.
    72  type ActionsByReceiver struct {
    73  	Receiver string         `json:"receiver,omitempty"`
    74  	Actions  []ActionResult `json:"actions,omitempty"`
    75  	Error    *Error         `json:"error,omitempty"`
    76  }
    77  
    78  // ActionsQueryResults holds a slice of responses from the Actions
    79  // query.
    80  type ActionsQueryResults struct {
    81  	Results []ActionsQueryResult `json:"results,omitempty"`
    82  }
    83  
    84  // ActionsQueryResult holds the name and parameters of an query result.
    85  type ActionsQueryResult struct {
    86  	Receiver string       `json:"receiver,omitempty"`
    87  	Action   ActionResult `json:"action,omitempty"`
    88  	Error    *Error       `json:"error,omitempty"`
    89  }
    90  
    91  // ActionExecutionResults holds a slice of ActionExecutionResult for a
    92  // bulk action API call
    93  type ActionExecutionResults struct {
    94  	Results []ActionExecutionResult `json:"results,omitempty"`
    95  }
    96  
    97  // ActionExecutionResult holds the action tag and output used when
    98  // recording the result of an action.
    99  type ActionExecutionResult struct {
   100  	ActionTag string                 `json:"actiontag"`
   101  	Status    string                 `json:"status"`
   102  	Results   map[string]interface{} `json:"results,omitempty"`
   103  	Message   string                 `json:"message,omitempty"`
   104  }
   105  
   106  // ServicesCharmActionsResults holds a slice of ServiceCharmActionsResult for
   107  // a bulk result of charm Actions for Services.
   108  type ServicesCharmActionsResults struct {
   109  	Results []ServiceCharmActionsResult `json:"results,omitempty"`
   110  }
   111  
   112  // ServiceCharmActionsResult holds service name and charm.Actions for the service.
   113  // If an error such as a missing charm or malformed service name occurs, it
   114  // is encapsulated in this type.
   115  type ServiceCharmActionsResult struct {
   116  	ServiceTag string         `json:"servicetag,omitempty"`
   117  	Actions    *charm.Actions `json:"actions,omitempty"`
   118  	Error      *Error         `json:"error,omitempty"`
   119  }