github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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 "github.com/juju/version" 11 12 "github.com/juju/juju/constraints" 13 "github.com/juju/juju/instance" 14 "github.com/juju/juju/state/multiwatcher" 15 "github.com/juju/juju/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 23 } 24 25 // MachineContainers holds the arguments for making an SetSupportedContainers call 26 // on a given machine. 27 type MachineContainers struct { 28 MachineTag string 29 ContainerTypes []instance.ContainerType 30 } 31 32 // WatchContainer identifies a single container type within a machine. 33 type WatchContainer struct { 34 MachineTag string 35 ContainerType string 36 } 37 38 // WatchContainers holds the arguments for making a WatchContainers 39 // API call. 40 type WatchContainers struct { 41 Params []WatchContainer 42 } 43 44 // CharmURL identifies a single charm URL. 45 type CharmURL struct { 46 URL string 47 } 48 49 // CharmURLs identifies multiple charm URLs. 50 type CharmURLs struct { 51 URLs []CharmURL 52 } 53 54 // StringsResult holds the result of an API call that returns a slice 55 // of strings or an error. 56 type StringsResult struct { 57 Error *Error 58 Result []string 59 } 60 61 // StringsResults holds the bulk operation result of an API call 62 // that returns a slice of strings or an error. 63 type StringsResults struct { 64 Results []StringsResult 65 } 66 67 // StringResult holds a string or an error. 68 type StringResult struct { 69 Error *Error 70 Result string 71 } 72 73 // StringResults holds the bulk operation result of an API call 74 // that returns a string or an error. 75 type StringResults struct { 76 Results []StringResult 77 } 78 79 // ModelResult holds the result of an API call returning a name and UUID 80 // for a model. 81 type ModelResult struct { 82 Error *Error 83 Name string 84 UUID string 85 } 86 87 // ModelSkeletonConfigArgs wraps the args for modelmanager.SkeletonConfig. 88 type ModelSkeletonConfigArgs struct { 89 Provider string 90 Region string 91 } 92 93 // ModelCreateArgs holds the arguments that are necessary to create 94 // a model. 95 type ModelCreateArgs struct { 96 // OwnerTag represents the user that will own the new model. 97 // The OwnerTag must be a valid user tag. If the user tag represents 98 // a local user, that user must exist. 99 OwnerTag string 100 101 // Account holds the provider specific account details necessary to 102 // interact with the provider to create, list and destroy machines. 103 Account map[string]interface{} 104 105 // Config defines the model config, which includes the name of the 106 // model. An model UUID is allocated by the API server during 107 // the creation of the model. 108 Config map[string]interface{} 109 } 110 111 // Model holds the result of an API call returning a name and UUID 112 // for a model and the tag of the server in which it is running. 113 type Model struct { 114 Name string `json:"Name"` 115 UUID string `json:"UUID"` 116 OwnerTag string `json:"OwnerTag"` 117 } 118 119 // UserModel holds information about a model and the last 120 // time the model was accessed for a particular user. 121 type UserModel struct { 122 Model 123 LastConnection *time.Time 124 } 125 126 // UserModelList holds information about a list of models 127 // for a particular user. 128 type UserModelList struct { 129 UserModels []UserModel 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 // IntResults holds multiple results with an int in each. 171 type IntResults struct { 172 // Results holds a list of results for calls that return an int or error. 173 Results []IntResult 174 } 175 176 // IntResult holds the result of an API call that returns a 177 // int or an error. 178 type IntResult struct { 179 // Error holds the error (if any) of this call. 180 Error *Error 181 // Result holds the integer result of the call (if Error is nil). 182 Result int 183 } 184 185 // Settings holds relation settings names and values. 186 type Settings map[string]string 187 188 // SettingsResult holds a relation settings map or an error. 189 type SettingsResult struct { 190 Error *Error 191 Settings Settings 192 } 193 194 // SettingsResults holds the result of an API calls that 195 // returns settings for multiple relations. 196 type SettingsResults struct { 197 Results []SettingsResult 198 } 199 200 // ConfigSettings holds unit, service or cham configuration settings 201 // with string keys and arbitrary values. 202 type ConfigSettings map[string]interface{} 203 204 // ConfigSettingsResult holds a configuration map or an error. 205 type ConfigSettingsResult struct { 206 Error *Error 207 Settings ConfigSettings 208 } 209 210 // ConfigSettingsResults holds multiple configuration maps or errors. 211 type ConfigSettingsResults struct { 212 Results []ConfigSettingsResult 213 } 214 215 // ModelConfig holds an model configuration. 216 type ModelConfig map[string]interface{} 217 218 // ModelConfigResult holds model configuration or an error. 219 type ModelConfigResult struct { 220 Config ModelConfig 221 } 222 223 // RelationUnit holds a relation and a unit tag. 224 type RelationUnit struct { 225 Relation string 226 Unit string 227 } 228 229 // RelationUnits holds the parameters for API calls expecting a pair 230 // of relation and unit tags. 231 type RelationUnits struct { 232 RelationUnits []RelationUnit 233 } 234 235 // RelationIds holds multiple relation ids. 236 type RelationIds struct { 237 RelationIds []int 238 } 239 240 // RelationUnitPair holds a relation tag, a local and remote unit tags. 241 type RelationUnitPair struct { 242 Relation string 243 LocalUnit string 244 RemoteUnit string 245 } 246 247 // RelationUnitPairs holds the parameters for API calls expecting 248 // multiple sets of a relation tag, a local and remote unit tags. 249 type RelationUnitPairs struct { 250 RelationUnitPairs []RelationUnitPair 251 } 252 253 // RelationUnitSettings holds a relation tag, a unit tag and local 254 // unit settings. 255 type RelationUnitSettings struct { 256 Relation string 257 Unit string 258 Settings Settings 259 } 260 261 // RelationUnitsSettings holds the arguments for making a EnterScope 262 // or WriteSettings API calls. 263 type RelationUnitsSettings struct { 264 RelationUnits []RelationUnitSettings 265 } 266 267 // RelationResult returns information about a single relation, 268 // or an error. 269 type RelationResult struct { 270 Error *Error 271 Life Life 272 Id int 273 Key string 274 Endpoint multiwatcher.Endpoint 275 } 276 277 // RelationResults holds the result of an API call that returns 278 // information about multiple relations. 279 type RelationResults struct { 280 Results []RelationResult 281 } 282 283 // EntityCharmURL holds an entity's tag and a charm URL. 284 type EntityCharmURL struct { 285 Tag string 286 CharmURL string 287 } 288 289 // EntitiesCharmURL holds the parameters for making a SetCharmURL API 290 // call. 291 type EntitiesCharmURL struct { 292 Entities []EntityCharmURL 293 } 294 295 // BytesResult holds the result of an API call that returns a slice 296 // of bytes. 297 type BytesResult struct { 298 Result []byte 299 } 300 301 // LifeResult holds the life status of a single entity, or an error 302 // indicating why it is not available. 303 type LifeResult struct { 304 Life Life 305 Error *Error 306 } 307 308 // LifeResults holds the life or error status of multiple entities. 309 type LifeResults struct { 310 Results []LifeResult 311 } 312 313 // InstanceInfo holds a machine tag, provider-specific instance id, a nonce, and 314 // network config. 315 type InstanceInfo struct { 316 Tag string 317 InstanceId instance.Id 318 Nonce string 319 Characteristics *instance.HardwareCharacteristics 320 Volumes []Volume 321 // VolumeAttachments is a mapping from volume tag to 322 // volume attachment info. 323 VolumeAttachments map[string]VolumeAttachmentInfo 324 325 NetworkConfig []NetworkConfig 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 the status of an entity. 335 type EntityStatus struct { 336 Status status.Status 337 Info string 338 Data map[string]interface{} 339 Since *time.Time 340 } 341 342 // EntityStatus holds parameters for setting the status of a single entity. 343 type EntityStatusArgs struct { 344 Tag string 345 Status status.Status 346 Info string 347 Data map[string]interface{} 348 } 349 350 // SetStatus holds the parameters for making a SetStatus/UpdateStatus call. 351 type SetStatus struct { 352 Entities []EntityStatusArgs 353 } 354 355 // ConstraintsResult holds machine constraints or an error. 356 type ConstraintsResult struct { 357 Error *Error 358 Constraints constraints.Value 359 } 360 361 // ConstraintsResults holds multiple constraints results. 362 type ConstraintsResults struct { 363 Results []ConstraintsResult 364 } 365 366 // AgentGetEntitiesResults holds the results of a 367 // agent.API.GetEntities call. 368 type AgentGetEntitiesResults struct { 369 Entities []AgentGetEntitiesResult 370 } 371 372 // AgentGetEntitiesResult holds the results of a 373 // machineagent.API.GetEntities call for a single entity. 374 type AgentGetEntitiesResult struct { 375 Life Life 376 Jobs []multiwatcher.MachineJob 377 ContainerType instance.ContainerType 378 Error *Error 379 } 380 381 // VersionResult holds the version and possibly error for a given 382 // DesiredVersion() API call. 383 type VersionResult struct { 384 Version *version.Number 385 Error *Error 386 } 387 388 // VersionResults is a list of versions for the requested entities. 389 type VersionResults struct { 390 Results []VersionResult 391 } 392 393 // ToolsResult holds the tools and possibly error for a given 394 // Tools() API call. 395 type ToolsResult struct { 396 ToolsList tools.List 397 DisableSSLHostnameVerification bool 398 Error *Error 399 } 400 401 // ToolsResults is a list of tools for various requested agents. 402 type ToolsResults struct { 403 Results []ToolsResult 404 } 405 406 // Version holds a specific binary version. 407 type Version struct { 408 Version version.Binary 409 } 410 411 // EntityVersion specifies the tools version to be set for an entity 412 // with the given tag. 413 // version.Binary directly. 414 type EntityVersion struct { 415 Tag string 416 Tools *Version 417 } 418 419 // EntitiesVersion specifies what tools are being run for 420 // multiple entities. 421 type EntitiesVersion struct { 422 AgentTools []EntityVersion 423 } 424 425 // NotifyWatchResult holds a NotifyWatcher id and an error (if any). 426 type NotifyWatchResult struct { 427 NotifyWatcherId string 428 Error *Error 429 } 430 431 // NotifyWatchResults holds the results for any API call which ends up 432 // returning a list of NotifyWatchers 433 type NotifyWatchResults struct { 434 Results []NotifyWatchResult 435 } 436 437 // StringsWatchResult holds a StringsWatcher id, changes and an error 438 // (if any). 439 type StringsWatchResult struct { 440 StringsWatcherId string 441 Changes []string 442 Error *Error 443 } 444 445 // StringsWatchResults holds the results for any API call which ends up 446 // returning a list of StringsWatchers. 447 type StringsWatchResults struct { 448 Results []StringsWatchResult 449 } 450 451 // EntitiesWatchResult holds a EntitiesWatcher id, changes and an error 452 // (if any). 453 type EntitiesWatchResult struct { 454 // Note legacy serialization tag. 455 EntitiesWatcherId string `json:"EntityWatcherId"` 456 Changes []string `json:"Changes"` 457 Error *Error `json:"Error"` 458 } 459 460 // EntitiesWatchResults holds the results for any API call which ends up 461 // returning a list of EntitiesWatchers. 462 type EntitiesWatchResults struct { 463 Results []EntitiesWatchResult `json:"Results"` 464 } 465 466 // UnitSettings specifies the version of some unit's settings in some relation. 467 type UnitSettings struct { 468 Version int64 `json:"Version"` 469 } 470 471 // RelationUnitsChange describes the membership and settings of; or changes to; 472 // some relation scope. 473 type RelationUnitsChange struct { 474 475 // Changed holds a set of units that are known to be in scope, and the 476 // latest known settings version for each. 477 Changed map[string]UnitSettings `json:"Changed"` 478 479 // Departed holds a set of units that have previously been reported to 480 // be in scope, but which no longer are. 481 Departed []string `json:"Departed"` 482 } 483 484 // RelationUnitsWatchResult holds a RelationUnitsWatcher id, baseline state 485 // (in the Changes field), and an error (if any). 486 type RelationUnitsWatchResult struct { 487 RelationUnitsWatcherId string `json:"RelationUnitsWatcherId"` 488 Changes RelationUnitsChange `json:"Changes"` 489 Error *Error `json:"Error"` 490 } 491 492 // RelationUnitsWatchResults holds the results for any API call which ends up 493 // returning a list of RelationUnitsWatchers. 494 type RelationUnitsWatchResults struct { 495 Results []RelationUnitsWatchResult 496 } 497 498 // MachineStorageIdsWatchResult holds a MachineStorageIdsWatcher id, 499 // changes and an error (if any). 500 type MachineStorageIdsWatchResult struct { 501 MachineStorageIdsWatcherId string 502 Changes []MachineStorageId 503 Error *Error 504 } 505 506 // MachineStorageIdsWatchResults holds the results for any API call which ends 507 // up returning a list of MachineStorageIdsWatchers. 508 type MachineStorageIdsWatchResults struct { 509 Results []MachineStorageIdsWatchResult 510 } 511 512 // CharmsResponse is the server response to charm upload or GET requests. 513 type CharmsResponse struct { 514 Error string `json:",omitempty"` 515 516 // ErrorCode holds the code associated with the error. 517 // Ideally, Error would hold an Error object and the 518 // code would be in that, but for backward compatibility, 519 // we cannot do that. 520 ErrorCode string `json:",omitempty"` 521 522 // ErrorInfo holds extra information associated with the error. 523 // Like ErrorCode, this should really be in an Error object. 524 ErrorInfo *ErrorInfo 525 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 } 555 556 // AgentVersionResult is used to return the current version number of the 557 // agent running the API server. 558 type AgentVersionResult struct { 559 Version version.Number 560 } 561 562 // ProvisioningInfo holds machine provisioning info. 563 type ProvisioningInfo struct { 564 Constraints constraints.Value 565 Series string 566 Placement string 567 Jobs []multiwatcher.MachineJob 568 Volumes []VolumeParams 569 Tags map[string]string 570 SubnetsToZones map[string][]string 571 ImageMetadata []CloudImageMetadata 572 EndpointBindings map[string]string 573 } 574 575 // ProvisioningInfoResult holds machine provisioning info or an error. 576 type ProvisioningInfoResult struct { 577 Error *Error 578 Result *ProvisioningInfo 579 } 580 581 // ProvisioningInfoResults holds multiple machine provisioning info results. 582 type ProvisioningInfoResults struct { 583 Results []ProvisioningInfoResult 584 } 585 586 // Metric holds a single metric. 587 type Metric struct { 588 Key string 589 Value string 590 Time time.Time 591 } 592 593 // MetricsParam contains the metrics for a single unit. 594 type MetricsParam struct { 595 Tag string 596 Metrics []Metric 597 } 598 599 // MetricsParams contains the metrics for multiple units. 600 type MetricsParams struct { 601 Metrics []MetricsParam 602 } 603 604 // MetricBatch is a list of metrics with metadata. 605 type MetricBatch struct { 606 UUID string 607 CharmURL string 608 Created time.Time 609 Metrics []Metric 610 } 611 612 // MetricBatchParam contains a single metric batch. 613 type MetricBatchParam struct { 614 Tag string 615 Batch MetricBatch 616 } 617 618 // MetricBatchParams contains multiple metric batches. 619 type MetricBatchParams struct { 620 Batches []MetricBatchParam 621 } 622 623 // MeterStatusResult holds unit meter status or error. 624 type MeterStatusResult struct { 625 Code string 626 Info string 627 Error *Error 628 } 629 630 // MeterStatusResults holds meter status results for multiple units. 631 type MeterStatusResults struct { 632 Results []MeterStatusResult 633 } 634 635 // SingularClaim represents a request for exclusive model administration access 636 // on the part of some controller. 637 type SingularClaim struct { 638 ModelTag string `json:"ModelTag"` 639 ControllerTag string `json:"ControllerTag"` 640 Duration time.Duration `json:"Duration"` 641 } 642 643 // SingularClaims holds any number of SingularClaim~s. 644 type SingularClaims struct { 645 Claims []SingularClaim `json:"Claims"` 646 } 647 648 // GUIArchiveVersion holds information on a specific GUI archive version. 649 type GUIArchiveVersion struct { 650 // Version holds the Juju GUI version number. 651 Version version.Number `json:"version"` 652 // SHA256 holds the SHA256 hash of the GUI tar.bz2 archive. 653 SHA256 string `json:"sha256"` 654 // Current holds whether this specific version is the current one served 655 // by the controller. 656 Current bool `json:"current"` 657 } 658 659 // GUIArchiveResponse holds the response to /gui-archive GET requests. 660 type GUIArchiveResponse struct { 661 Versions []GUIArchiveVersion `json:"versions"` 662 } 663 664 // GUIVersionRequest holds the body for /gui-version PUT requests. 665 type GUIVersionRequest struct { 666 // Version holds the Juju GUI version number. 667 Version version.Number `json:"version"` 668 }