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

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package action
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/juju/juju/api/base"
    10  	"github.com/juju/juju/api/common"
    11  	"github.com/juju/juju/apiserver/params"
    12  )
    13  
    14  const apiName = "ActionPruner"
    15  
    16  // Facade allows calls to "ActionPruner" endpoints
    17  type Facade struct {
    18  	facade base.FacadeCaller
    19  	*common.ModelWatcher
    20  }
    21  
    22  // NewFacade builds a facade for the action pruner endpoints
    23  func NewFacade(caller base.APICaller) *Facade {
    24  	facadeCaller := base.NewFacadeCaller(caller, apiName)
    25  	return &Facade{facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller)}
    26  }
    27  
    28  // Prunes action entries by specified age and size
    29  func (s *Facade) Prune(maxHistoryTime time.Duration, maxHistoryMB int) error {
    30  	p := params.ActionPruneArgs{
    31  		MaxHistoryTime: maxHistoryTime,
    32  		MaxHistoryMB:   maxHistoryMB,
    33  	}
    34  	return s.facade.FacadeCall("Prune", p, nil)
    35  }