github.com/juju/juju@v0.0.0-20240327075706-a90865de2538/worker/caasunitprovisioner/client.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package caasunitprovisioner
     5  
     6  import (
     7  	charmscommon "github.com/juju/juju/api/common/charms"
     8  	apicaasunitprovisioner "github.com/juju/juju/api/controller/caasunitprovisioner"
     9  	"github.com/juju/juju/caas"
    10  	"github.com/juju/juju/core/config"
    11  	"github.com/juju/juju/core/life"
    12  	"github.com/juju/juju/core/status"
    13  	"github.com/juju/juju/core/watcher"
    14  	"github.com/juju/juju/rpc/params"
    15  )
    16  
    17  // Client provides an interface for interacting with the
    18  // CAASUnitProvisioner API. Subsets of this should be passed
    19  // to the CAASUnitProvisioner worker.
    20  type Client interface {
    21  	ApplicationGetter
    22  	ApplicationUpdater
    23  	ProvisioningInfoGetter
    24  	LifeGetter
    25  	UnitUpdater
    26  	ProvisioningStatusSetter
    27  	CharmGetter
    28  }
    29  
    30  // ApplicationGetter provides an interface for
    31  // watching for the lifecycle state changes
    32  // (including addition) of applications in the
    33  // model, and fetching their details.
    34  type ApplicationGetter interface {
    35  	WatchApplications() (watcher.StringsWatcher, error)
    36  	WatchApplication(appName string) (watcher.NotifyWatcher, error)
    37  	ApplicationConfig(string) (config.ConfigAttributes, error)
    38  	DeploymentMode(string) (caas.DeploymentMode, error)
    39  	WatchApplicationScale(string) (watcher.NotifyWatcher, error)
    40  	ApplicationScale(string) (int, error)
    41  }
    42  
    43  // ApplicationUpdater provides an interface for updating
    44  // Juju applications from changes in the cloud.
    45  type ApplicationUpdater interface {
    46  	UpdateApplicationService(arg params.UpdateApplicationServiceArg) error
    47  	ClearApplicationResources(appName string) error
    48  }
    49  
    50  // ProvisioningInfoGetter provides an interface for
    51  // watching and getting the pod spec and other info
    52  // needed to provision an application.
    53  type ProvisioningInfoGetter interface {
    54  	ProvisioningInfo(appName string) (*apicaasunitprovisioner.ProvisioningInfo, error)
    55  	WatchPodSpec(appName string) (watcher.NotifyWatcher, error)
    56  }
    57  
    58  // LifeGetter provides an interface for getting the
    59  // lifecycle state value for an application or unit.
    60  type LifeGetter interface {
    61  	Life(string) (life.Value, error)
    62  }
    63  
    64  // UnitUpdater provides an interface for updating
    65  // Juju units from changes in the cloud.
    66  type UnitUpdater interface {
    67  	UpdateUnits(arg params.UpdateApplicationUnits) (*params.UpdateApplicationUnitsInfo, error)
    68  }
    69  
    70  // ProvisioningStatusSetter provides an interface for
    71  // setting status information.
    72  type ProvisioningStatusSetter interface {
    73  	// SetOperatorStatus sets the status for the application operator.
    74  	SetOperatorStatus(appName string, status status.Status, message string, data map[string]interface{}) error
    75  }
    76  
    77  type CharmGetter interface {
    78  	ApplicationCharmInfo(appName string) (*charmscommon.CharmInfo, error)
    79  }