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