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