github.com/juju/juju@v0.0.0-20240327075706-a90865de2538/api/agent/machineactions/action.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Copyright 2016 Cloudbase Solutions
     3  // Licensed under the AGPLv3, see LICENCE file for details.
     4  
     5  package machineactions
     6  
     7  // Action represents a single instance of an Action call, by name and params.
     8  // TODO(bogdantelega): This is currently copied from uniter.Actions,
     9  // but until the implementations converge, it's saner to duplicate the code since
    10  // the "correct" abstraction over both is not obvious.
    11  type Action struct {
    12  	id             string
    13  	name           string
    14  	params         map[string]interface{}
    15  	parallel       bool
    16  	executionGroup string
    17  }
    18  
    19  // NewAction makes a new Action with specified id, name and params map.
    20  func NewAction(id, name string, params map[string]interface{}, parallel bool, executionGroup string) *Action {
    21  	return &Action{id: id, name: name, params: params, parallel: parallel, executionGroup: executionGroup}
    22  }
    23  
    24  func (a *Action) ID() string {
    25  	return a.id
    26  }
    27  
    28  // Name retrieves the name of the Action.
    29  func (a *Action) Name() string {
    30  	return a.name
    31  }
    32  
    33  // Params retrieves the params map of the Action.
    34  func (a *Action) Params() map[string]interface{} {
    35  	return a.params
    36  }
    37  
    38  // Parallel returns true if the action can run without
    39  // needed to acquire the machine lock.
    40  func (a *Action) Parallel() bool {
    41  	return a.parallel
    42  }
    43  
    44  // ExecutionGroup is the group of actions which cannot
    45  // execute in parallel with each other.
    46  func (a *Action) ExecutionGroup() string {
    47  	return a.executionGroup
    48  }