forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
1,517 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2017 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package action | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/juju/juju/api/base" | ||
"github.com/juju/juju/api/common" | ||
"github.com/juju/juju/apiserver/params" | ||
) | ||
|
||
const apiName = "ActionPruner" | ||
|
||
// Facade allows calls to "ActionPruner" endpoints | ||
type Facade struct { | ||
facade base.FacadeCaller | ||
*common.ModelWatcher | ||
} | ||
|
||
// NewFacade builds a facade for the action pruner endpoints | ||
func NewFacade(caller base.APICaller) *Facade { | ||
facadeCaller := base.NewFacadeCaller(caller, apiName) | ||
return &Facade{facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller)} | ||
} | ||
|
||
// Prunes action entries by specified age and size | ||
func (s *Facade) Prune(maxHistoryTime time.Duration, maxHistoryMB int) error { | ||
p := params.ActionPruneArgs{ | ||
MaxHistoryTime: maxHistoryTime, | ||
MaxHistoryMB: maxHistoryMB, | ||
} | ||
return s.facade.FacadeCall("Prune", p, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2017 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package actionpruner | ||
|
||
import ( | ||
"github.com/juju/juju/apiserver/common" | ||
"github.com/juju/juju/apiserver/facade" | ||
"github.com/juju/juju/apiserver/params" | ||
"github.com/juju/juju/state" | ||
) | ||
|
||
type API struct { | ||
*common.ModelWatcher | ||
st *state.State | ||
authorizer facade.Authorizer | ||
} | ||
|
||
func NewAPI(st *state.State, r facade.Resources, auth facade.Authorizer) (*API, error) { | ||
return &API{ | ||
ModelWatcher: common.NewModelWatcher(st, r, auth), | ||
st: st, | ||
authorizer: auth, | ||
}, nil | ||
} | ||
|
||
func (api *API) Prune(p params.ActionPruneArgs) error { | ||
if !api.authorizer.AuthController() { | ||
return common.ErrPerm | ||
} | ||
|
||
return state.PruneActions(api.st, p.MaxHistoryTime, p.MaxHistoryMB) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.