github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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.v6-unstable"
    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  // ActionsByNames wrap a slice of Actions for API calls.
    92  type ActionsByNames struct {
    93  	Actions []ActionsByName `json:"actions,omitempty"`
    94  }
    95  
    96  // ActionsByName is a bulk API call wrapper containing actions
    97  // as results.
    98  type ActionsByName struct {
    99  	Name    string         `json:"name,omitempty"`
   100  	Actions []ActionResult `json:"actions,omitempty"`
   101  	Error   *Error         `json:"error,omitempty"`
   102  }
   103  
   104  // FindActionsByName finds actions given an action name.
   105  type FindActionsByNames struct {
   106  	ActionNames []string `json:"names,omitempty"`
   107  }
   108  
   109  // ActionExecutionResults holds a slice of ActionExecutionResult for a
   110  // bulk action API call
   111  type ActionExecutionResults struct {
   112  	Results []ActionExecutionResult `json:"results,omitempty"`
   113  }
   114  
   115  // ActionExecutionResult holds the action tag and output used when
   116  // recording the result of an action.
   117  type ActionExecutionResult struct {
   118  	ActionTag string                 `json:"actiontag"`
   119  	Status    string                 `json:"status"`
   120  	Results   map[string]interface{} `json:"results,omitempty"`
   121  	Message   string                 `json:"message,omitempty"`
   122  }
   123  
   124  // ServicesCharmActionsResults holds a slice of ServiceCharmActionsResult for
   125  // a bulk result of charm Actions for Services.
   126  type ServicesCharmActionsResults struct {
   127  	Results []ServiceCharmActionsResult `json:"results,omitempty"`
   128  }
   129  
   130  // ServiceCharmActionsResult holds service name and charm.Actions for the service.
   131  // If an error such as a missing charm or malformed service name occurs, it
   132  // is encapsulated in this type.
   133  type ServiceCharmActionsResult struct {
   134  	ServiceTag string         `json:"servicetag,omitempty"`
   135  	Actions    *charm.Actions `json:"actions,omitempty"`
   136  	Error      *Error         `json:"error,omitempty"`
   137  }