github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/state/api/machiner/machiner.go (about)

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package machiner
     5  
     6  import (
     7  	"launchpad.net/juju-core/state/api/base"
     8  	"launchpad.net/juju-core/state/api/common"
     9  	"launchpad.net/juju-core/state/api/params"
    10  )
    11  
    12  // State provides access to the Machiner API facade.
    13  type State struct {
    14  	caller base.Caller
    15  }
    16  
    17  // NewState creates a new client-side Machiner facade.
    18  func NewState(caller base.Caller) *State {
    19  	return &State{caller}
    20  }
    21  
    22  // machineLife requests the lifecycle of the given machine from the server.
    23  func (st *State) machineLife(tag string) (params.Life, error) {
    24  	return common.Life(st.caller, "Machiner", tag)
    25  }
    26  
    27  // Machine provides access to methods of a state.Machine through the facade.
    28  func (st *State) Machine(tag string) (*Machine, error) {
    29  	life, err := st.machineLife(tag)
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  	return &Machine{
    34  		tag:  tag,
    35  		life: life,
    36  		st:   st,
    37  	}, nil
    38  }