github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/apiserver/params/params.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 "fmt" 8 "strings" 9 "time" 10 11 "github.com/juju/errors" 12 "github.com/juju/replicaset" 13 "github.com/juju/utils/proxy" 14 "github.com/juju/utils/ssh" 15 "github.com/juju/version" 16 "gopkg.in/macaroon.v1" 17 18 "github.com/juju/juju/constraints" 19 "github.com/juju/juju/instance" 20 "github.com/juju/juju/network" 21 "github.com/juju/juju/state/multiwatcher" 22 "github.com/juju/juju/storage" 23 "github.com/juju/juju/tools" 24 ) 25 26 // FindTags wraps a slice of strings that are prefixes to use when 27 // searching for matching tags. 28 type FindTags struct { 29 Prefixes []string `json:"prefixes"` 30 } 31 32 // FindTagsResults wraps the mapping between the requested prefix and the 33 // matching tags for each requested prefix. 34 type FindTagsResults struct { 35 Matches map[string][]Entity `json:"matches"` 36 } 37 38 // Entity identifies a single entity. 39 type Entity struct { 40 Tag string `json:"tag"` 41 } 42 43 // Entities identifies multiple entities. 44 type Entities struct { 45 Entities []Entity `json:"entities"` 46 } 47 48 // EntitiesResults contains multiple Entities results (where each 49 // Entities is the result of a query). 50 type EntitiesResults struct { 51 Results []EntitiesResult `json:"results"` 52 } 53 54 // EntitiesResult is the result of one query that either yields some 55 // set of entities or an error. 56 type EntitiesResult struct { 57 Entities []Entity `json:"entities"` 58 Error *Error `json:"error,omitempty"` 59 } 60 61 // EntityPasswords holds the parameters for making a SetPasswords call. 62 type EntityPasswords struct { 63 Changes []EntityPassword `json:"changes"` 64 } 65 66 // EntityPassword specifies a password change for the entity 67 // with the given tag. 68 type EntityPassword struct { 69 Tag string `json:"tag"` 70 Password string `json:"password"` 71 } 72 73 // ErrorResults holds the results of calling a bulk operation which 74 // returns no data, only an error result. The order and 75 // number of elements matches the operations specified in the request. 76 type ErrorResults struct { 77 // Results contains the error results from each operation. 78 Results []ErrorResult `json:"results"` 79 } 80 81 // OneError returns the error from the result 82 // of a bulk operation on a single value. 83 func (result ErrorResults) OneError() error { 84 if n := len(result.Results); n != 1 { 85 return fmt.Errorf("expected 1 result, got %d", n) 86 } 87 if err := result.Results[0].Error; err != nil { 88 return err 89 } 90 return nil 91 } 92 93 // Combine returns one error from the result which is an accumulation of the 94 // errors. If there are no errors in the result, the return value is nil. 95 // Otherwise the error values are combined with new-line characters. 96 func (result ErrorResults) Combine() error { 97 var errorStrings []string 98 for _, r := range result.Results { 99 if r.Error != nil { 100 errorStrings = append(errorStrings, r.Error.Error()) 101 } 102 } 103 if errorStrings != nil { 104 return errors.New(strings.Join(errorStrings, "\n")) 105 } 106 return nil 107 } 108 109 // ErrorResult holds the error status of a single operation. 110 type ErrorResult struct { 111 Error *Error `json:"error,omitempty"` 112 } 113 114 // AddRelation holds the parameters for making the AddRelation call. 115 // The endpoints specified are unordered. 116 type AddRelation struct { 117 Endpoints []string `json:"endpoints"` 118 } 119 120 // AddRelationResults holds the results of a AddRelation call. The Endpoints 121 // field maps application names to the involved endpoints. 122 type AddRelationResults struct { 123 Endpoints map[string]CharmRelation `json:"endpoints"` 124 } 125 126 // DestroyRelation holds the parameters for making the DestroyRelation call. 127 // The endpoints specified are unordered. 128 type DestroyRelation struct { 129 Endpoints []string `json:"endpoints"` 130 } 131 132 // AddCharm holds the arguments for making an AddCharm API call. 133 type AddCharm struct { 134 URL string `json:"url"` 135 Channel string `json:"channel"` 136 } 137 138 // AddCharmWithAuthorization holds the arguments for making an AddCharmWithAuthorization API call. 139 type AddCharmWithAuthorization struct { 140 URL string `json:"url"` 141 Channel string `json:"channel"` 142 CharmStoreMacaroon *macaroon.Macaroon `json:"macaroon"` 143 } 144 145 // AddMachineParams encapsulates the parameters used to create a new machine. 146 type AddMachineParams struct { 147 // The following fields hold attributes that will be given to the 148 // new machine when it is created. 149 Series string `json:"series"` 150 Constraints constraints.Value `json:"constraints"` 151 Jobs []multiwatcher.MachineJob `json:"jobs"` 152 153 // Disks describes constraints for disks that must be attached to 154 // the machine when it is provisioned. 155 Disks []storage.Constraints `json:"disks,omitempty"` 156 157 // If Placement is non-nil, it contains a placement directive 158 // that will be used to decide how to instantiate the machine. 159 Placement *instance.Placement `json:"placement,omitempty"` 160 161 // If ParentId is non-empty, it specifies the id of the 162 // parent machine within which the new machine will 163 // be created. In that case, ContainerType must also be 164 // set. 165 ParentId string `json:"parent-id"` 166 167 // ContainerType optionally gives the container type of the 168 // new machine. If it is non-empty, the new machine 169 // will be implemented by a container. If it is specified 170 // but ParentId is empty, a new top level machine will 171 // be created to hold the container with given series, 172 // constraints and jobs. 173 ContainerType instance.ContainerType `json:"container-type"` 174 175 // If InstanceId is non-empty, it will be associated with 176 // the new machine along with the given nonce, 177 // hardware characteristics and addresses. 178 // All the following fields will be ignored if ContainerType 179 // is set. 180 InstanceId instance.Id `json:"instance-id"` 181 Nonce string `json:"nonce"` 182 HardwareCharacteristics instance.HardwareCharacteristics `json:"hardware-characteristics"` 183 Addrs []Address `json:"addresses"` 184 } 185 186 // AddMachines holds the parameters for making the AddMachines call. 187 type AddMachines struct { 188 MachineParams []AddMachineParams `json:"params"` 189 } 190 191 // AddMachinesResults holds the results of an AddMachines call. 192 type AddMachinesResults struct { 193 Machines []AddMachinesResult `json:"machines"` 194 } 195 196 // AddMachinesResult holds the name of a machine added by the 197 // api.client.AddMachine call for a single machine. 198 type AddMachinesResult struct { 199 Machine string `json:"machine"` 200 Error *Error `json:"error,omitempty"` 201 } 202 203 // DestroyMachines holds parameters for the DestroyMachines call. 204 type DestroyMachines struct { 205 MachineNames []string `json:"machine-names"` 206 Force bool `json:"force"` 207 } 208 209 // ApplicationsDeploy holds the parameters for deploying one or more applications. 210 type ApplicationsDeploy struct { 211 Applications []ApplicationDeploy `json:"applications"` 212 } 213 214 // ApplicationDeploy holds the parameters for making the application Deploy call. 215 type ApplicationDeploy struct { 216 ApplicationName string `json:"application"` 217 Series string `json:"series"` 218 CharmURL string `json:"charm-url"` 219 Channel string `json:"channel"` 220 NumUnits int `json:"num-units"` 221 Config map[string]string `json:"config,omitempty"` 222 ConfigYAML string `json:"config-yaml"` // Takes precedence over config if both are present. 223 Constraints constraints.Value `json:"constraints"` 224 Placement []*instance.Placement `json:"placement,omitempty"` 225 Storage map[string]storage.Constraints `json:"storage,omitempty"` 226 EndpointBindings map[string]string `json:"endpoint-bindings,omitempty"` 227 Resources map[string]string `json:"resources,omitempty"` 228 } 229 230 // ApplicationUpdate holds the parameters for making the application Update call. 231 type ApplicationUpdate struct { 232 ApplicationName string `json:"application"` 233 CharmURL string `json:"charm-url"` 234 ForceCharmURL bool `json:"force-charm-url"` 235 ForceSeries bool `json:"force-series"` 236 MinUnits *int `json:"min-units,omitempty"` 237 SettingsStrings map[string]string `json:"settings,omitempty"` 238 SettingsYAML string `json:"settings-yaml"` // Takes precedence over SettingsStrings if both are present. 239 Constraints *constraints.Value `json:"constraints,omitempty"` 240 } 241 242 // ApplicationSetCharm sets the charm for a given application. 243 type ApplicationSetCharm struct { 244 // ApplicationName is the name of the application to set the charm on. 245 ApplicationName string `json:"application"` 246 247 // CharmURL is the new url for the charm. 248 CharmURL string `json:"charm-url"` 249 250 // Channel is the charm store channel from which the charm came. 251 Channel string `json:"channel"` 252 253 // ConfigSettings is the charm settings to set during the upgrade. 254 // This field is only understood by Application facade version 2 255 // and greater. 256 ConfigSettings map[string]string `json:"config-settings,omitempty"` 257 258 // ConfigSettingsYAML is the charm settings in YAML format to set 259 // during the upgrade. If this is non-empty, it will take precedence 260 // over ConfigSettings. This field is only understood by Application 261 // facade version 2 262 ConfigSettingsYAML string `json:"config-settings-yaml,omitempty"` 263 264 // ForceUnits forces the upgrade on units in an error state. 265 ForceUnits bool `json:"force-units"` 266 267 // ForceSeries forces the use of the charm even if it doesn't match the 268 // series of the unit. 269 ForceSeries bool `json:"force-series"` 270 271 // ResourceIDs is a map of resource names to resource IDs to activate during 272 // the upgrade. 273 ResourceIDs map[string]string `json:"resource-ids,omitempty"` 274 275 // StorageConstraints is a map of storage names to storage constraints to 276 // update during the upgrade. This field is only understood by Application 277 // facade version 2 and greater. 278 StorageConstraints map[string]StorageConstraints `json:"storage-constraints,omitempty"` 279 } 280 281 // ApplicationExpose holds the parameters for making the application Expose call. 282 type ApplicationExpose struct { 283 ApplicationName string `json:"application"` 284 } 285 286 // ApplicationSet holds the parameters for an application Set 287 // command. Options contains the configuration data. 288 type ApplicationSet struct { 289 ApplicationName string `json:"application"` 290 Options map[string]string `json:"options"` 291 } 292 293 // ApplicationUnset holds the parameters for an application Unset 294 // command. Options contains the option attribute names 295 // to unset. 296 type ApplicationUnset struct { 297 ApplicationName string `json:"application"` 298 Options []string `json:"options"` 299 } 300 301 // ApplicationGet holds parameters for making the Get or 302 // GetCharmURL calls. 303 type ApplicationGet struct { 304 ApplicationName string `json:"application"` 305 } 306 307 // ApplicationGetResults holds results of the application Get call. 308 type ApplicationGetResults struct { 309 Application string `json:"application"` 310 Charm string `json:"charm"` 311 Config map[string]interface{} `json:"config"` 312 Constraints constraints.Value `json:"constraints"` 313 Series string `json:"series"` 314 } 315 316 // ApplicationCharmRelations holds parameters for making the application CharmRelations call. 317 type ApplicationCharmRelations struct { 318 ApplicationName string `json:"application"` 319 } 320 321 // ApplicationCharmRelationsResults holds the results of the application CharmRelations call. 322 type ApplicationCharmRelationsResults struct { 323 CharmRelations []string `json:"charm-relations"` 324 } 325 326 // ApplicationUnexpose holds parameters for the application Unexpose call. 327 type ApplicationUnexpose struct { 328 ApplicationName string `json:"application"` 329 } 330 331 // ApplicationMetricCredential holds parameters for the SetApplicationCredentials call. 332 type ApplicationMetricCredential struct { 333 ApplicationName string `json:"application"` 334 MetricCredentials []byte `json:"metrics-credentials"` 335 } 336 337 // ApplicationMetricCredentials holds multiple ApplicationMetricCredential parameters. 338 type ApplicationMetricCredentials struct { 339 Creds []ApplicationMetricCredential `json:"creds"` 340 } 341 342 // PublicAddress holds parameters for the PublicAddress call. 343 type PublicAddress struct { 344 Target string `json:"target"` 345 } 346 347 // PublicAddressResults holds results of the PublicAddress call. 348 type PublicAddressResults struct { 349 PublicAddress string `json:"public-address"` 350 } 351 352 // PrivateAddress holds parameters for the PrivateAddress call. 353 type PrivateAddress struct { 354 Target string `json:"target"` 355 } 356 357 // PrivateAddressResults holds results of the PrivateAddress call. 358 type PrivateAddressResults struct { 359 PrivateAddress string `json:"private-address"` 360 } 361 362 // Resolved holds parameters for the Resolved call. 363 type Resolved struct { 364 UnitName string `json:"unit-name"` 365 Retry bool `json:"retry"` 366 } 367 368 // ResolvedResults holds results of the Resolved call. 369 type ResolvedResults struct { 370 Application string `json:"application"` 371 Charm string `json:"charm"` 372 Settings map[string]interface{} `json:"settings"` 373 } 374 375 // AddApplicationUnitsResults holds the names of the units added by the 376 // AddUnits call. 377 type AddApplicationUnitsResults struct { 378 Units []string `json:"units"` 379 } 380 381 // AddApplicationUnits holds parameters for the AddUnits call. 382 type AddApplicationUnits struct { 383 ApplicationName string `json:"application"` 384 NumUnits int `json:"num-units"` 385 Placement []*instance.Placement `json:"placement"` 386 } 387 388 // DestroyApplicationUnits holds parameters for the DestroyUnits call. 389 type DestroyApplicationUnits struct { 390 UnitNames []string `json:"unit-names"` 391 } 392 393 // ApplicationDestroy holds the parameters for making the application Destroy call. 394 type ApplicationDestroy struct { 395 ApplicationName string `json:"application"` 396 } 397 398 // Creds holds credentials for identifying an entity. 399 type Creds struct { 400 AuthTag string `json:"auth-tag"` 401 Password string `json:"password"` 402 Nonce string `json:"nonce"` 403 } 404 405 // LoginRequest holds credentials for identifying an entity to the Login v1 406 // facade. AuthTag holds the tag of the user to connect as. If it is empty, 407 // then the provided macaroon slices will be used for authentication (if 408 // any one is valid, the authentication succeeds). If there are no 409 // valid macaroons and macaroon authentication is configured, 410 // the LoginResponse will contain a macaroon that when 411 // discharged, may allow access. 412 type LoginRequest struct { 413 AuthTag string `json:"auth-tag"` 414 Credentials string `json:"credentials"` 415 Nonce string `json:"nonce"` 416 Macaroons []macaroon.Slice `json:"macaroons"` 417 UserData string `json:"user-data"` 418 } 419 420 // LoginRequestCompat holds credentials for identifying an entity to the Login v1 421 // or earlier (v0 or even pre-facade). 422 type LoginRequestCompat struct { 423 LoginRequest `json:"login-request"` 424 Creds `json:"creds"` 425 } 426 427 // GetAnnotationsResults holds annotations associated with an entity. 428 type GetAnnotationsResults struct { 429 Annotations map[string]string `json:"annotations"` 430 } 431 432 // GetAnnotations stores parameters for making the GetAnnotations call. 433 type GetAnnotations struct { 434 Tag string `json:"tag"` 435 } 436 437 // SetAnnotations stores parameters for making the SetAnnotations call. 438 type SetAnnotations struct { 439 Tag string `json:"tag"` 440 Pairs map[string]string `json:"annotations"` 441 } 442 443 // GetApplicationConstraints stores parameters for making the GetApplicationConstraints call. 444 type GetApplicationConstraints struct { 445 ApplicationName string `json:"application"` 446 } 447 448 // GetConstraintsResults holds results of the GetConstraints call. 449 type GetConstraintsResults struct { 450 Constraints constraints.Value `json:"constraints"` 451 } 452 453 // SetConstraints stores parameters for making the SetConstraints call. 454 type SetConstraints struct { 455 ApplicationName string `json:"application"` //optional, if empty, model constraints are set. 456 Constraints constraints.Value `json:"constraints"` 457 } 458 459 // ResolveCharms stores charm references for a ResolveCharms call. 460 type ResolveCharms struct { 461 References []string `json:"references"` 462 } 463 464 // ResolveCharmResult holds the result of resolving a charm reference to a URL, or any error that occurred. 465 type ResolveCharmResult struct { 466 // URL is a string representation of charm.URL. 467 URL string `json:"url,omitempty"` 468 Error string `json:"error,omitempty"` 469 } 470 471 // ResolveCharmResults holds results of the ResolveCharms call. 472 type ResolveCharmResults struct { 473 URLs []ResolveCharmResult `json:"urls"` 474 } 475 476 // AllWatcherId holds the id of an AllWatcher. 477 type AllWatcherId struct { 478 AllWatcherId string `json:"watcher-id"` 479 } 480 481 // AllWatcherNextResults holds deltas returned from calling AllWatcher.Next(). 482 type AllWatcherNextResults struct { 483 Deltas []multiwatcher.Delta `json:"deltas"` 484 } 485 486 // ListSSHKeys stores parameters used for a KeyManager.ListKeys call. 487 type ListSSHKeys struct { 488 Entities `json:"entities"` 489 Mode ssh.ListMode `json:"mode"` 490 } 491 492 // ModifyUserSSHKeys stores parameters used for a KeyManager.Add|Delete|Import call for a user. 493 type ModifyUserSSHKeys struct { 494 User string `json:"user"` 495 Keys []string `json:"ssh-keys"` 496 } 497 498 // StateServingInfo holds information needed by a state 499 // server. 500 type StateServingInfo struct { 501 APIPort int `json:"api-port"` 502 StatePort int `json:"state-port"` 503 // The controller cert and corresponding private key. 504 Cert string `json:"cert"` 505 PrivateKey string `json:"private-key"` 506 // The private key for the CA cert so that a new controller 507 // cert can be generated when needed. 508 CAPrivateKey string `json:"ca-private-key"` 509 // this will be passed as the KeyFile argument to MongoDB 510 SharedSecret string `json:"shared-secret"` 511 SystemIdentity string `json:"system-identity"` 512 } 513 514 // IsMasterResult holds the result of an IsMaster API call. 515 type IsMasterResult struct { 516 // Master reports whether the connected agent 517 // lives on the same instance as the mongo replica 518 // set master. 519 Master bool `json:"master"` 520 } 521 522 // ContainerManagerConfigParams contains the parameters for the 523 // ContainerManagerConfig provisioner API call. 524 type ContainerManagerConfigParams struct { 525 Type instance.ContainerType `json:"type"` 526 } 527 528 // ContainerManagerConfig contains information from the model config 529 // that is needed for configuring the container manager. 530 type ContainerManagerConfig struct { 531 ManagerConfig map[string]string `json:"config"` 532 } 533 534 // UpdateBehavior contains settings that are duplicated in several 535 // places. Let's just embed this instead. 536 type UpdateBehavior struct { 537 EnableOSRefreshUpdate bool `json:"enable-os-refresh-update"` 538 EnableOSUpgrade bool `json:"enable-os-upgrade"` 539 } 540 541 // ContainerConfig contains information from the model config that is 542 // needed for container cloud-init. 543 type ContainerConfig struct { 544 ProviderType string `json:"provider-type"` 545 AuthorizedKeys string `json:"authorized-keys"` 546 SSLHostnameVerification bool `json:"ssl-hostname-verification"` 547 Proxy proxy.Settings `json:"proxy"` 548 AptProxy proxy.Settings `json:"apt-proxy"` 549 AptMirror string `json:"apt-mirror"` 550 *UpdateBehavior 551 } 552 553 // ProvisioningScriptParams contains the parameters for the 554 // ProvisioningScript client API call. 555 type ProvisioningScriptParams struct { 556 MachineId string `json:"machine-id"` 557 Nonce string `json:"nonce"` 558 559 // DataDir may be "", in which case the default will be used. 560 DataDir string `json:"data-dir"` 561 562 // DisablePackageCommands may be set to disable all 563 // package-related commands. It is then the responsibility of the 564 // provisioner to ensure that all the packages required by Juju 565 // are available. 566 DisablePackageCommands bool `json:"disable-package-commands"` 567 } 568 569 // ProvisioningScriptResult contains the result of the 570 // ProvisioningScript client API call. 571 type ProvisioningScriptResult struct { 572 Script string `json:"script"` 573 } 574 575 // DeployerConnectionValues containers the result of deployer.ConnectionInfo 576 // API call. 577 type DeployerConnectionValues struct { 578 StateAddresses []string `json:"state-addresses"` 579 APIAddresses []string `json:"api-addresses"` 580 } 581 582 // JobsResult holds the jobs for a machine that are returned by a call to Jobs. 583 type JobsResult struct { 584 Jobs []multiwatcher.MachineJob `json:"jobs"` 585 Error *Error `json:"error,omitempty"` 586 } 587 588 // JobsResults holds the result of a call to Jobs. 589 type JobsResults struct { 590 Results []JobsResult `json:"results"` 591 } 592 593 // DistributionGroupResult contains the result of 594 // the DistributionGroup provisioner API call. 595 type DistributionGroupResult struct { 596 Error *Error `json:"error,omitempty"` 597 Result []instance.Id `json:"result"` 598 } 599 600 // DistributionGroupResults is the bulk form of 601 // DistributionGroupResult. 602 type DistributionGroupResults struct { 603 Results []DistributionGroupResult `json:"results"` 604 } 605 606 // FacadeVersions describes the available Facades and what versions of each one 607 // are available 608 type FacadeVersions struct { 609 Name string `json:"name"` 610 Versions []int `json:"versions"` 611 } 612 613 // RedirectInfoResult holds the result of a RedirectInfo call. 614 type RedirectInfoResult struct { 615 // Servers holds an entry for each server that holds the 616 // addresses for the server. 617 Servers [][]HostPort `json:"servers"` 618 619 // CACert holds the CA certificate for the server. 620 // TODO(rogpeppe) allow this to be empty if the 621 // server has a globally trusted certificate? 622 CACert string `json:"ca-cert"` 623 } 624 625 // ReauthRequest holds a challenge/response token meaningful to the identity 626 // provider. 627 type ReauthRequest struct { 628 Prompt string `json:"prompt"` 629 Nonce string `json:"nonce"` 630 } 631 632 // AuthUserInfo describes a logged-in local user or remote identity. 633 type AuthUserInfo struct { 634 DisplayName string `json:"display-name"` 635 Identity string `json:"identity"` 636 LastConnection *time.Time `json:"last-connection,omitempty"` 637 638 // Credentials contains an optional opaque credential value to be held by 639 // the client, if any. 640 Credentials *string `json:"credentials,omitempty"` 641 642 // ControllerAccess holds the access the user has to the connected controller. 643 ControllerAccess string `json:"controller-access"` 644 // ModelAccess holds the access the user has to the connected model. 645 ModelAccess string `json:"model-access"` 646 } 647 648 // LoginResult holds the result of an Admin Login call. 649 type LoginResult struct { 650 // DischargeRequired implies that the login request has failed, and none of 651 // the other fields are populated. It contains a macaroon which, when 652 // discharged, will grant access on a subsequent call to Login. 653 // Note: It is OK to use the Macaroon type here as it is explicitely 654 // designed to provide stable serialisation of macaroons. It's good 655 // practice to only use primitives in types that will be serialised, 656 // however because of the above it is suitable to use the Macaroon type 657 // here. 658 DischargeRequired *macaroon.Macaroon `json:"discharge-required,omitempty"` 659 660 // DischargeRequiredReason holds the reason that the above discharge was 661 // required. 662 DischargeRequiredReason string `json:"discharge-required-error,omitempty"` 663 664 // Servers is the list of API server addresses. 665 Servers [][]HostPort `json:"servers,omitempty"` 666 667 // ModelTag is the tag for the model that is being connected to. 668 ModelTag string `json:"model-tag,omitempty"` 669 670 // ControllerTag is the tag for the controller that runs the API servers. 671 ControllerTag string `json:"controller-tag,omitempty"` 672 673 // UserInfo describes the authenticated user, if any. 674 UserInfo *AuthUserInfo `json:"user-info,omitempty"` 675 676 // Facades describes all the available API facade versions to the 677 // authenticated client. 678 Facades []FacadeVersions `json:"facades,omitempty"` 679 680 // ServerVersion is the string representation of the server version 681 // if the server supports it. 682 ServerVersion string `json:"server-version,omitempty"` 683 } 684 685 // ControllersServersSpec contains arguments for 686 // the EnableHA client API call. 687 type ControllersSpec struct { 688 ModelTag string `json:"model-tag"` 689 NumControllers int `json:"num-controllers"` 690 Constraints constraints.Value `json:"constraints,omitempty"` 691 // Series is the series to associate with new controller machines. 692 // If this is empty, then the model's default series is used. 693 Series string `json:"series,omitempty"` 694 // Placement defines specific machines to become new controller machines. 695 Placement []string `json:"placement,omitempty"` 696 } 697 698 // ControllersServersSpecs contains all the arguments 699 // for the EnableHA API call. 700 type ControllersSpecs struct { 701 Specs []ControllersSpec `json:"specs"` 702 } 703 704 // ControllersChangeResult contains the results 705 // of a single EnableHA API call or 706 // an error. 707 type ControllersChangeResult struct { 708 Result ControllersChanges `json:"result"` 709 Error *Error `json:"error,omitempty"` 710 } 711 712 // ControllersChangeResults contains the results 713 // of the EnableHA API call. 714 type ControllersChangeResults struct { 715 Results []ControllersChangeResult `json:"results"` 716 } 717 718 // ControllersChanges lists the servers 719 // that have been added, removed or maintained in the 720 // pool as a result of an enable-ha operation. 721 type ControllersChanges struct { 722 Added []string `json:"added,omitempty"` 723 Maintained []string `json:"maintained,omitempty"` 724 Removed []string `json:"removed,omitempty"` 725 Promoted []string `json:"promoted,omitempty"` 726 Demoted []string `json:"demoted,omitempty"` 727 Converted []string `json:"converted,omitempty"` 728 } 729 730 // FindToolsParams defines parameters for the FindTools method. 731 type FindToolsParams struct { 732 // Number will be used to match tools versions exactly if non-zero. 733 Number version.Number `json:"number"` 734 735 // MajorVersion will be used to match the major version if non-zero. 736 MajorVersion int `json:"major"` 737 738 // MinorVersion will be used to match the major version if greater 739 // than or equal to zero, and Number is zero. 740 MinorVersion int `json:"minor"` 741 742 // Arch will be used to match tools by architecture if non-empty. 743 Arch string `json:"arch"` 744 745 // Series will be used to match tools by series if non-empty. 746 Series string `json:"series"` 747 } 748 749 // FindToolsResult holds a list of tools from FindTools and any error. 750 type FindToolsResult struct { 751 List tools.List `json:"list"` 752 Error *Error `json:"error,omitempty"` 753 } 754 755 // ImageFilterParams holds the parameters used to specify images to delete. 756 type ImageFilterParams struct { 757 Images []ImageSpec `json:"images"` 758 } 759 760 // ImageSpec defines the parameters to select images list or delete. 761 type ImageSpec struct { 762 Kind string `json:"kind"` 763 Arch string `json:"arch"` 764 Series string `json:"series"` 765 } 766 767 // ListImageResult holds the results of querying images. 768 type ListImageResult struct { 769 Result []ImageMetadata `json:"result"` 770 } 771 772 // ImageMetadata represents an image in storage. 773 type ImageMetadata struct { 774 Kind string `json:"kind"` 775 Arch string `json:"arch"` 776 Series string `json:"series"` 777 URL string `json:"url"` 778 Created time.Time `json:"created"` 779 } 780 781 // RebootActionResults holds a list of RebootActionResult and any error. 782 type RebootActionResults struct { 783 Results []RebootActionResult `json:"results,omitempty"` 784 } 785 786 // RebootActionResult holds the result of a single call to 787 // machine.ShouldRebootOrShutdown. 788 type RebootActionResult struct { 789 Result RebootAction `json:"result,omitempty"` 790 Error *Error `json:"error,omitempty"` 791 } 792 793 // LogRecord is used to transmit log messages to the logsink API 794 // endpoint. Single character field names are used for serialisation 795 // to keep the size down. These messages are going to be sent a lot. 796 type LogRecord struct { 797 Time time.Time `json:"t"` 798 Module string `json:"m"` 799 Location string `json:"l"` 800 Level string `json:"v"` 801 Message string `json:"x"` 802 } 803 804 // GetBundleChangesParams holds parameters for making GetBundleChanges calls. 805 type GetBundleChangesParams struct { 806 // BundleDataYAML is the YAML-encoded charm bundle data 807 // (see "github.com/juju/charm.BundleData"). 808 BundleDataYAML string `json:"yaml"` 809 } 810 811 // GetBundleChangesResults holds results of the GetBundleChanges call. 812 type GetBundleChangesResults struct { 813 // Changes holds the list of changes required to deploy the bundle. 814 // It is omitted if the provided bundle YAML has verification errors. 815 Changes []*BundleChangesChange `json:"changes,omitempty"` 816 // Errors holds possible bundle verification errors. 817 Errors []string `json:"errors,omitempty"` 818 } 819 820 // BundleChangesChange holds a single change required to deploy a bundle. 821 type BundleChangesChange struct { 822 // Id is the unique identifier for this change. 823 Id string `json:"id"` 824 // Method is the action to be performed to apply this change. 825 Method string `json:"method"` 826 // Args holds a list of arguments to pass to the method. 827 Args []interface{} `json:"args"` 828 // Requires holds a list of dependencies for this change. Each dependency 829 // is represented by the corresponding change id, and must be applied 830 // before this change is applied. 831 Requires []string `json:"requires"` 832 } 833 834 type MongoVersion struct { 835 Major int `json:"major"` 836 Minor int `json:"minor"` 837 Patch string `json:"patch"` 838 StorageEngine string `json:"engine"` 839 } 840 841 // UpgradeMongoParams holds the arguments required to 842 // enter upgrade mongo mode. 843 type UpgradeMongoParams struct { 844 Target MongoVersion `json:"target"` 845 } 846 847 // HAMember holds information that identifies one member 848 // of HA. 849 type HAMember struct { 850 Tag string `json:"tag"` 851 PublicAddress network.Address `json:"public-address"` 852 Series string `json:"series"` 853 } 854 855 // MongoUpgradeResults holds the results of an attempt 856 // to enter upgrade mongo mode. 857 type MongoUpgradeResults struct { 858 RsMembers []replicaset.Member `json:"rs-members"` 859 Master HAMember `json:"master"` 860 Members []HAMember `json:"ha-members"` 861 } 862 863 // ResumeReplicationParams holds the members of a HA that 864 // must be resumed. 865 type ResumeReplicationParams struct { 866 Members []replicaset.Member `json:"members"` 867 } 868 869 // MeterStatusParam holds meter status information to be set for the specified tag. 870 type MeterStatusParam struct { 871 Tag string `json:"tag"` 872 Code string `json:"code"` 873 Info string `json:"info, omitempty"` 874 } 875 876 // MeterStatusParams holds parameters for making SetMeterStatus calls. 877 type MeterStatusParams struct { 878 Statuses []MeterStatusParam `json:"statues"` 879 } 880 881 // MacaroonResults contains a set of MacaroonResults. 882 type MacaroonResults struct { 883 Results []MacaroonResult `json:"results"` 884 } 885 886 // MacaroonResult contains a macaroon or an error. 887 type MacaroonResult struct { 888 Result *macaroon.Macaroon `json:"result,omitempty"` 889 Error *Error `json:"error,omitempty"` 890 }