github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/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 // ActionAborting is the status of an Action that is running but is to be 30 // terminated. Identical to ActionRunning. 31 ActionAborting string = "aborting" 32 33 // ActionAborted is the status of an Action that was aborted. 34 // Identical to ActionFailed and can have an error. 35 ActionAborted string = "aborted" 36 37 // ActionError is the status of an Action that did not get run 38 // due to an error. 39 ActionError string = "error" 40 ) 41 42 // Actions is a slice of Action for bulk requests. 43 type Actions struct { 44 Actions []Action `json:"actions,omitempty"` 45 } 46 47 // Action describes an Action that will be or has been queued up. 48 type Action struct { 49 Tag string `json:"tag"` 50 Receiver string `json:"receiver"` 51 Name string `json:"name"` 52 Parameters map[string]interface{} `json:"parameters,omitempty"` 53 Parallel *bool `json:"parallel,omitempty"` 54 ExecutionGroup *string `json:"execution-group,omitempty"` 55 } 56 57 // EnqueuedActions represents the result of enqueuing actions to run. 58 type EnqueuedActions struct { 59 OperationTag string `json:"operation"` 60 Actions []ActionResult `json:"actions,omitempty"` 61 } 62 63 type EnqueuedActionsV2 struct { 64 OperationTag string `json:"operation"` 65 Actions []ActionResult `json:"actions,omitempty"` 66 } 67 68 // ActionResults is a slice of ActionResult for bulk requests. 69 type ActionResults struct { 70 Results []ActionResult `json:"results,omitempty"` 71 } 72 73 // ActionMessage represents a logged message on an action. 74 type ActionMessage struct { 75 Timestamp time.Time `json:"timestamp"` 76 Message string `json:"message"` 77 } 78 79 // ActionResult describes an Action that will be or has been completed. 80 type ActionResult struct { 81 Action *Action `json:"action,omitempty"` 82 Enqueued time.Time `json:"enqueued,omitempty"` 83 Started time.Time `json:"started,omitempty"` 84 Completed time.Time `json:"completed,omitempty"` 85 Status string `json:"status,omitempty"` 86 Message string `json:"message,omitempty"` 87 Log []ActionMessage `json:"log,omitempty"` 88 Output map[string]interface{} `json:"output,omitempty"` 89 Error *Error `json:"error,omitempty"` 90 } 91 92 // ActionsByReceivers wrap a slice of Actions for API calls. 93 type ActionsByReceivers struct { 94 Actions []ActionsByReceiver `json:"actions,omitempty"` 95 } 96 97 // ActionsByReceiver is a bulk API call wrapper containing Actions, 98 // either as input parameters or as results. 99 type ActionsByReceiver struct { 100 Receiver string `json:"receiver,omitempty"` 101 Actions []ActionResult `json:"actions,omitempty"` 102 Error *Error `json:"error,omitempty"` 103 } 104 105 // ActionsQueryResults holds a slice of responses from the Actions 106 // query. 107 type ActionsQueryResults struct { 108 Results []ActionsQueryResult `json:"results,omitempty"` 109 } 110 111 // ActionsQueryResult holds the name and parameters of an query result. 112 type ActionsQueryResult struct { 113 Receiver string `json:"receiver,omitempty"` 114 Action ActionResult `json:"action,omitempty"` 115 Error *Error `json:"error,omitempty"` 116 } 117 118 // OperationQueryArgs holds args for listing operations. 119 type OperationQueryArgs struct { 120 Applications []string `json:"applications,omitempty"` 121 Units []string `json:"units,omitempty"` 122 Machines []string `json:"machines,omitempty"` 123 ActionNames []string `json:"actions,omitempty"` 124 Status []string `json:"status,omitempty"` 125 126 // These attributes are used to support client side 127 // batching of results. 128 Offset *int `json:"offset,omitempty"` 129 Limit *int `json:"limit,omitempty"` 130 } 131 132 // OperationResults is a slice of OperationResult for bulk requests. 133 type OperationResults struct { 134 Results []OperationResult `json:"results,omitempty"` 135 Truncated bool `json:"truncated,omitempty"` 136 } 137 138 // OperationResult describes an Operation that will be or has been completed. 139 type OperationResult struct { 140 OperationTag string `json:"operation"` 141 Summary string `json:"summary"` 142 Fail string `json:"fail,omitempty"` 143 Enqueued time.Time `json:"enqueued,omitempty"` 144 Started time.Time `json:"started,omitempty"` 145 Completed time.Time `json:"completed,omitempty"` 146 Status string `json:"status,omitempty"` 147 Actions []ActionResult `json:"actions,omitempty"` 148 Error *Error `json:"error,omitempty"` 149 } 150 151 // ActionExecutionResults holds a slice of ActionExecutionResult for a 152 // bulk action API call 153 type ActionExecutionResults struct { 154 Results []ActionExecutionResult `json:"results,omitempty"` 155 } 156 157 // ActionExecutionResult holds the action tag and output used when 158 // recording the result of an action. 159 type ActionExecutionResult struct { 160 ActionTag string `json:"action-tag"` 161 Status string `json:"status"` 162 Results map[string]interface{} `json:"results,omitempty"` 163 Message string `json:"message,omitempty"` 164 } 165 166 // ApplicationsCharmActionsResults holds a slice of ApplicationCharmActionsResult for 167 // a bulk result of charm Actions for Applications. 168 type ApplicationsCharmActionsResults struct { 169 Results []ApplicationCharmActionsResult `json:"results,omitempty"` 170 } 171 172 // ApplicationCharmActionsResult holds application name and charm.Actions for the application. 173 // If an error such as a missing charm or malformed application name occurs, it 174 // is encapsulated in this type. 175 type ApplicationCharmActionsResult struct { 176 ApplicationTag string `json:"application-tag,omitempty"` 177 Actions map[string]ActionSpec `json:"actions,omitempty"` 178 Error *Error `json:"error,omitempty"` 179 } 180 181 // ActionSpec is a definition of the parameters and traits of an Action. 182 // The Params map is expected to conform to JSON-Schema Draft 4 as defined at 183 // http://json-schema.org/draft-04/schema# (see http://json-schema.org/latest/json-schema-core.html) 184 type ActionSpec struct { 185 Description string `json:"description"` 186 Params map[string]interface{} `json:"params"` 187 } 188 189 type ActionPruneArgs struct { 190 MaxHistoryTime time.Duration `json:"max-history-time"` 191 MaxHistoryMB int `json:"max-history-mb"` 192 } 193 194 // ActionMessageParams holds the arguments for 195 // logging progress messages for some actions. 196 type ActionMessageParams struct { 197 Messages []EntityString `json:"messages"` 198 }