github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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 "time" 7 8 const ( 9 // ActionCancelled is the status for an Action that has been 10 // cancelled prior to execution. 11 ActionCancelled string = "cancelled" 12 13 // ActionCompleted is the status of an Action that has completed 14 // successfully. 15 ActionCompleted string = "completed" 16 17 // ActionFailed is the status of an Action that has completed with 18 // an error. 19 ActionFailed string = "failed" 20 21 // ActionPending is the status of an Action that has been queued up but 22 // not executed yet. 23 ActionPending string = "pending" 24 25 // ActionRunning is the status of an Action that has been started but 26 // not completed yet. 27 ActionRunning string = "running" 28 ) 29 30 // Actions is a slice of Action for bulk requests. 31 type Actions struct { 32 Actions []Action `json:"actions,omitempty"` 33 } 34 35 // Action describes an Action that will be or has been queued up. 36 type Action struct { 37 Tag string `json:"tag"` 38 Receiver string `json:"receiver"` 39 Name string `json:"name"` 40 Parameters map[string]interface{} `json:"parameters,omitempty"` 41 } 42 43 // ActionResults is a slice of ActionResult for bulk requests. 44 type ActionResults struct { 45 Results []ActionResult `json:"results,omitempty"` 46 } 47 48 // ActionResult describes an Action that will be or has been completed. 49 type ActionResult struct { 50 Action *Action `json:"action,omitempty"` 51 Enqueued time.Time `json:"enqueued,omitempty"` 52 Started time.Time `json:"started,omitempty"` 53 Completed time.Time `json:"completed,omitempty"` 54 Status string `json:"status,omitempty"` 55 Message string `json:"message,omitempty"` 56 Output map[string]interface{} `json:"output,omitempty"` 57 Error *Error `json:"error,omitempty"` 58 } 59 60 // ActionsByReceivers wrap a slice of Actions for API calls. 61 type ActionsByReceivers struct { 62 Actions []ActionsByReceiver `json:"actions,omitempty"` 63 } 64 65 // ActionsByReceiver is a bulk API call wrapper containing Actions, 66 // either as input paramters or as results. 67 type ActionsByReceiver struct { 68 Receiver string `json:"receiver,omitempty"` 69 Actions []ActionResult `json:"actions,omitempty"` 70 Error *Error `json:"error,omitempty"` 71 } 72 73 // ActionsQueryResults holds a slice of responses from the Actions 74 // query. 75 type ActionsQueryResults struct { 76 Results []ActionsQueryResult `json:"results,omitempty"` 77 } 78 79 // ActionsQueryResult holds the name and parameters of an query result. 80 type ActionsQueryResult struct { 81 Receiver string `json:"receiver,omitempty"` 82 Action ActionResult `json:"action,omitempty"` 83 Error *Error `json:"error,omitempty"` 84 } 85 86 // ActionsByNames wrap a slice of Actions for API calls. 87 type ActionsByNames struct { 88 Actions []ActionsByName `json:"actions,omitempty"` 89 } 90 91 // ActionsByName is a bulk API call wrapper containing actions 92 // as results. 93 type ActionsByName struct { 94 Name string `json:"name,omitempty"` 95 Actions []ActionResult `json:"actions,omitempty"` 96 Error *Error `json:"error,omitempty"` 97 } 98 99 // FindActionsByName finds actions given an action name. 100 type FindActionsByNames struct { 101 ActionNames []string `json:"names,omitempty"` 102 } 103 104 // ActionExecutionResults holds a slice of ActionExecutionResult for a 105 // bulk action API call 106 type ActionExecutionResults struct { 107 Results []ActionExecutionResult `json:"results,omitempty"` 108 } 109 110 // ActionExecutionResult holds the action tag and output used when 111 // recording the result of an action. 112 type ActionExecutionResult struct { 113 ActionTag string `json:"action-tag"` 114 Status string `json:"status"` 115 Results map[string]interface{} `json:"results,omitempty"` 116 Message string `json:"message,omitempty"` 117 } 118 119 // ApplicationsCharmActionsResults holds a slice of ApplicationCharmActionsResult for 120 // a bulk result of charm Actions for Applications. 121 type ApplicationsCharmActionsResults struct { 122 Results []ApplicationCharmActionsResult `json:"results,omitempty"` 123 } 124 125 // ApplicationCharmActionsResult holds application name and charm.Actions for the application. 126 // If an error such as a missing charm or malformed application name occurs, it 127 // is encapsulated in this type. 128 type ApplicationCharmActionsResult struct { 129 ApplicationTag string `json:"application-tag,omitempty"` 130 Actions map[string]ActionSpec `json:"actions,omitempty"` 131 Error *Error `json:"error,omitempty"` 132 } 133 134 // ActionSpec is a definition of the parameters and traits of an Action. 135 // The Params map is expected to conform to JSON-Schema Draft 4 as defined at 136 // http://json-schema.org/draft-04/schema# (see http://json-schema.org/latest/json-schema-core.html) 137 type ActionSpec struct { 138 Description string `json:"description"` 139 Params map[string]interface{} `json:"params"` 140 }