github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/apiserver/machineactions/shim.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  import (
     8  	"github.com/juju/juju/apiserver/common"
     9  	"github.com/juju/juju/apiserver/params"
    10  	"github.com/juju/juju/state"
    11  	"github.com/juju/names"
    12  )
    13  
    14  func init() {
    15  	common.RegisterStandardFacade("MachineActions", 1, newFacade)
    16  }
    17  
    18  func newFacade(st *state.State, res *common.Resources, auth common.Authorizer) (*Facade, error) {
    19  	return NewFacade(backendShim{st}, res, auth)
    20  }
    21  
    22  type backendShim struct {
    23  	st *state.State
    24  }
    25  
    26  func (shim backendShim) ActionByTag(tag names.ActionTag) (state.Action, error) {
    27  	return shim.st.ActionByTag(tag)
    28  }
    29  
    30  func (shim backendShim) FindEntity(tag names.Tag) (state.Entity, error) {
    31  	return shim.st.FindEntity(tag)
    32  }
    33  
    34  func (shim backendShim) TagToActionReceiverFn(findEntity func(names.Tag) (state.Entity, error)) func(string) (state.ActionReceiver, error) {
    35  	return common.TagToActionReceiverFn(findEntity)
    36  }
    37  
    38  func (shim backendShim) ConvertActions(ar state.ActionReceiver, fn common.GetActionsFn) ([]params.ActionResult, error) {
    39  	return common.ConvertActions(ar, fn)
    40  }