github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/api/fanconfigurer/facade.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package fanconfigurer
     5  
     6  import (
     7  	"github.com/juju/juju/api/base"
     8  	apiwatcher "github.com/juju/juju/api/watcher"
     9  	"github.com/juju/juju/apiserver/common/networkingcommon"
    10  	"github.com/juju/juju/apiserver/params"
    11  	"github.com/juju/juju/core/watcher"
    12  	"github.com/juju/juju/network"
    13  )
    14  
    15  // Facade provides access to the FanConfigurer API facade.
    16  type Facade struct {
    17  	caller base.FacadeCaller
    18  }
    19  
    20  // NewFacade creates a new client-side FanConfigu	er facade.
    21  func NewFacade(caller base.APICaller) *Facade {
    22  	return &Facade{
    23  		caller: base.NewFacadeCaller(caller, "FanConfigurer"),
    24  	}
    25  }
    26  
    27  // WatchForFanConfigChanges return a NotifyWatcher waiting for the
    28  // fan configuration to change.
    29  func (f *Facade) WatchForFanConfigChanges() (watcher.NotifyWatcher, error) {
    30  	var result params.NotifyWatchResult
    31  	err := f.caller.FacadeCall("WatchForFanConfigChanges", nil, &result)
    32  	if err != nil {
    33  		return nil, err
    34  	}
    35  	return apiwatcher.NewNotifyWatcher(f.caller.RawAPICaller(), result), nil
    36  }
    37  
    38  // FanConfig returns the current fan configuration.
    39  func (f *Facade) FanConfig() (network.FanConfig, error) {
    40  	var result params.FanConfigResult
    41  	err := f.caller.FacadeCall("FanConfig", nil, &result)
    42  	if err != nil {
    43  		return nil, err
    44  	}
    45  	return networkingcommon.FanConfigResultToFanConfig(result)
    46  }