github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/worker/caasoperator/client.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package caasoperator
     5  
     6  import (
     7  	"github.com/juju/charm/v12"
     8  	"github.com/juju/version/v2"
     9  
    10  	caasoperatorapi "github.com/juju/juju/api/agent/caasoperator"
    11  	"github.com/juju/juju/core/life"
    12  	"github.com/juju/juju/core/model"
    13  	"github.com/juju/juju/core/status"
    14  	"github.com/juju/juju/core/watcher"
    15  )
    16  
    17  // Client provides an interface for interacting
    18  // with the CAASOperator API. Subsets of this
    19  // should be passed to the CAASOperator worker.
    20  type Client interface {
    21  	CharmGetter
    22  	UnitGetter
    23  	UnitRemover
    24  	ApplicationWatcher
    25  	ContainerStartWatcher
    26  	StatusSetter
    27  	VersionSetter
    28  	Model() (*model.Model, error)
    29  }
    30  
    31  // CharmGetter provides an interface for getting
    32  // the URL and SHA256 hash of the charm currently
    33  // assigned to the application.
    34  type CharmGetter interface {
    35  	Charm(application string) (*caasoperatorapi.CharmInfo, error)
    36  }
    37  
    38  // UnitGetter provides an interface for watching for
    39  // the lifecycle state changes (including addition)
    40  // of a specified application's units, and fetching
    41  // their details.
    42  type UnitGetter interface {
    43  	WatchUnits(string) (watcher.StringsWatcher, error)
    44  	Life(string) (life.Value, error)
    45  }
    46  
    47  // UnitRemover provides an interface for
    48  // removing a unit.
    49  type UnitRemover interface {
    50  	RemoveUnit(string) error
    51  }
    52  
    53  // ApplicationWatcher provides an interface watching
    54  // for application changes.
    55  type ApplicationWatcher interface {
    56  	Watch(string) (watcher.NotifyWatcher, error)
    57  }
    58  
    59  // ContainerStartWatcher provides an interface for watching
    60  // for unit starts.
    61  type ContainerStartWatcher interface {
    62  	WatchContainerStart(string, string) (watcher.StringsWatcher, error)
    63  }
    64  
    65  // StatusSetter provides an interface for setting
    66  // the status of a CAAS application.
    67  type StatusSetter interface {
    68  	// SetStatus sets the status of an application.
    69  	SetStatus(
    70  		application string,
    71  		status status.Status,
    72  		info string,
    73  		data map[string]interface{},
    74  	) error
    75  }
    76  
    77  // CharmConfigGetter provides an interface for
    78  // watching and getting the application's charm config settings.
    79  type CharmConfigGetter interface {
    80  	CharmConfig(string) (charm.Settings, error)
    81  	WatchCharmConfig(string) (watcher.NotifyWatcher, error)
    82  }
    83  
    84  // VersionSetter provides an interface for setting
    85  // the operator agent version.
    86  type VersionSetter interface {
    87  	SetVersion(appName string, v version.Binary) error
    88  }