github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/state/api/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/utils/exec"
    10  
    11  	"github.com/juju/juju/constraints"
    12  	"github.com/juju/juju/environs/network"
    13  	"github.com/juju/juju/instance"
    14  	"github.com/juju/juju/tools"
    15  	"github.com/juju/juju/version"
    16  )
    17  
    18  // MachineContainersParams holds the arguments for making a SetSupportedContainers
    19  // API call.
    20  type MachineContainersParams struct {
    21  	Params []MachineContainers
    22  }
    23  
    24  // MachineContainers holds the arguments for making an SetSupportedContainers call
    25  // on a given machine.
    26  type MachineContainers struct {
    27  	MachineTag     string
    28  	ContainerTypes []instance.ContainerType
    29  }
    30  
    31  // WatchContainer identifies a single container type within a machine.
    32  type WatchContainer struct {
    33  	MachineTag    string
    34  	ContainerType string
    35  }
    36  
    37  // WatchContainers holds the arguments for making a WatchContainers
    38  // API call.
    39  type WatchContainers struct {
    40  	Params []WatchContainer
    41  }
    42  
    43  // CharmURL identifies a single charm URL.
    44  type CharmURL struct {
    45  	URL string
    46  }
    47  
    48  // CharmURLs identifies multiple charm URLs.
    49  type CharmURLs struct {
    50  	URLs []CharmURL
    51  }
    52  
    53  // StringsResult holds the result of an API call that returns a slice
    54  // of strings or an error.
    55  type StringsResult struct {
    56  	Error  *Error
    57  	Result []string
    58  }
    59  
    60  // PortsResults holds the bulk operation result of an API call
    61  // that returns a slice of instance.Port.
    62  type PortsResults struct {
    63  	Results []PortsResult
    64  }
    65  
    66  // PortsResult holds the result of an API call that returns a slice
    67  // of instance.Port or an error.
    68  type PortsResult struct {
    69  	Error *Error
    70  	Ports []instance.Port
    71  }
    72  
    73  // StringsResults holds the bulk operation result of an API call
    74  // that returns a slice of strings or an error.
    75  type StringsResults struct {
    76  	Results []StringsResult
    77  }
    78  
    79  // StringResult holds a string or an error.
    80  type StringResult struct {
    81  	Error  *Error
    82  	Result string
    83  }
    84  
    85  // StringResults holds the bulk operation result of an API call
    86  // that returns a string or an error.
    87  type StringResults struct {
    88  	Results []StringResult
    89  }
    90  
    91  // CharmArchiveURLResult holds a charm archive (bundle) URL, a
    92  // DisableSSLHostnameVerification flag or an error.
    93  type CharmArchiveURLResult struct {
    94  	Error                          *Error
    95  	Result                         string
    96  	DisableSSLHostnameVerification bool
    97  }
    98  
    99  // CharmArchiveURLResults holds the bulk operation result of an API
   100  // call that returns a charm archive (bundle) URL, a
   101  // DisableSSLHostnameVerification flag or an error.
   102  type CharmArchiveURLResults struct {
   103  	Results []CharmArchiveURLResult
   104  }
   105  
   106  // EnvironmentResult holds the result of an API call returning a name and UUID
   107  // for an environment.
   108  type EnvironmentResult struct {
   109  	Error *Error
   110  	Name  string
   111  	UUID  string
   112  }
   113  
   114  // ResolvedModeResult holds a resolved mode or an error.
   115  type ResolvedModeResult struct {
   116  	Error *Error
   117  	Mode  ResolvedMode
   118  }
   119  
   120  // ResolvedModeResults holds the bulk operation result of an API call
   121  // that returns a resolved mode or an error.
   122  type ResolvedModeResults struct {
   123  	Results []ResolvedModeResult
   124  }
   125  
   126  // StringBoolResult holds the result of an API call that returns a
   127  // string and a boolean.
   128  type StringBoolResult struct {
   129  	Error  *Error
   130  	Result string
   131  	Ok     bool
   132  }
   133  
   134  // StringBoolResults holds multiple results with a string and a bool
   135  // each.
   136  type StringBoolResults struct {
   137  	Results []StringBoolResult
   138  }
   139  
   140  // BoolResult holds the result of an API call that returns a
   141  // a boolean or an error.
   142  type BoolResult struct {
   143  	Error  *Error
   144  	Result bool
   145  }
   146  
   147  // BoolResults holds multiple results with BoolResult each.
   148  type BoolResults struct {
   149  	Results []BoolResult
   150  }
   151  
   152  // RelationSettings holds relation settings names and values.
   153  type RelationSettings map[string]string
   154  
   155  // RelationSettingsResult holds a relation settings map or an error.
   156  type RelationSettingsResult struct {
   157  	Error    *Error
   158  	Settings RelationSettings
   159  }
   160  
   161  // RelationSettingsResults holds the result of an API calls that
   162  // returns settings for multiple relations.
   163  type RelationSettingsResults struct {
   164  	Results []RelationSettingsResult
   165  }
   166  
   167  // ConfigSettings holds unit, service or cham configuration settings
   168  // with string keys and arbitrary values.
   169  type ConfigSettings map[string]interface{}
   170  
   171  // ConfigSettingsResult holds a configuration map or an error.
   172  type ConfigSettingsResult struct {
   173  	Error    *Error
   174  	Settings ConfigSettings
   175  }
   176  
   177  // ConfigSettingsResults holds multiple configuration maps or errors.
   178  type ConfigSettingsResults struct {
   179  	Results []ConfigSettingsResult
   180  }
   181  
   182  // EnvironConfig holds an environment configuration.
   183  type EnvironConfig map[string]interface{}
   184  
   185  // EnvironConfigResult holds environment configuration or an error.
   186  type EnvironConfigResult struct {
   187  	Config EnvironConfig
   188  }
   189  
   190  // RelationUnit holds a relation and a unit tag.
   191  type RelationUnit struct {
   192  	Relation string
   193  	Unit     string
   194  }
   195  
   196  // RelationUnits holds the parameters for API calls expecting a pair
   197  // of relation and unit tags.
   198  type RelationUnits struct {
   199  	RelationUnits []RelationUnit
   200  }
   201  
   202  // RelationIds holds multiple relation ids.
   203  type RelationIds struct {
   204  	RelationIds []int
   205  }
   206  
   207  // RelationUnitPair holds a relation tag, a local and remote unit tags.
   208  type RelationUnitPair struct {
   209  	Relation   string
   210  	LocalUnit  string
   211  	RemoteUnit string
   212  }
   213  
   214  // RelationUnitPairs holds the parameters for API calls expecting
   215  // multiple sets of a relation tag, a local and remote unit tags.
   216  type RelationUnitPairs struct {
   217  	RelationUnitPairs []RelationUnitPair
   218  }
   219  
   220  // RelationUnitSettings holds a relation tag, a unit tag and local
   221  // unit settings.
   222  type RelationUnitSettings struct {
   223  	Relation string
   224  	Unit     string
   225  	Settings RelationSettings
   226  }
   227  
   228  // RelationUnitsSettings holds the arguments for making a EnterScope
   229  // or WriteSettings API calls.
   230  type RelationUnitsSettings struct {
   231  	RelationUnits []RelationUnitSettings
   232  }
   233  
   234  // RelationResult returns information about a single relation,
   235  // or an error.
   236  type RelationResult struct {
   237  	Error    *Error
   238  	Life     Life
   239  	Id       int
   240  	Key      string
   241  	Endpoint Endpoint
   242  }
   243  
   244  // RelationResults holds the result of an API call that returns
   245  // information about multiple relations.
   246  type RelationResults struct {
   247  	Results []RelationResult
   248  }
   249  
   250  // EntityPort holds an entity's tag, a protocol and a port.
   251  type EntityPort struct {
   252  	Tag      string
   253  	Protocol string
   254  	Port     int
   255  }
   256  
   257  // EntitiesPorts holds the parameters for making an OpenPort or
   258  // ClosePort on some entities.
   259  type EntitiesPorts struct {
   260  	Entities []EntityPort
   261  }
   262  
   263  // EntityCharmURL holds an entity's tag and a charm URL.
   264  type EntityCharmURL struct {
   265  	Tag      string
   266  	CharmURL string
   267  }
   268  
   269  // EntitiesCharmURL holds the parameters for making a SetCharmURL API
   270  // call.
   271  type EntitiesCharmURL struct {
   272  	Entities []EntityCharmURL
   273  }
   274  
   275  // BytesResult holds the result of an API call that returns a slice
   276  // of bytes.
   277  type BytesResult struct {
   278  	Result []byte
   279  }
   280  
   281  // LifeResult holds the life status of a single entity, or an error
   282  // indicating why it is not available.
   283  type LifeResult struct {
   284  	Life  Life
   285  	Error *Error
   286  }
   287  
   288  // LifeResults holds the life or error status of multiple entities.
   289  type LifeResults struct {
   290  	Results []LifeResult
   291  }
   292  
   293  // MachineSetProvisioned holds a machine tag, provider-specific
   294  // instance id, a nonce, or an error.
   295  //
   296  // NOTE: This is deprecated since 1.19.0 and not used by the
   297  // provisioner, it's just retained for backwards-compatibility and
   298  // should be removed.
   299  type MachineSetProvisioned struct {
   300  	Tag             string
   301  	InstanceId      instance.Id
   302  	Nonce           string
   303  	Characteristics *instance.HardwareCharacteristics
   304  }
   305  
   306  // SetProvisioned holds the parameters for making a SetProvisioned
   307  // call for a machine.
   308  //
   309  // NOTE: This is deprecated since 1.19.0 and not used by the
   310  // provisioner, it's just retained for backwards-compatibility and
   311  // should be removed.
   312  type SetProvisioned struct {
   313  	Machines []MachineSetProvisioned
   314  }
   315  
   316  // Network describes a single network available on an instance.
   317  type Network struct {
   318  	// Tag is the network's tag.
   319  	Tag string
   320  
   321  	// ProviderId is the provider-specific network id.
   322  	ProviderId network.Id
   323  
   324  	// CIDR of the network, in "123.45.67.89/12" format.
   325  	CIDR string
   326  
   327  	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
   328  	// normal networks. It's defined by IEEE 802.1Q standard.
   329  	VLANTag int
   330  }
   331  
   332  // NetworkInterface describes a single network interface available on
   333  // an instance.
   334  type NetworkInterface struct {
   335  	// MACAddress is the network interface's hardware MAC address
   336  	// (e.g. "aa:bb:cc:dd:ee:ff").
   337  	MACAddress string
   338  
   339  	// InterfaceName is the OS-specific network device name (e.g.
   340  	// "eth1", even for for a VLAN eth1.42 virtual interface).
   341  	InterfaceName string
   342  
   343  	// NetworkTag is this interface's network tag.
   344  	NetworkTag string
   345  
   346  	// IsVirtual is true when the interface is a virtual device, as
   347  	// opposed to a physical device.
   348  	IsVirtual bool
   349  }
   350  
   351  // InstanceInfo holds a machine tag, provider-specific instance id, a
   352  // nonce, a list of networks and interfaces to set up.
   353  type InstanceInfo struct {
   354  	Tag             string
   355  	InstanceId      instance.Id
   356  	Nonce           string
   357  	Characteristics *instance.HardwareCharacteristics
   358  	Networks        []Network
   359  	Interfaces      []NetworkInterface
   360  }
   361  
   362  // InstancesInfo holds the parameters for making a SetInstanceInfo
   363  // call for multiple machines.
   364  type InstancesInfo struct {
   365  	Machines []InstanceInfo
   366  }
   367  
   368  // RequestedNetworkResult holds requested networks or an error.
   369  type RequestedNetworkResult struct {
   370  	Error    *Error
   371  	Networks []string
   372  }
   373  
   374  // RequestedNetworksResults holds multiple requested networks results.
   375  type RequestedNetworksResults struct {
   376  	Results []RequestedNetworkResult
   377  }
   378  
   379  // MachineNetworkInfoResult holds network info for a single machine.
   380  type MachineNetworkInfoResult struct {
   381  	Error *Error
   382  	Info  []network.Info
   383  }
   384  
   385  // MachineNetworkInfoResults holds network info for multiple machines.
   386  type MachineNetworkInfoResults struct {
   387  	Results []MachineNetworkInfoResult
   388  }
   389  
   390  // EntityStatus holds an entity tag, status and extra info.
   391  type EntityStatus struct {
   392  	Tag    string
   393  	Status Status
   394  	Info   string
   395  	Data   StatusData
   396  }
   397  
   398  // SetStatus holds the parameters for making a SetStatus/UpdateStatus call.
   399  type SetStatus struct {
   400  	Entities []EntityStatus
   401  }
   402  
   403  // StatusResult holds an entity status, extra information, or an
   404  // error.
   405  type StatusResult struct {
   406  	Error  *Error
   407  	Id     string
   408  	Life   Life
   409  	Status Status
   410  	Info   string
   411  	Data   StatusData
   412  }
   413  
   414  // StatusResults holds multiple status results.
   415  type StatusResults struct {
   416  	Results []StatusResult
   417  }
   418  
   419  // MachineAddresses holds an machine tag and addresses.
   420  type MachineAddresses struct {
   421  	Tag       string
   422  	Addresses []instance.Address
   423  }
   424  
   425  // SetMachinesAddresses holds the parameters for making a SetMachineAddresses call.
   426  type SetMachinesAddresses struct {
   427  	MachineAddresses []MachineAddresses
   428  }
   429  
   430  // ConstraintsResult holds machine constraints or an error.
   431  type ConstraintsResult struct {
   432  	Error       *Error
   433  	Constraints constraints.Value
   434  }
   435  
   436  // ConstraintsResults holds multiple constraints results.
   437  type ConstraintsResults struct {
   438  	Results []ConstraintsResult
   439  }
   440  
   441  // AgentGetEntitiesResults holds the results of a
   442  // agent.API.GetEntities call.
   443  type AgentGetEntitiesResults struct {
   444  	Entities []AgentGetEntitiesResult
   445  }
   446  
   447  // AgentGetEntitiesResult holds the results of a
   448  // machineagent.API.GetEntities call for a single entity.
   449  type AgentGetEntitiesResult struct {
   450  	Life          Life
   451  	Jobs          []MachineJob
   452  	ContainerType instance.ContainerType
   453  	Error         *Error
   454  }
   455  
   456  // VersionResult holds the version and possibly error for a given
   457  // DesiredVersion() API call.
   458  type VersionResult struct {
   459  	Version *version.Number
   460  	Error   *Error
   461  }
   462  
   463  // VersionResults is a list of versions for the requested entities.
   464  type VersionResults struct {
   465  	Results []VersionResult
   466  }
   467  
   468  // ToolsResult holds the tools and possibly error for a given
   469  // Tools() API call.
   470  type ToolsResult struct {
   471  	Tools                          *tools.Tools
   472  	DisableSSLHostnameVerification bool
   473  	Error                          *Error
   474  }
   475  
   476  // ToolsResults is a list of tools for various requested agents.
   477  type ToolsResults struct {
   478  	Results []ToolsResult
   479  }
   480  
   481  // FindToolsParams defines parameters for the FindTools method.
   482  type FindToolsParams struct {
   483  	MajorVersion int
   484  	MinorVersion int
   485  	Arch         string
   486  	Series       string
   487  }
   488  
   489  // FindToolsResults holds a list of tools from FindTools and any error.
   490  type FindToolsResults struct {
   491  	List  tools.List
   492  	Error *Error
   493  }
   494  
   495  // Version holds a specific binary version.
   496  type Version struct {
   497  	Version version.Binary
   498  }
   499  
   500  // EntityVersion specifies the tools version to be set for an entity
   501  // with the given tag.
   502  // version.Binary directly.
   503  type EntityVersion struct {
   504  	Tag   string
   505  	Tools *Version
   506  }
   507  
   508  // EntitiesVersion specifies what tools are being run for
   509  // multiple entities.
   510  type EntitiesVersion struct {
   511  	AgentTools []EntityVersion
   512  }
   513  
   514  // NotifyWatchResult holds a NotifyWatcher id and an error (if any).
   515  type NotifyWatchResult struct {
   516  	NotifyWatcherId string
   517  	Error           *Error
   518  }
   519  
   520  // NotifyWatchResults holds the results for any API call which ends up
   521  // returning a list of NotifyWatchers
   522  type NotifyWatchResults struct {
   523  	Results []NotifyWatchResult
   524  }
   525  
   526  // StringsWatchResult holds a StringsWatcher id, changes and an error
   527  // (if any).
   528  type StringsWatchResult struct {
   529  	StringsWatcherId string
   530  	Changes          []string
   531  	Error            *Error
   532  }
   533  
   534  // StringsWatchResults holds the results for any API call which ends up
   535  // returning a list of StringsWatchers.
   536  type StringsWatchResults struct {
   537  	Results []StringsWatchResult
   538  }
   539  
   540  // UnitSettings holds information about a service unit's settings
   541  // within a relation.
   542  type UnitSettings struct {
   543  	Version int64
   544  }
   545  
   546  // RelationUnitsChange holds notifications of units entering and leaving the
   547  // scope of a RelationUnit, and changes to the settings of those units known
   548  // to have entered.
   549  //
   550  // When remote units first enter scope and then when their settings
   551  // change, the changes will be noted in the Changed field, which holds
   552  // the unit settings for every such unit, indexed by the unit id.
   553  //
   554  // When remote units leave scope, their ids will be noted in the
   555  // Departed field, and no further events will be sent for those units.
   556  type RelationUnitsChange struct {
   557  	Changed  map[string]UnitSettings
   558  	Departed []string
   559  }
   560  
   561  // RelationUnitsWatchResult holds a RelationUnitsWatcher id, changes
   562  // and an error (if any).
   563  type RelationUnitsWatchResult struct {
   564  	RelationUnitsWatcherId string
   565  	Changes                RelationUnitsChange
   566  	Error                  *Error
   567  }
   568  
   569  // RelationUnitsWatchResults holds the results for any API call which ends up
   570  // returning a list of RelationUnitsWatchers.
   571  type RelationUnitsWatchResults struct {
   572  	Results []RelationUnitsWatchResult
   573  }
   574  
   575  // CharmsResponse is the server response to charm upload or GET requests.
   576  type CharmsResponse struct {
   577  	Error    string   `json:",omitempty"`
   578  	CharmURL string   `json:",omitempty"`
   579  	Files    []string `json:",omitempty"`
   580  }
   581  
   582  // RunParams is used to provide the parameters to the Run method.
   583  // Commands and Timeout are expected to have values, and one or more
   584  // values should be in the Machines, Services, or Units slices.
   585  type RunParams struct {
   586  	Commands string
   587  	Timeout  time.Duration
   588  	Machines []string
   589  	Services []string
   590  	Units    []string
   591  }
   592  
   593  // RunResult contains the result from an individual run call on a machine.
   594  // UnitId is populated if the command was run inside the unit context.
   595  type RunResult struct {
   596  	exec.ExecResponse
   597  	MachineId string
   598  	UnitId    string
   599  	Error     string
   600  }
   601  
   602  // RunResults is used to return the slice of results.  API server side calls
   603  // need to return single structure values.
   604  type RunResults struct {
   605  	Results []RunResult
   606  }
   607  
   608  // AgentVersionResult is used to return the current version number of the
   609  // agent running the API server.
   610  type AgentVersionResult struct {
   611  	Version version.Number
   612  }
   613  
   614  // ProvisioningInfo holds machine provisioning info.
   615  type ProvisioningInfo struct {
   616  	Constraints constraints.Value
   617  	Series      string
   618  	Placement   string
   619  	Networks    []string
   620  }
   621  
   622  // ProvisioningInfoResult holds machine provisioning info or an error.
   623  type ProvisioningInfoResult struct {
   624  	Error  *Error
   625  	Result *ProvisioningInfo
   626  }
   627  
   628  // ProvisioningInfoResults holds multiple machine provisioning info results.
   629  type ProvisioningInfoResults struct {
   630  	Results []ProvisioningInfoResult
   631  }