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