github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/api/migrationtarget/client.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package migrationtarget 5 6 import ( 7 "github.com/juju/names" 8 9 "github.com/juju/juju/api/base" 10 "github.com/juju/juju/apiserver/params" 11 ) 12 13 // Client describes the client side API for the MigrationTarget 14 // facade. It is called by the migration master worker to talk to the 15 // target controller during a migration. 16 type Client interface { 17 // Import takes a serialized model and imports it into the target 18 // controller. 19 Import([]byte) error 20 21 // Abort removes all data relating to a previously imported 22 // model. 23 Abort(string) error 24 25 // Activate marks a migrated model as being ready to use. 26 Activate(string) error 27 } 28 29 // NewClient returns a new Client based on an existing API connection. 30 func NewClient(caller base.APICaller) Client { 31 return &client{base.NewFacadeCaller(caller, "MigrationTarget")} 32 } 33 34 // client implements Client. 35 type client struct { 36 caller base.FacadeCaller 37 } 38 39 // Import implements Client. 40 func (c *client) Import(bytes []byte) error { 41 serialized := params.SerializedModel{Bytes: bytes} 42 return c.caller.FacadeCall("Import", serialized, nil) 43 } 44 45 // Abort implements Client. 46 func (c *client) Abort(modelUUID string) error { 47 args := params.ModelArgs{ModelTag: names.NewModelTag(modelUUID).String()} 48 return c.caller.FacadeCall("Abort", args, nil) 49 } 50 51 // Activate implements Client. 52 func (c *client) Activate(modelUUID string) error { 53 args := params.ModelArgs{ModelTag: names.NewModelTag(modelUUID).String()} 54 return c.caller.FacadeCall("Activate", args, nil) 55 }