github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/apiserver/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/instance"
    13  	"github.com/juju/juju/state/multiwatcher"
    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  // StringsResults holds the bulk operation result of an API call
    61  // that returns a slice of strings or an error.
    62  type StringsResults struct {
    63  	Results []StringsResult
    64  }
    65  
    66  // StringResult holds a string or an error.
    67  type StringResult struct {
    68  	Error  *Error
    69  	Result string
    70  }
    71  
    72  // StringResults holds the bulk operation result of an API call
    73  // that returns a string or an error.
    74  type StringResults struct {
    75  	Results []StringResult
    76  }
    77  
    78  // EnvironmentResult holds the result of an API call returning a name and UUID
    79  // for an environment.
    80  type EnvironmentResult struct {
    81  	Error *Error
    82  	Name  string
    83  	UUID  string
    84  }
    85  
    86  // EnvironmentSkeletonConfigArgs wraps the args for environmentmanager.SkeletonConfig.
    87  type EnvironmentSkeletonConfigArgs struct {
    88  	Provider string
    89  	Region   string
    90  }
    91  
    92  // EnvironmentCreateArgs holds the arguments that are necessary to create
    93  // and environment.
    94  type EnvironmentCreateArgs struct {
    95  	// OwnerTag represents the user that will own the new environment.
    96  	// The OwnerTag must be a valid user tag.  If the user tag represents
    97  	// a local user, that user must exist.
    98  	OwnerTag string
    99  
   100  	// Account holds the provider specific account details necessary to
   101  	// interact with the provider to create, list and destroy machines.
   102  	Account map[string]interface{}
   103  
   104  	// Config defines the environment config, which includes the name of the
   105  	// environment.  An environment UUID is allocated by the API server during
   106  	// the creation of the environment.
   107  	Config map[string]interface{}
   108  }
   109  
   110  // Environment holds the result of an API call returning a name and UUID
   111  // for an environment and the tag of the server in which it is running.
   112  type Environment struct {
   113  	Name       string
   114  	UUID       string
   115  	OwnerTag   string
   116  	ServerUUID string
   117  }
   118  
   119  // UserEnvironment holds information about an environment and the last
   120  // time the environment was accessed for a particular user.
   121  type UserEnvironment struct {
   122  	Environment
   123  	LastConnection *time.Time
   124  }
   125  
   126  // UserEnvironmentList holds information about a list of environments
   127  // for a particular user.
   128  type UserEnvironmentList struct {
   129  	UserEnvironments []UserEnvironment
   130  }
   131  
   132  // ResolvedModeResult holds a resolved mode or an error.
   133  type ResolvedModeResult struct {
   134  	Error *Error
   135  	Mode  ResolvedMode
   136  }
   137  
   138  // ResolvedModeResults holds the bulk operation result of an API call
   139  // that returns a resolved mode or an error.
   140  type ResolvedModeResults struct {
   141  	Results []ResolvedModeResult
   142  }
   143  
   144  // StringBoolResult holds the result of an API call that returns a
   145  // string and a boolean.
   146  type StringBoolResult struct {
   147  	Error  *Error
   148  	Result string
   149  	Ok     bool
   150  }
   151  
   152  // StringBoolResults holds multiple results with a string and a bool
   153  // each.
   154  type StringBoolResults struct {
   155  	Results []StringBoolResult
   156  }
   157  
   158  // BoolResult holds the result of an API call that returns a
   159  // a boolean or an error.
   160  type BoolResult struct {
   161  	Error  *Error
   162  	Result bool
   163  }
   164  
   165  // BoolResults holds multiple results with BoolResult each.
   166  type BoolResults struct {
   167  	Results []BoolResult
   168  }
   169  
   170  // Settings holds relation settings names and values.
   171  type Settings map[string]string
   172  
   173  // SettingsResult holds a relation settings map or an error.
   174  type SettingsResult struct {
   175  	Error    *Error
   176  	Settings Settings
   177  }
   178  
   179  // SettingsResults holds the result of an API calls that
   180  // returns settings for multiple relations.
   181  type SettingsResults struct {
   182  	Results []SettingsResult
   183  }
   184  
   185  // ConfigSettings holds unit, service or cham configuration settings
   186  // with string keys and arbitrary values.
   187  type ConfigSettings map[string]interface{}
   188  
   189  // ConfigSettingsResult holds a configuration map or an error.
   190  type ConfigSettingsResult struct {
   191  	Error    *Error
   192  	Settings ConfigSettings
   193  }
   194  
   195  // ConfigSettingsResults holds multiple configuration maps or errors.
   196  type ConfigSettingsResults struct {
   197  	Results []ConfigSettingsResult
   198  }
   199  
   200  // EnvironConfig holds an environment configuration.
   201  type EnvironConfig map[string]interface{}
   202  
   203  // EnvironConfigResult holds environment configuration or an error.
   204  type EnvironConfigResult struct {
   205  	Config EnvironConfig
   206  }
   207  
   208  // RelationUnit holds a relation and a unit tag.
   209  type RelationUnit struct {
   210  	Relation string
   211  	Unit     string
   212  }
   213  
   214  // RelationUnits holds the parameters for API calls expecting a pair
   215  // of relation and unit tags.
   216  type RelationUnits struct {
   217  	RelationUnits []RelationUnit
   218  }
   219  
   220  // RelationIds holds multiple relation ids.
   221  type RelationIds struct {
   222  	RelationIds []int
   223  }
   224  
   225  // RelationUnitPair holds a relation tag, a local and remote unit tags.
   226  type RelationUnitPair struct {
   227  	Relation   string
   228  	LocalUnit  string
   229  	RemoteUnit string
   230  }
   231  
   232  // RelationUnitPairs holds the parameters for API calls expecting
   233  // multiple sets of a relation tag, a local and remote unit tags.
   234  type RelationUnitPairs struct {
   235  	RelationUnitPairs []RelationUnitPair
   236  }
   237  
   238  // RelationUnitSettings holds a relation tag, a unit tag and local
   239  // unit settings.
   240  type RelationUnitSettings struct {
   241  	Relation string
   242  	Unit     string
   243  	Settings Settings
   244  }
   245  
   246  // RelationUnitsSettings holds the arguments for making a EnterScope
   247  // or WriteSettings API calls.
   248  type RelationUnitsSettings struct {
   249  	RelationUnits []RelationUnitSettings
   250  }
   251  
   252  // RelationResult returns information about a single relation,
   253  // or an error.
   254  type RelationResult struct {
   255  	Error    *Error
   256  	Life     Life
   257  	Id       int
   258  	Key      string
   259  	Endpoint multiwatcher.Endpoint
   260  }
   261  
   262  // RelationResults holds the result of an API call that returns
   263  // information about multiple relations.
   264  type RelationResults struct {
   265  	Results []RelationResult
   266  }
   267  
   268  // EntityCharmURL holds an entity's tag and a charm URL.
   269  type EntityCharmURL struct {
   270  	Tag      string
   271  	CharmURL string
   272  }
   273  
   274  // EntitiesCharmURL holds the parameters for making a SetCharmURL API
   275  // call.
   276  type EntitiesCharmURL struct {
   277  	Entities []EntityCharmURL
   278  }
   279  
   280  // BytesResult holds the result of an API call that returns a slice
   281  // of bytes.
   282  type BytesResult struct {
   283  	Result []byte
   284  }
   285  
   286  // LifeResult holds the life status of a single entity, or an error
   287  // indicating why it is not available.
   288  type LifeResult struct {
   289  	Life  Life
   290  	Error *Error
   291  }
   292  
   293  // LifeResults holds the life or error status of multiple entities.
   294  type LifeResults struct {
   295  	Results []LifeResult
   296  }
   297  
   298  // MachineSetProvisioned holds a machine tag, provider-specific
   299  // instance id, a nonce, or an error.
   300  //
   301  // NOTE: This is deprecated since 1.19.0 and not used by the
   302  // provisioner, it's just retained for backwards-compatibility and
   303  // should be removed.
   304  type MachineSetProvisioned struct {
   305  	Tag             string
   306  	InstanceId      instance.Id
   307  	Nonce           string
   308  	Characteristics *instance.HardwareCharacteristics
   309  }
   310  
   311  // SetProvisioned holds the parameters for making a SetProvisioned
   312  // call for a machine.
   313  //
   314  // NOTE: This is deprecated since 1.19.0 and not used by the
   315  // provisioner, it's just retained for backwards-compatibility and
   316  // should be removed.
   317  type SetProvisioned struct {
   318  	Machines []MachineSetProvisioned
   319  }
   320  
   321  // InstanceInfo holds a machine tag, provider-specific instance id, a
   322  // nonce, a list of networks and interfaces to set up.
   323  type InstanceInfo struct {
   324  	Tag             string
   325  	InstanceId      instance.Id
   326  	Nonce           string
   327  	Characteristics *instance.HardwareCharacteristics
   328  	Networks        []Network
   329  	Interfaces      []NetworkInterface
   330  	Volumes         []Volume
   331  	// VolumeAttachments is a mapping from volume tag to
   332  	// volume attachment info.
   333  	VolumeAttachments map[string]VolumeAttachmentInfo
   334  }
   335  
   336  // InstancesInfo holds the parameters for making a SetInstanceInfo
   337  // call for multiple machines.
   338  type InstancesInfo struct {
   339  	Machines []InstanceInfo
   340  }
   341  
   342  // EntityStatus holds the status of an entity.
   343  type EntityStatus struct {
   344  	Status Status
   345  	Info   string
   346  	Data   map[string]interface{}
   347  	Since  *time.Time
   348  }
   349  
   350  // EntityStatus holds parameters for setting the status of a single entity.
   351  type EntityStatusArgs struct {
   352  	Tag    string
   353  	Status Status
   354  	Info   string
   355  	Data   map[string]interface{}
   356  }
   357  
   358  // SetStatus holds the parameters for making a SetStatus/UpdateStatus call.
   359  type SetStatus struct {
   360  	Entities []EntityStatusArgs
   361  }
   362  
   363  // InstanceStatus holds an entity tag and instance status.
   364  type InstanceStatus struct {
   365  	Tag    string
   366  	Status string
   367  }
   368  
   369  // SetInstancesStatus holds parameters for making a
   370  // SetInstanceStatus() call.
   371  type SetInstancesStatus struct {
   372  	Entities []InstanceStatus
   373  }
   374  
   375  // ConstraintsResult holds machine constraints or an error.
   376  type ConstraintsResult struct {
   377  	Error       *Error
   378  	Constraints constraints.Value
   379  }
   380  
   381  // ConstraintsResults holds multiple constraints results.
   382  type ConstraintsResults struct {
   383  	Results []ConstraintsResult
   384  }
   385  
   386  // AgentGetEntitiesResults holds the results of a
   387  // agent.API.GetEntities call.
   388  type AgentGetEntitiesResults struct {
   389  	Entities []AgentGetEntitiesResult
   390  }
   391  
   392  // AgentGetEntitiesResult holds the results of a
   393  // machineagent.API.GetEntities call for a single entity.
   394  type AgentGetEntitiesResult struct {
   395  	Life          Life
   396  	Jobs          []multiwatcher.MachineJob
   397  	ContainerType instance.ContainerType
   398  	Error         *Error
   399  }
   400  
   401  // VersionResult holds the version and possibly error for a given
   402  // DesiredVersion() API call.
   403  type VersionResult struct {
   404  	Version *version.Number
   405  	Error   *Error
   406  }
   407  
   408  // VersionResults is a list of versions for the requested entities.
   409  type VersionResults struct {
   410  	Results []VersionResult
   411  }
   412  
   413  // ToolsResult holds the tools and possibly error for a given
   414  // Tools() API call.
   415  type ToolsResult struct {
   416  	Tools                          *tools.Tools
   417  	DisableSSLHostnameVerification bool
   418  	Error                          *Error
   419  }
   420  
   421  // ToolsResults is a list of tools for various requested agents.
   422  type ToolsResults struct {
   423  	Results []ToolsResult
   424  }
   425  
   426  // Version holds a specific binary version.
   427  type Version struct {
   428  	Version version.Binary
   429  }
   430  
   431  // EntityVersion specifies the tools version to be set for an entity
   432  // with the given tag.
   433  // version.Binary directly.
   434  type EntityVersion struct {
   435  	Tag   string
   436  	Tools *Version
   437  }
   438  
   439  // EntitiesVersion specifies what tools are being run for
   440  // multiple entities.
   441  type EntitiesVersion struct {
   442  	AgentTools []EntityVersion
   443  }
   444  
   445  // NotifyWatchResult holds a NotifyWatcher id and an error (if any).
   446  type NotifyWatchResult struct {
   447  	NotifyWatcherId string
   448  	Error           *Error
   449  }
   450  
   451  // NotifyWatchResults holds the results for any API call which ends up
   452  // returning a list of NotifyWatchers
   453  type NotifyWatchResults struct {
   454  	Results []NotifyWatchResult
   455  }
   456  
   457  // StringsWatchResult holds a StringsWatcher id, changes and an error
   458  // (if any).
   459  type StringsWatchResult struct {
   460  	StringsWatcherId string
   461  	Changes          []string
   462  	Error            *Error
   463  }
   464  
   465  // StringsWatchResults holds the results for any API call which ends up
   466  // returning a list of StringsWatchers.
   467  type StringsWatchResults struct {
   468  	Results []StringsWatchResult
   469  }
   470  
   471  // EntityWatchResult holds a EntityWatcher id, changes and an error
   472  // (if any).
   473  type EntityWatchResult struct {
   474  	EntityWatcherId string   `json:"EntityWatcherId"`
   475  	Changes         []string `json:"Changes"`
   476  	Error           *Error   `json:"Error"`
   477  }
   478  
   479  // EntityWatchResults holds the results for any API call which ends up
   480  // returning a list of EntityWatchers.
   481  type EntityWatchResults struct {
   482  	Results []EntityWatchResult
   483  }
   484  
   485  // RelationUnitsWatchResult holds a RelationUnitsWatcher id, changes
   486  // and an error (if any).
   487  type RelationUnitsWatchResult struct {
   488  	RelationUnitsWatcherId string
   489  	Changes                multiwatcher.RelationUnitsChange
   490  	Error                  *Error
   491  }
   492  
   493  // RelationUnitsWatchResults holds the results for any API call which ends up
   494  // returning a list of RelationUnitsWatchers.
   495  type RelationUnitsWatchResults struct {
   496  	Results []RelationUnitsWatchResult
   497  }
   498  
   499  // MachineStorageIdsWatchResult holds a MachineStorageIdsWatcher id,
   500  // changes and an error (if any).
   501  type MachineStorageIdsWatchResult struct {
   502  	MachineStorageIdsWatcherId string
   503  	Changes                    []MachineStorageId
   504  	Error                      *Error
   505  }
   506  
   507  // MachineStorageIdsWatchResults holds the results for any API call which ends
   508  // up returning a list of MachineStorageIdsWatchers.
   509  type MachineStorageIdsWatchResults struct {
   510  	Results []MachineStorageIdsWatchResult
   511  }
   512  
   513  // CharmsResponse is the server response to charm upload or GET requests.
   514  type CharmsResponse struct {
   515  	Error    string   `json:",omitempty"`
   516  	CharmURL string   `json:",omitempty"`
   517  	Files    []string `json:",omitempty"`
   518  }
   519  
   520  // RunParams is used to provide the parameters to the Run method.
   521  // Commands and Timeout are expected to have values, and one or more
   522  // values should be in the Machines, Services, or Units slices.
   523  type RunParams struct {
   524  	Commands string
   525  	Timeout  time.Duration
   526  	Machines []string
   527  	Services []string
   528  	Units    []string
   529  }
   530  
   531  // RunResult contains the result from an individual run call on a machine.
   532  // UnitId is populated if the command was run inside the unit context.
   533  type RunResult struct {
   534  	exec.ExecResponse
   535  	MachineId string
   536  	UnitId    string
   537  	Error     string
   538  }
   539  
   540  // RunResults is used to return the slice of results.  API server side calls
   541  // need to return single structure values.
   542  type RunResults struct {
   543  	Results []RunResult
   544  }
   545  
   546  // AgentVersionResult is used to return the current version number of the
   547  // agent running the API server.
   548  type AgentVersionResult struct {
   549  	Version version.Number
   550  }
   551  
   552  // ProvisioningInfo holds machine provisioning info.
   553  type ProvisioningInfo struct {
   554  	Constraints    constraints.Value
   555  	Series         string
   556  	Placement      string
   557  	Networks       []string
   558  	Jobs           []multiwatcher.MachineJob
   559  	Volumes        []VolumeParams
   560  	Tags           map[string]string
   561  	SubnetsToZones map[string][]string
   562  }
   563  
   564  // ProvisioningInfoResult holds machine provisioning info or an error.
   565  type ProvisioningInfoResult struct {
   566  	Error  *Error
   567  	Result *ProvisioningInfo
   568  }
   569  
   570  // ProvisioningInfoResults holds multiple machine provisioning info results.
   571  type ProvisioningInfoResults struct {
   572  	Results []ProvisioningInfoResult
   573  }
   574  
   575  // Metric holds a single metric.
   576  type Metric struct {
   577  	Key   string
   578  	Value string
   579  	Time  time.Time
   580  }
   581  
   582  // MetricsParam contains the metrics for a single unit.
   583  type MetricsParam struct {
   584  	Tag     string
   585  	Metrics []Metric
   586  }
   587  
   588  // MetricsParams contains the metrics for multiple units.
   589  type MetricsParams struct {
   590  	Metrics []MetricsParam
   591  }
   592  
   593  // MetricBatch is a list of metrics with metadata.
   594  type MetricBatch struct {
   595  	UUID     string
   596  	CharmURL string
   597  	Created  time.Time
   598  	Metrics  []Metric
   599  }
   600  
   601  // MetricBatchParam contains a single metric batch.
   602  type MetricBatchParam struct {
   603  	Tag   string
   604  	Batch MetricBatch
   605  }
   606  
   607  // MetricBatchParams contains multiple metric batches.
   608  type MetricBatchParams struct {
   609  	Batches []MetricBatchParam
   610  }
   611  
   612  // MeterStatusResult holds unit meter status or error.
   613  type MeterStatusResult struct {
   614  	Code  string
   615  	Info  string
   616  	Error *Error
   617  }
   618  
   619  // MeterStatusResults holds meter status results for multiple units.
   620  type MeterStatusResults struct {
   621  	Results []MeterStatusResult
   622  }