github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/params/internal.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package params
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/juju/version/v2"
    10  
    11  	"github.com/juju/juju/core/constraints"
    12  	"github.com/juju/juju/core/instance"
    13  	"github.com/juju/juju/core/life"
    14  	"github.com/juju/juju/core/model"
    15  	"github.com/juju/juju/core/status"
    16  	"github.com/juju/juju/tools"
    17  )
    18  
    19  // MachineContainersParams holds the arguments for making a SetSupportedContainers
    20  // API call.
    21  type MachineContainersParams struct {
    22  	Params []MachineContainers `json:"params"`
    23  }
    24  
    25  // MachineContainers holds the arguments for making an SetSupportedContainers call
    26  // on a given machine.
    27  type MachineContainers struct {
    28  	MachineTag     string                   `json:"machine-tag"`
    29  	ContainerTypes []instance.ContainerType `json:"container-types"`
    30  }
    31  
    32  // MachineContainerResults holds the results from making the call to SupportedContainers
    33  // on a given machine.
    34  type MachineContainerResults struct {
    35  	Results []MachineContainerResult `json:"results"`
    36  }
    37  
    38  // MachineContainerResult holds the result of making the call to SupportedContainers
    39  // on a given machine.
    40  type MachineContainerResult struct {
    41  	Error          *Error                   `json:"error,omitempty"`
    42  	ContainerTypes []instance.ContainerType `json:"container-types"`
    43  	Determined     bool                     `json:"determined"`
    44  }
    45  
    46  // WatchContainer identifies a single container type within a machine.
    47  type WatchContainer struct {
    48  	MachineTag    string `json:"machine-tag"`
    49  	ContainerType string `json:"container-type"`
    50  }
    51  
    52  // WatchContainers holds the arguments for making a WatchContainers
    53  // API call.
    54  type WatchContainers struct {
    55  	Params []WatchContainer `json:"params"`
    56  }
    57  
    58  // CharmURL identifies a single charm URL.
    59  type CharmURL struct {
    60  	URL string `json:"url"`
    61  }
    62  
    63  // CharmURLs identifies multiple charm URLs.
    64  type CharmURLs struct {
    65  	URLs []CharmURL `json:"urls"`
    66  }
    67  
    68  // StringsResult holds the result of an API call that returns a slice
    69  // of strings or an error.
    70  type StringsResult struct {
    71  	Error  *Error   `json:"error,omitempty"`
    72  	Result []string `json:"result,omitempty"`
    73  }
    74  
    75  // StringsResults holds the bulk operation result of an API call
    76  // that returns a slice of strings or an error.
    77  type StringsResults struct {
    78  	Results []StringsResult `json:"results"`
    79  }
    80  
    81  // StringResult holds a string or an error.
    82  type StringResult struct {
    83  	Error  *Error `json:"error,omitempty"`
    84  	Result string `json:"result"`
    85  }
    86  
    87  // StringResults holds the bulk operation result of an API call
    88  // that returns a string or an error.
    89  type StringResults struct {
    90  	Results []StringResult `json:"results"`
    91  }
    92  
    93  // MapResult holds a generic map or an error.
    94  type MapResult struct {
    95  	Result map[string]interface{} `json:"result"`
    96  	Error  *Error                 `json:"error,omitempty"`
    97  }
    98  
    99  // MapResults holds the bulk operation result of an API call
   100  // that returns a map or an error.
   101  type MapResults struct {
   102  	Results []MapResult `json:"results"`
   103  }
   104  
   105  // ModelResult holds the result of an API call returning a name and UUID
   106  // for a model.
   107  type ModelResult struct {
   108  	Error *Error `json:"error,omitempty"`
   109  	Name  string `json:"name"`
   110  	UUID  string `json:"uuid"`
   111  	Type  string `json:"type"`
   112  }
   113  
   114  // ModelCreateArgs holds the arguments that are necessary to create
   115  // a model.
   116  type ModelCreateArgs struct {
   117  	// Name is the name for the new model.
   118  	Name string `json:"name"`
   119  
   120  	// OwnerTag represents the user that will own the new model.
   121  	// The OwnerTag must be a valid user tag.  If the user tag represents
   122  	// a local user, that user must exist.
   123  	OwnerTag string `json:"owner-tag"`
   124  
   125  	// Config defines the model config, which includes the name of the
   126  	// model. A model UUID is allocated by the API server during the
   127  	// creation of the model.
   128  	Config map[string]interface{} `json:"config,omitempty"`
   129  
   130  	// CloudTag is the tag of the cloud to create the model in.
   131  	// If this is empty, the model will be created in the same
   132  	// cloud as the controller model.
   133  	CloudTag string `json:"cloud-tag,omitempty"`
   134  
   135  	// CloudRegion is the name of the cloud region to create the
   136  	// model in. If the cloud does not support regions, this must
   137  	// be empty. If this is empty, and CloudTag is empty, the model
   138  	// will be created in the same region as the controller model.
   139  	CloudRegion string `json:"region,omitempty"`
   140  
   141  	// CloudCredentialTag is the tag of the cloud credential to use
   142  	// for managing the model's resources. If the cloud does not
   143  	// require credentials, this may be empty. If this is empty,
   144  	// and the owner is the controller owner, the same credential
   145  	// used for the controller model will be used.
   146  	CloudCredentialTag string `json:"credential,omitempty"`
   147  }
   148  
   149  // Model holds the result of an API call returning a name and UUID
   150  // for a model and the tag of the server in which it is running.
   151  type Model struct {
   152  	Name     string `json:"name"`
   153  	UUID     string `json:"uuid"`
   154  	Type     string `json:"type"`
   155  	OwnerTag string `json:"owner-tag"`
   156  }
   157  
   158  // UserModel holds information about a model and the last
   159  // time the model was accessed for a particular user.
   160  type UserModel struct {
   161  	Model          `json:"model"`
   162  	LastConnection *time.Time `json:"last-connection"`
   163  }
   164  
   165  // UserModelList holds information about a list of models
   166  // for a particular user.
   167  type UserModelList struct {
   168  	UserModels []UserModel `json:"user-models"`
   169  }
   170  
   171  // ResolvedModeResult holds a resolved mode or an error.
   172  type ResolvedModeResult struct {
   173  	Error *Error       `json:"error,omitempty"`
   174  	Mode  ResolvedMode `json:"mode"`
   175  }
   176  
   177  // ResolvedModeResults holds the bulk operation result of an API call
   178  // that returns a resolved mode or an error.
   179  type ResolvedModeResults struct {
   180  	Results []ResolvedModeResult `json:"results"`
   181  }
   182  
   183  // StringBoolResult holds the result of an API call that returns a
   184  // string and a boolean.
   185  type StringBoolResult struct {
   186  	Error  *Error `json:"error,omitempty"`
   187  	Result string `json:"result"`
   188  	Ok     bool   `json:"ok"`
   189  }
   190  
   191  // StringBoolResults holds multiple results with a string and a bool
   192  // each.
   193  type StringBoolResults struct {
   194  	Results []StringBoolResult `json:"results"`
   195  }
   196  
   197  // BoolResult holds the result of an API call that returns a
   198  // a boolean or an error.
   199  type BoolResult struct {
   200  	Error  *Error `json:"error,omitempty"`
   201  	Result bool   `json:"result"`
   202  }
   203  
   204  // BoolResults holds multiple results with BoolResult each.
   205  type BoolResults struct {
   206  	Results []BoolResult `json:"results"`
   207  }
   208  
   209  // IntResults holds multiple results with an int in each.
   210  type IntResults struct {
   211  	// Results holds a list of results for calls that return an int or error.
   212  	Results []IntResult `json:"results"`
   213  }
   214  
   215  // IntResult holds the result of an API call that returns a
   216  // int or an error.
   217  type IntResult struct {
   218  	// Error holds the error (if any) of this call.
   219  	Error *Error `json:"error,omitempty"`
   220  	// Result holds the integer result of the call (if Error is nil).
   221  	Result int `json:"result"`
   222  }
   223  
   224  // Settings holds relation settings names and values.
   225  type Settings map[string]string
   226  
   227  // SettingsResult holds a relation settings map or an error.
   228  type SettingsResult struct {
   229  	Error    *Error   `json:"error,omitempty"`
   230  	Settings Settings `json:"settings"`
   231  }
   232  
   233  // SettingsResults holds the result of an API calls that
   234  // returns settings for multiple relations.
   235  type SettingsResults struct {
   236  	Results []SettingsResult `json:"results"`
   237  }
   238  
   239  // ConfigSettings holds unit, application or charm configuration settings
   240  // with string keys and arbitrary values.
   241  type ConfigSettings map[string]interface{}
   242  
   243  // ConfigSettingsResult holds a configuration map or an error.
   244  type ConfigSettingsResult struct {
   245  	Error    *Error         `json:"error,omitempty"`
   246  	Settings ConfigSettings `json:"settings"`
   247  }
   248  
   249  // ConfigSettingsResults holds multiple configuration maps or errors.
   250  type ConfigSettingsResults struct {
   251  	Results []ConfigSettingsResult `json:"results"`
   252  }
   253  
   254  // UnitStateResult holds a unit's state map or an error.
   255  type UnitStateResult struct {
   256  	Error *Error `json:"error,omitempty"`
   257  	// Charm state set by the unit via hook tool.
   258  	CharmState map[string]string `json:"charm-state,omitempty"`
   259  	// Uniter internal state for this unit.
   260  	UniterState string `json:"uniter-state,omitempty"`
   261  	// RelationState is a internal relation state for this unit.
   262  	RelationState map[int]string `json:"relation-state,omitempty"`
   263  	// StorageState is a internal storage state for this unit.
   264  	StorageState string `json:"storage-state,omitempty"`
   265  	// SecretState is internal secret state for this unit.
   266  	SecretState string `json:"secret-state,omitempty"`
   267  	// MeterStatusState encodes the meter status state for this unit.
   268  	MeterStatusState string `json:"meter-status-state,omitempty"`
   269  }
   270  
   271  // UnitStateResults holds multiple unit state maps or errors.
   272  type UnitStateResults struct {
   273  	Results []UnitStateResult `json:"results"`
   274  }
   275  
   276  // SetUnitStateArgs holds multiple SetUnitStateArg objects to be persisted by the controller.
   277  type SetUnitStateArgs struct {
   278  	Args []SetUnitStateArg `json:"args"`
   279  }
   280  
   281  // SetUnitStateArg holds a unit tag and pointers to data persisted from
   282  // or via the uniter. State is a map with KV-pairs that represent a
   283  // local charm state to be persisted by the controller.  The other fields
   284  // represent uniter internal data.
   285  //
   286  // Each field with omitempty is optional, setting it will cause the field
   287  // to be evaluated for changes to the persisted data.  A pointer to nil or
   288  // empty data will cause the persisted data to be deleted.
   289  type SetUnitStateArg struct {
   290  	Tag              string             `json:"tag"`
   291  	CharmState       *map[string]string `json:"charm-state,omitempty"`
   292  	UniterState      *string            `json:"uniter-state,omitempty"`
   293  	RelationState    *map[int]string    `json:"relation-state,omitempty"`
   294  	StorageState     *string            `json:"storage-state,omitempty"`
   295  	SecretState      *string            `json:"secret-state,omitempty"`
   296  	MeterStatusState *string            `json:"meter-status-state,omitempty"`
   297  }
   298  
   299  // CommitHookChangesArgs serves as a container for CommitHookChangesArg objects
   300  // to be processed by the controller.
   301  type CommitHookChangesArgs struct {
   302  	Args []CommitHookChangesArg `json:"args"`
   303  }
   304  
   305  // CommitHookChangesArg holds a unit tag and a list of optional uniter API
   306  // call payloads that are to be executed transactionally.
   307  type CommitHookChangesArg struct {
   308  	Tag string `json:"tag"`
   309  
   310  	UpdateNetworkInfo    bool                   `json:"update-network-info"`
   311  	RelationUnitSettings []RelationUnitSettings `json:"relation-unit-settings,omitempty"`
   312  	OpenPorts            []EntityPortRange      `json:"open-ports,omitempty"`
   313  	ClosePorts           []EntityPortRange      `json:"close-ports,omitempty"`
   314  	SetUnitState         *SetUnitStateArg       `json:"unit-state,omitempty"`
   315  	AddStorage           []StorageAddParams     `json:"add-storage,omitempty"`
   316  	SetPodSpec           *PodSpec               `json:"pod-spec,omitempty"`
   317  	SetRawK8sSpec        *PodSpec               `json:"set-raw-k8s-spec,omitempty"`
   318  	SecretCreates        []CreateSecretArg      `json:"secret-creates,omitempty"`
   319  	TrackLatest          []string               `json:"secret-track-latest,omitempty"`
   320  	SecretUpdates        []UpdateSecretArg      `json:"secret-updates,omitempty"`
   321  	SecretGrants         []GrantRevokeSecretArg `json:"secret-grants,omitempty"`
   322  	SecretRevokes        []GrantRevokeSecretArg `json:"secret-revokes,omitempty"`
   323  	SecretDeletes        []DeleteSecretArg      `json:"secret-deletes,omitempty"`
   324  }
   325  
   326  // ModelConfig holds a model configuration.
   327  type ModelConfig map[string]interface{}
   328  
   329  // ControllerConfig holds a controller configuration.
   330  type ControllerConfig map[string]interface{}
   331  
   332  // ModelConfigResult holds model configuration.
   333  type ModelConfigResult struct {
   334  	Config ModelConfig `json:"config"`
   335  }
   336  
   337  // ControllerConfigResult holds controller configuration.
   338  type ControllerConfigResult struct {
   339  	Config ControllerConfig `json:"config"`
   340  }
   341  
   342  // ControllerAPIInfoResult holds controller api address details.
   343  type ControllerAPIInfoResult struct {
   344  	Addresses []string `json:"addresses"`
   345  	CACert    string   `json:"cacert"`
   346  	Error     *Error   `json:"error,omitempty"`
   347  }
   348  
   349  // ControllerAPIInfoResults holds controller api address details results.
   350  type ControllerAPIInfoResults struct {
   351  	Results []ControllerAPIInfoResult `json:"results"`
   352  }
   353  
   354  // RelationUnit holds a relation and a unit tag.
   355  type RelationUnit struct {
   356  	Relation string `json:"relation"`
   357  	Unit     string `json:"unit"`
   358  }
   359  
   360  // RelationUnits holds the parameters for API calls expecting a pair
   361  // of relation and unit tags.
   362  type RelationUnits struct {
   363  	RelationUnits []RelationUnit `json:"relation-units"`
   364  }
   365  
   366  // RelationIds holds multiple relation ids.
   367  type RelationIds struct {
   368  	RelationIds []int `json:"relation-ids"`
   369  }
   370  
   371  // RelationUnitPair holds a relation tag, a local and remote unit tags.
   372  type RelationUnitPair struct {
   373  	Relation   string `json:"relation"`
   374  	LocalUnit  string `json:"local-unit"`
   375  	RemoteUnit string `json:"remote-unit"`
   376  }
   377  
   378  // RelationUnitPairs holds the parameters for API calls expecting
   379  // multiple sets of a relation tag, a local and remote unit tags.
   380  type RelationUnitPairs struct {
   381  	RelationUnitPairs []RelationUnitPair `json:"relation-unit-pairs"`
   382  }
   383  
   384  // RelationUnitSettings holds a relation tag, a unit tag and local
   385  // unit and app-level settings.
   386  // TODO(juju3) - remove
   387  type RelationUnitSettings struct {
   388  	Relation            string   `json:"relation"`
   389  	Unit                string   `json:"unit"`
   390  	Settings            Settings `json:"settings"`
   391  	ApplicationSettings Settings `json:"application-settings"`
   392  }
   393  
   394  // RelationUnitsSettings holds the arguments for making a EnterScope
   395  // or UpdateRelationSettings API calls.
   396  // TODO(juju3) - remove
   397  type RelationUnitsSettings struct {
   398  	RelationUnits []RelationUnitSettings `json:"relation-units"`
   399  }
   400  
   401  // RelationResults holds the result of an API call that returns
   402  // information about multiple relations.
   403  type RelationResults struct {
   404  	Results []RelationResult `json:"results"`
   405  }
   406  
   407  // RelationResult returns information about a single relation,
   408  // or an error.
   409  type RelationResult struct {
   410  	Error            *Error     `json:"error,omitempty"`
   411  	Life             life.Value `json:"life"`
   412  	Suspended        bool       `json:"bool,omitempty"`
   413  	Id               int        `json:"id"`
   414  	Key              string     `json:"key"`
   415  	Endpoint         Endpoint   `json:"endpoint"`
   416  	OtherApplication string     `json:"other-application,omitempty"`
   417  }
   418  
   419  // EntityCharmURL holds an entity's tag and a charm URL.
   420  type EntityCharmURL struct {
   421  	Tag      string `json:"tag"`
   422  	CharmURL string `json:"charm-url"`
   423  }
   424  
   425  // EntitiesCharmURL holds the parameters for making a SetCharmURL API
   426  // call.
   427  type EntitiesCharmURL struct {
   428  	Entities []EntityCharmURL `json:"entities"`
   429  }
   430  
   431  // EntityWorkloadVersion holds the workload version for an entity.
   432  type EntityWorkloadVersion struct {
   433  	Tag             string `json:"tag"`
   434  	WorkloadVersion string `json:"workload-version"`
   435  }
   436  
   437  // EntityWorkloadVersions holds the parameters for setting the
   438  // workload version for a set of entities.
   439  type EntityWorkloadVersions struct {
   440  	Entities []EntityWorkloadVersion `json:"entities"`
   441  }
   442  
   443  // BytesResult holds the result of an API call that returns a slice
   444  // of bytes.
   445  type BytesResult struct {
   446  	Result []byte `json:"result"`
   447  }
   448  
   449  // LifeResult holds the life status of a single entity, or an error
   450  // indicating why it is not available.
   451  type LifeResult struct {
   452  	Life  life.Value `json:"life"`
   453  	Error *Error     `json:"error,omitempty"`
   454  }
   455  
   456  // LifeResults holds the life or error status of multiple entities.
   457  type LifeResults struct {
   458  	Results []LifeResult `json:"results"`
   459  }
   460  
   461  // InstanceInfo holds information about an instance. Instances are
   462  // typically virtual machines hosted by a cloud provider but may also
   463  // be a container.
   464  //
   465  // The InstanceInfo struct contains three categories of information:
   466  //   - interal data, as the machine's tag and the tags of any attached
   467  //     storage volumes
   468  //   - naming and other provider-specific information, including the
   469  //     instance id and display name
   470  //   - configuration information, including its attached storage volumes,
   471  //     charm profiles and networking
   472  type InstanceInfo struct {
   473  	Tag             string                            `json:"tag"`
   474  	InstanceId      instance.Id                       `json:"instance-id"`
   475  	DisplayName     string                            `json:"display-name"`
   476  	Nonce           string                            `json:"nonce"`
   477  	Characteristics *instance.HardwareCharacteristics `json:"characteristics"`
   478  	Volumes         []Volume                          `json:"volumes"`
   479  	// VolumeAttachments is a mapping from volume tag to
   480  	// volume attachment info.
   481  	VolumeAttachments map[string]VolumeAttachmentInfo `json:"volume-attachments"`
   482  
   483  	NetworkConfig []NetworkConfig `json:"network-config"`
   484  	CharmProfiles []string        `json:"charm-profiles"`
   485  }
   486  
   487  // InstancesInfo holds the parameters for making a SetInstanceInfo
   488  // call for multiple machines.
   489  type InstancesInfo struct {
   490  	Machines []InstanceInfo `json:"machines"`
   491  }
   492  
   493  // EntityStatus holds the status of an entity.
   494  type EntityStatus struct {
   495  	Status status.Status          `json:"status"`
   496  	Info   string                 `json:"info"`
   497  	Data   map[string]interface{} `json:"data,omitempty"`
   498  	Since  *time.Time             `json:"since"`
   499  }
   500  
   501  // EntityStatusArgs holds parameters for setting the status of a single entity.
   502  type EntityStatusArgs struct {
   503  	Tag    string                 `json:"tag"`
   504  	Status string                 `json:"status"`
   505  	Info   string                 `json:"info"`
   506  	Data   map[string]interface{} `json:"data"`
   507  }
   508  
   509  // SetStatus holds the parameters for making a SetStatus/UpdateStatus call.
   510  type SetStatus struct {
   511  	Entities []EntityStatusArgs `json:"entities"`
   512  }
   513  
   514  // ConstraintsResult holds machine constraints or an error.
   515  type ConstraintsResult struct {
   516  	Error       *Error            `json:"error,omitempty"`
   517  	Constraints constraints.Value `json:"constraints"`
   518  }
   519  
   520  // ConstraintsResults holds multiple constraints results.
   521  type ConstraintsResults struct {
   522  	Results []ConstraintsResult `json:"results"`
   523  }
   524  
   525  // AgentGetEntitiesResults holds the results of a
   526  // agent.API.GetEntities call.
   527  type AgentGetEntitiesResults struct {
   528  	Entities []AgentGetEntitiesResult `json:"entities"`
   529  }
   530  
   531  // AgentGetEntitiesResult holds the results of a
   532  // machineagent.API.GetEntities call for a single entity.
   533  type AgentGetEntitiesResult struct {
   534  	Life          life.Value             `json:"life"`
   535  	Jobs          []model.MachineJob     `json:"jobs"`
   536  	ContainerType instance.ContainerType `json:"container-type"`
   537  	Error         *Error                 `json:"error,omitempty"`
   538  }
   539  
   540  // VersionResult holds the version and possibly error for a given
   541  // DesiredVersion() API call.
   542  type VersionResult struct {
   543  	Version *version.Number `json:"version,omitempty"`
   544  	Error   *Error          `json:"error,omitempty"`
   545  }
   546  
   547  // VersionResults is a list of versions for the requested entities.
   548  type VersionResults struct {
   549  	Results []VersionResult `json:"results"`
   550  }
   551  
   552  // SetModelEnvironVersions holds the tags and associated environ versions
   553  // of a collection of models.
   554  type SetModelEnvironVersions struct {
   555  	Models []SetModelEnvironVersion `json:"models,omitempty"`
   556  }
   557  
   558  // SetModelEnvironVersion holds the tag and associated environ version
   559  // of a model.
   560  type SetModelEnvironVersion struct {
   561  	// ModelTag is the string representation of a model tag, which
   562  	// should be parsable using names.ParseModelTag.
   563  	ModelTag string `json:"model-tag"`
   564  
   565  	// Version is the environ version to set for the model.
   566  	Version int `json:"version"`
   567  }
   568  
   569  // ToolsResult holds the tools and possibly error for a given
   570  // Tools() API call.
   571  type ToolsResult struct {
   572  	ToolsList tools.List `json:"tools"`
   573  	Error     *Error     `json:"error,omitempty"`
   574  }
   575  
   576  // ToolsResults is a list of tools for various requested agents.
   577  type ToolsResults struct {
   578  	Results []ToolsResult `json:"results"`
   579  }
   580  
   581  // Version holds a specific binary version.
   582  type Version struct {
   583  	Version version.Binary `json:"version"`
   584  }
   585  
   586  // EntityVersion specifies the tools version to be set for an entity
   587  // with the given tag.
   588  // version.Binary directly.
   589  type EntityVersion struct {
   590  	Tag   string   `json:"tag"`
   591  	Tools *Version `json:"tools"`
   592  }
   593  
   594  // EntitiesVersion specifies what tools are being run for
   595  // multiple entities.
   596  type EntitiesVersion struct {
   597  	AgentTools []EntityVersion `json:"agent-tools"`
   598  }
   599  
   600  // NotifyWatchResult holds a NotifyWatcher id and an error (if any).
   601  type NotifyWatchResult struct {
   602  	NotifyWatcherId string
   603  	Error           *Error `json:"error,omitempty"`
   604  }
   605  
   606  // NotifyWatchResults holds the results for any API call which ends up
   607  // returning a list of NotifyWatchers
   608  type NotifyWatchResults struct {
   609  	Results []NotifyWatchResult `json:"results"`
   610  }
   611  
   612  // StringsWatchResult holds a StringsWatcher id, changes and an error
   613  // (if any).
   614  type StringsWatchResult struct {
   615  	StringsWatcherId string   `json:"watcher-id"`
   616  	Changes          []string `json:"changes,omitempty"`
   617  	Error            *Error   `json:"error,omitempty"`
   618  }
   619  
   620  // StringsWatchResults holds the results for any API call which ends up
   621  // returning a list of StringsWatchers.
   622  type StringsWatchResults struct {
   623  	Results []StringsWatchResult `json:"results"`
   624  }
   625  
   626  // EntitiesWatchResult holds a EntitiesWatcher id, changes and an error
   627  // (if any).
   628  type EntitiesWatchResult struct {
   629  	// Note legacy serialization tag.
   630  	EntitiesWatcherId string   `json:"watcher-id"`
   631  	Changes           []string `json:"changes,omitempty"`
   632  	Error             *Error   `json:"error,omitempty"`
   633  }
   634  
   635  // EntitiesWatchResults holds the results for any API call which ends up
   636  // returning a list of EntitiesWatchers.
   637  type EntitiesWatchResults struct {
   638  	Results []EntitiesWatchResult `json:"results"`
   639  }
   640  
   641  // UnitSettings specifies the version of some unit's settings in some relation.
   642  type UnitSettings struct {
   643  	Version int64 `json:"version"`
   644  }
   645  
   646  // RelationUnitsChange describes the membership and settings of; or changes to;
   647  // some relation scope.
   648  type RelationUnitsChange struct {
   649  
   650  	// Changed holds a set of units that are known to be in scope, and the
   651  	// latest known settings version for each.
   652  	Changed map[string]UnitSettings `json:"changed"`
   653  
   654  	// Changed holds the versions of each application data for applications related
   655  	// to this unit.
   656  	AppChanged map[string]int64 `json:"app-changed,omitempty"`
   657  
   658  	// Departed holds a set of units that have previously been reported to
   659  	// be in scope, but which no longer are.
   660  	Departed []string `json:"departed,omitempty"`
   661  }
   662  
   663  // RelationUnitsWatchResult holds a RelationUnitsWatcher id, baseline state
   664  // (in the Changes field), and an error (if any).
   665  type RelationUnitsWatchResult struct {
   666  	RelationUnitsWatcherId string              `json:"watcher-id"`
   667  	Changes                RelationUnitsChange `json:"changes"`
   668  	Error                  *Error              `json:"error,omitempty"`
   669  }
   670  
   671  // RelationUnitsWatchResults holds the results for any API call which ends up
   672  // returning a list of RelationUnitsWatchers.
   673  type RelationUnitsWatchResults struct {
   674  	Results []RelationUnitsWatchResult `json:"results"`
   675  }
   676  
   677  // RelationUnitStatus holds details about scope
   678  // and suspended status for a relation unit.
   679  type RelationUnitStatus struct {
   680  	RelationTag string `json:"relation-tag"`
   681  	InScope     bool   `json:"in-scope"`
   682  	Suspended   bool   `json:"suspended"`
   683  }
   684  
   685  // RelationUnitStatusResult holds details about scope and status for
   686  // relation units, and an error.
   687  type RelationUnitStatusResult struct {
   688  	RelationResults []RelationUnitStatus `json:"results"`
   689  	Error           *Error               `json:"error,omitempty"`
   690  }
   691  
   692  // RelationUnitStatusResults holds the results of a
   693  // uniter RelationStatus API call.
   694  type RelationUnitStatusResults struct {
   695  	Results []RelationUnitStatusResult `json:"results"`
   696  }
   697  
   698  // RelationApplications holds a set of pairs of relation & application
   699  // tags.
   700  type RelationApplications struct {
   701  	RelationApplications []RelationApplication `json:"relation-applications"`
   702  }
   703  
   704  // RelationApplication holds one (relation, application) pair.
   705  type RelationApplication struct {
   706  	Relation    string `json:"relation"`
   707  	Application string `json:"application"`
   708  }
   709  
   710  // MachineStorageIdsWatchResult holds a MachineStorageIdsWatcher id,
   711  // changes and an error (if any).
   712  type MachineStorageIdsWatchResult struct {
   713  	MachineStorageIdsWatcherId string             `json:"watcher-id"`
   714  	Changes                    []MachineStorageId `json:"changes"`
   715  	Error                      *Error             `json:"error,omitempty"`
   716  }
   717  
   718  // MachineStorageIdsWatchResults holds the results for any API call which ends
   719  // up returning a list of MachineStorageIdsWatchers.
   720  type MachineStorageIdsWatchResults struct {
   721  	Results []MachineStorageIdsWatchResult `json:"results"`
   722  }
   723  
   724  // CharmsResponse is the server response to charm upload or GET requests.
   725  type CharmsResponse struct {
   726  	Error string `json:"error,omitempty"`
   727  
   728  	// ErrorCode holds the code associated with the error.
   729  	// Ideally, Error would hold an Error object and the
   730  	// code would be in that, but for backward compatibility,
   731  	// we cannot do that.
   732  	ErrorCode string `json:"error-code,omitempty"`
   733  
   734  	// ErrorInfo holds extra information associated with the error.
   735  	ErrorInfo map[string]interface{} `json:"error-info,omitempty"`
   736  
   737  	CharmURL string   `json:"charm-url,omitempty"`
   738  	Files    []string `json:"files,omitempty"`
   739  }
   740  
   741  // RunParams is used to provide the parameters to the Run method.
   742  // Commands and Timeout are expected to have values, and one or more
   743  // values should be in the Machines, Applications, or Units slices.
   744  type RunParams struct {
   745  	Commands       string        `json:"commands"`
   746  	Timeout        time.Duration `json:"timeout"`
   747  	Machines       []string      `json:"machines,omitempty"`
   748  	Applications   []string      `json:"applications,omitempty"`
   749  	Units          []string      `json:"units,omitempty"`
   750  	Parallel       *bool         `json:"parallel,omitempty"`
   751  	ExecutionGroup *string       `json:"execution-group,omitempty"`
   752  
   753  	// WorkloadContext for CAAS is true when the Commands should be run on
   754  	// the workload not the operator.
   755  	WorkloadContext bool `json:"workload-context,omitempty"`
   756  }
   757  
   758  // RunResult contains the result from an individual run call on a machine.
   759  // UnitId is populated if the command was run inside the unit context.
   760  type RunResult struct {
   761  	Code   int    `json:"code-id"`
   762  	Stdout []byte `json:"stdout,omitempty"`
   763  	Stderr []byte `json:"stderr,omitempty"`
   764  	// FIXME: should be tags not id strings
   765  	MachineId string `json:"machine-id"`
   766  	UnitId    string `json:"unit-id"`
   767  	Error     string `json:"error"`
   768  }
   769  
   770  // RunResults is used to return the slice of results.  API server side calls
   771  // need to return single structure values.
   772  type RunResults struct {
   773  	Results []RunResult `json:"results"`
   774  }
   775  
   776  // AgentVersionResult is used to return the current version number of the
   777  // agent running the API server.
   778  type AgentVersionResult struct {
   779  	Version version.Number `json:"version"`
   780  }
   781  
   782  // RetryProvisioningArgs holds args for retrying machine provisioning.
   783  type RetryProvisioningArgs struct {
   784  	Machines []string `json:"machines,omitempty"`
   785  	All      bool     `json:"all"`
   786  }
   787  
   788  // ProvisioningNetworkTopology holds a network topology that is based on
   789  // positive machine space constraints.
   790  // This is used for creating NICs on instances where the provider is not space
   791  // aware; I.e. not MAAS.
   792  // We only care about positive constraints because negative constraints are
   793  // satisfied implicitly by only creating NICs connected to subnets in inclusive
   794  // spaces.
   795  type ProvisioningNetworkTopology struct {
   796  	// SubnetAZs is a map of availability zone names
   797  	// indexed by provider subnet ID.
   798  	SubnetAZs map[string][]string `json:"subnet-zones"`
   799  
   800  	// SpaceSubnets is a map of subnet provider IDs from the map above
   801  	// indexed by the space ID that the subnets reside in.
   802  	SpaceSubnets map[string][]string `json:"space-subnets"`
   803  }
   804  
   805  // ProvisioningInfo holds machine provisioning info.
   806  type ProvisioningInfo struct {
   807  	Constraints       constraints.Value        `json:"constraints"`
   808  	Base              Base                     `json:"base"`
   809  	Placement         string                   `json:"placement"`
   810  	Jobs              []model.MachineJob       `json:"jobs"`
   811  	RootDisk          *VolumeParams            `json:"root-disk,omitempty"`
   812  	Volumes           []VolumeParams           `json:"volumes,omitempty"`
   813  	VolumeAttachments []VolumeAttachmentParams `json:"volume-attachments,omitempty"`
   814  	Tags              map[string]string        `json:"tags,omitempty"`
   815  	ImageMetadata     []CloudImageMetadata     `json:"image-metadata,omitempty"`
   816  	EndpointBindings  map[string]string        `json:"endpoint-bindings,omitempty"`
   817  	ControllerConfig  map[string]interface{}   `json:"controller-config,omitempty"`
   818  	CloudInitUserData map[string]interface{}   `json:"cloudinit-userdata,omitempty"`
   819  	CharmLXDProfiles  []string                 `json:"charm-lxd-profiles,omitempty"`
   820  
   821  	ProvisioningNetworkTopology
   822  }
   823  
   824  // ProvisioningInfoResult holds machine provisioning info or an error.
   825  type ProvisioningInfoResult struct {
   826  	Result *ProvisioningInfo `json:"result"`
   827  	Error  *Error            `json:"error,omitempty"`
   828  }
   829  
   830  // ProvisioningInfoResults holds multiple machine provisioning info results.
   831  type ProvisioningInfoResults struct {
   832  	Results []ProvisioningInfoResult `json:"results"`
   833  }
   834  
   835  // Metric holds a single metric.
   836  type Metric struct {
   837  	Key    string            `json:"key"`
   838  	Value  string            `json:"value"`
   839  	Time   time.Time         `json:"time"`
   840  	Labels map[string]string `json:"labels,omitempty"`
   841  }
   842  
   843  // MetricsParam contains the metrics for a single unit.
   844  type MetricsParam struct {
   845  	Tag     string   `json:"tag"`
   846  	Metrics []Metric `json:"metrics"`
   847  }
   848  
   849  // MetricsParams contains the metrics for multiple units.
   850  type MetricsParams struct {
   851  	Metrics []MetricsParam `json:"metrics"`
   852  }
   853  
   854  // MetricBatch is a list of metrics with metadata.
   855  type MetricBatch struct {
   856  	UUID     string    `json:"uuid"`
   857  	CharmURL string    `json:"charm-url"`
   858  	Created  time.Time `json:"created"`
   859  	Metrics  []Metric  `json:"metrics"`
   860  }
   861  
   862  // MetricBatchParam contains a single metric batch.
   863  type MetricBatchParam struct {
   864  	Tag   string      `json:"tag"`
   865  	Batch MetricBatch `json:"batch"`
   866  }
   867  
   868  // MetricBatchParams contains multiple metric batches.
   869  type MetricBatchParams struct {
   870  	Batches []MetricBatchParam `json:"batches"`
   871  }
   872  
   873  // MeterStatusResult holds unit meter status or error.
   874  type MeterStatusResult struct {
   875  	Code  string `json:"code"`
   876  	Info  string `json:"info"`
   877  	Error *Error `json:"error,omitempty"`
   878  }
   879  
   880  // MeterStatusResults holds meter status results for multiple units.
   881  type MeterStatusResults struct {
   882  	Results []MeterStatusResult `json:"results"`
   883  }
   884  
   885  // SingularClaim represents a request for exclusive administrative access
   886  // to an entity (model or controller) on the part of the claimant.
   887  type SingularClaim struct {
   888  	EntityTag   string        `json:"entity-tag"`
   889  	ClaimantTag string        `json:"claimant-tag"`
   890  	Duration    time.Duration `json:"duration"`
   891  }
   892  
   893  // SingularClaims holds any number of SingularClaim~s.
   894  type SingularClaims struct {
   895  	Claims []SingularClaim `json:"claims"`
   896  }
   897  
   898  // LogMessage is a structured logging entry.
   899  type LogMessage struct {
   900  	Entity    string    `json:"tag"`
   901  	Timestamp time.Time `json:"ts"`
   902  	Severity  string    `json:"sev"`
   903  	Module    string    `json:"mod"`
   904  	Location  string    `json:"loc"`
   905  	Message   string    `json:"msg"`
   906  	Labels    []string  `json:"lab"`
   907  }
   908  
   909  // ResourceUploadResult is used to return some details about an
   910  // uploaded resource.
   911  type ResourceUploadResult struct {
   912  	// Error will contain details about a failed upload attempt.
   913  	Error *Error `json:"error,omitempty"`
   914  
   915  	// ID uniquely identifies a resource-application pair within the model.
   916  	ID string `json:"id"`
   917  
   918  	// Timestamp indicates when the resource was added to the model.
   919  	Timestamp time.Time `json:"timestamp"`
   920  }
   921  
   922  // UnitRefreshResult is used to return the latest values for attributes
   923  // on a unit.
   924  type UnitRefreshResult struct {
   925  	Life       life.Value
   926  	Resolved   ResolvedMode
   927  	Error      *Error
   928  	ProviderID string `json:"provider-id,omitempty"`
   929  }
   930  
   931  // UnitRefreshResults holds the results for any API call which ends
   932  // up returning a list of UnitRefreshResult.
   933  type UnitRefreshResults struct {
   934  	Results []UnitRefreshResult
   935  }
   936  
   937  // EntityString holds an entity tag and a string value.
   938  type EntityString struct {
   939  	Tag   string `json:"tag"`
   940  	Value string `json:"value"`
   941  }
   942  
   943  // SetPodSpecParams holds the arguments for setting the pod
   944  // spec for a set of applications.
   945  // TODO(juju3) - remove
   946  type SetPodSpecParams struct {
   947  	Specs []EntityString `json:"specs"`
   948  }
   949  
   950  // PodSpec holds an entity tag and optional podspec value.
   951  type PodSpec struct {
   952  	Tag  string  `json:"tag"`
   953  	Spec *string `json:"spec,omitempty"`
   954  }
   955  
   956  // GoalStateResults holds the results of GoalStates API call
   957  type GoalStateResults struct {
   958  	Results []GoalStateResult `json:"results"`
   959  }
   960  
   961  // GoalStateResult the result of GoalStates per entity.
   962  type GoalStateResult struct {
   963  	Result *GoalState `json:"result"`
   964  	Error  *Error     `json:"error"`
   965  }
   966  
   967  // GoalStateStatus goal-state at unit level
   968  type GoalStateStatus struct {
   969  	Status string     `json:"status"`
   970  	Since  *time.Time `json:"since"`
   971  }
   972  
   973  // UnitsGoalState collection of GoalStatesStatus with unit name
   974  type UnitsGoalState map[string]GoalStateStatus
   975  
   976  // GoalState goal-state at application level, stores Units and Units-Relations
   977  type GoalState struct {
   978  	Units     UnitsGoalState            `json:"units"`
   979  	Relations map[string]UnitsGoalState `json:"relations"`
   980  }
   981  
   982  // ContainerTypeResult holds the result of a machine's ContainerType.
   983  type ContainerTypeResult struct {
   984  	Type  instance.ContainerType `json:"container-type"`
   985  	Error *Error                 `json:"error"`
   986  }