github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/apiserver/facades/client/modelgeneration/interface.go (about)

     1  // Copyright 2019 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package modelgeneration
     5  
     6  import (
     7  	"github.com/juju/charm/v12"
     8  	"github.com/juju/names/v5"
     9  
    10  	"github.com/juju/juju/core/cache"
    11  	"github.com/juju/juju/core/settings"
    12  )
    13  
    14  //go:generate go run go.uber.org/mock/mockgen -package mocks -destination mocks/package_mock.go github.com/juju/juju/apiserver/facades/client/modelgeneration State,Model,Generation,Application,ModelCache
    15  
    16  // State represents the state of a model required by the model generation API.
    17  type State interface {
    18  	ControllerTag() names.ControllerTag
    19  	Model() (Model, error)
    20  	Application(string) (Application, error)
    21  }
    22  
    23  // Model describes model state used by the model generation API.
    24  type Model interface {
    25  	ModelTag() names.ModelTag
    26  	AddBranch(string, string) error
    27  	Branch(string) (Generation, error)
    28  	Branches() ([]Generation, error)
    29  	Generation(int) (Generation, error)
    30  	Generations() ([]Generation, error)
    31  }
    32  
    33  // ModelCache describes a cached model used by the model generation API.
    34  type ModelCache interface {
    35  	Branch(string) (cache.Branch, error)
    36  }
    37  
    38  // Generation defines the methods used by a generation.
    39  type Generation interface {
    40  	BranchName() string
    41  	Created() int64
    42  	CreatedBy() string
    43  	Completed() int64
    44  	CompletedBy() string
    45  	AssignAllUnits(string) error
    46  	AssignUnits(string, int) error
    47  	AssignUnit(string) error
    48  	AssignedUnits() map[string][]string
    49  	Commit(string) (int, error)
    50  	Abort(string) error
    51  	Config() map[string]settings.ItemChanges
    52  	GenerationId() int
    53  }
    54  
    55  // Application describes application state used by the model generation API.
    56  type Application interface {
    57  	UnitNames() ([]string, error)
    58  
    59  	// DefaultCharmConfig is the only abstraction in these shims.
    60  	// It saves us having to shim out Charm as well.
    61  	DefaultCharmConfig() (charm.Settings, error)
    62  }