github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/facades/client/action/register.go (about) 1 // Copyright 2022 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package action 5 6 import ( 7 "reflect" 8 9 "github.com/juju/errors" 10 11 "github.com/juju/juju/apiserver/facade" 12 ) 13 14 // Register is called to expose a package of facades onto a given registry. 15 func Register(registry facade.FacadeRegistry) { 16 registry.MustRegister("Action", 7, func(ctx facade.Context) (facade.Facade, error) { 17 return newActionAPIV7(ctx) 18 }, reflect.TypeOf((*APIv7)(nil))) 19 } 20 21 // newActionAPIV7 returns an initialized ActionAPI for version 7. 22 func newActionAPIV7(ctx facade.Context) (*APIv7, error) { 23 api, err := newActionAPI(&stateShim{st: ctx.State()}, ctx.Resources(), ctx.Auth(), ctx.LeadershipReader) 24 if err != nil { 25 return nil, errors.Trace(err) 26 } 27 return &APIv7{api}, nil 28 }