github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/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/go-macaroon-bakery/macaroon-bakery/v3/bakery" 12 "github.com/juju/errors" 13 "github.com/juju/proxy" 14 "github.com/juju/utils/v3/ssh" 15 "github.com/juju/version/v2" 16 "gopkg.in/macaroon.v2" 17 18 "github.com/juju/juju/core/constraints" 19 "github.com/juju/juju/core/instance" 20 "github.com/juju/juju/core/model" 21 "github.com/juju/juju/storage" 22 "github.com/juju/juju/tools" 23 ) 24 25 // Entity identifies a single entity. 26 type Entity struct { 27 Tag string `json:"tag"` 28 } 29 30 // Entities identifies multiple entities. 31 type Entities struct { 32 Entities []Entity `json:"entities"` 33 } 34 35 // EntitiesResults contains multiple Entities results (where each 36 // Entities is the result of a query). 37 type EntitiesResults struct { 38 Results []EntitiesResult `json:"results"` 39 } 40 41 // EntitiesResult is the result of one query that either yields some 42 // set of entities or an error. 43 type EntitiesResult struct { 44 Entities []Entity `json:"entities"` 45 Error *Error `json:"error,omitempty"` 46 } 47 48 // EntityPasswords holds the parameters for making a SetPasswords call. 49 type EntityPasswords struct { 50 Changes []EntityPassword `json:"changes"` 51 } 52 53 // EntityPassword specifies a password change for the entity 54 // with the given tag. 55 type EntityPassword struct { 56 Tag string `json:"tag"` 57 Password string `json:"password"` 58 } 59 60 // ErrorResults holds the results of calling a bulk operation which 61 // returns no data, only an error result. The order and 62 // number of elements matches the operations specified in the request. 63 type ErrorResults struct { 64 // Results contains the error results from each operation. 65 Results []ErrorResult `json:"results"` 66 } 67 68 // OneError returns the error from the result 69 // of a bulk operation on a single value. 70 func (result ErrorResults) OneError() error { 71 if n := len(result.Results); n != 1 { 72 return fmt.Errorf("expected 1 result, got %d", n) 73 } 74 if err := result.Results[0].Error; err != nil { 75 return err 76 } 77 return nil 78 } 79 80 // Combine returns one error from the result which is an accumulation of the 81 // errors. If there are no errors in the result, the return value is nil. 82 // Otherwise the error values are combined with new-line characters. 83 func (result ErrorResults) Combine() error { 84 var errorStrings []string 85 for _, r := range result.Results { 86 if r.Error != nil { 87 errorStrings = append(errorStrings, r.Error.Error()) 88 } 89 } 90 if errorStrings != nil { 91 return errors.New(strings.Join(errorStrings, "\n")) 92 } 93 return nil 94 } 95 96 // ErrorResult holds the error status of a single operation. 97 type ErrorResult struct { 98 Error *Error `json:"error,omitempty"` 99 } 100 101 // AddRelation holds the parameters for making the AddRelation call. 102 // The endpoints specified are unordered. 103 type AddRelation struct { 104 Endpoints []string `json:"endpoints"` 105 ViaCIDRs []string `json:"via-cidrs,omitempty"` 106 } 107 108 // AddRelationResults holds the results of a AddRelation call. The Endpoints 109 // field maps application names to the involved endpoints. 110 type AddRelationResults struct { 111 Endpoints map[string]CharmRelation `json:"endpoints"` 112 } 113 114 // DestroyRelation holds the parameters for making the DestroyRelation call. 115 // A relation is identified by either endpoints or id. 116 // The endpoints, if specified, are unordered. 117 type DestroyRelation struct { 118 Endpoints []string `json:"endpoints,omitempty"` 119 RelationId int `json:"relation-id"` 120 121 // Force specifies whether relation destruction will be forced, i.e. 122 // keep going despite operational errors. 123 Force *bool `json:"force,omitempty"` 124 125 // MaxWait specifies the amount of time that each step in relation destroy process 126 // will wait before forcing the next step to kick-off. This parameter 127 // only makes sense in combination with 'force' set to 'true'. 128 MaxWait *time.Duration `json:"max-wait,omitempty"` 129 } 130 131 // RelationStatusArgs holds the parameters for updating the status 132 // of one or more relations. 133 type RelationStatusArgs struct { 134 Args []RelationStatusArg `json:"args"` 135 } 136 137 // RelationStatusArg holds the new status value for a relation. 138 type RelationStatusArg struct { 139 UnitTag string `json:"unit-tag"` 140 RelationId int `json:"relation-id"` 141 Status RelationStatusValue `json:"status"` 142 Message string `json:"message"` 143 } 144 145 // RelationSuspendedArgs holds the parameters for setting 146 // the suspended status of one or more relations. 147 type RelationSuspendedArgs struct { 148 Args []RelationSuspendedArg `json:"args"` 149 } 150 151 // RelationSuspendedArg holds the new suspended status value for a relation. 152 type RelationSuspendedArg struct { 153 RelationId int `json:"relation-id"` 154 Message string `json:"message"` 155 Suspended bool `json:"suspended"` 156 } 157 158 // ProcessRelations holds the information required to process series of 159 // relations during a model migration. 160 type ProcessRelations struct { 161 ControllerAlias string `json:"controller-alias"` 162 } 163 164 // AddCharm holds the arguments for making an AddCharm API call. 165 type AddCharm struct { 166 URL string `json:"url"` 167 Channel string `json:"channel"` 168 Force bool `json:"force"` 169 } 170 171 // AddCharmWithOrigin holds the arguments for making an AddCharm API call via the 172 // Charms facade. 173 type AddCharmWithOrigin struct { 174 URL string `json:"url"` 175 Origin CharmOrigin `json:"charm-origin"` 176 Force bool `json:"force"` 177 } 178 179 // AddCharmWithAuthorization holds the arguments for making an 180 // AddCharmWithAuthorization API call. 181 type AddCharmWithAuthorization struct { 182 URL string `json:"url"` 183 Channel string `json:"channel"` 184 CharmStoreMacaroon *macaroon.Macaroon `json:"macaroon"` 185 Force bool `json:"force"` 186 } 187 188 // AddCharmWithAuth holds the arguments for making an 189 // AddCharmWithAuth API call via the Charms facade. 190 type AddCharmWithAuth struct { 191 URL string `json:"url"` 192 Origin CharmOrigin `json:"charm-origin"` 193 CharmStoreMacaroon *macaroon.Macaroon `json:"macaroon"` 194 Force bool `json:"force"` 195 } 196 197 // CharmOriginResult holds the results of AddCharms calls where 198 // a CharmOrigin was used. 199 type CharmOriginResult struct { 200 Origin CharmOrigin `json:"charm-origin"` 201 Error *Error `json:"error,omitempty"` 202 } 203 204 // CharmURLOriginResult holds the results of the charm's url and origin. 205 type CharmURLOriginResult struct { 206 URL string `json:"url"` 207 Origin CharmOrigin `json:"charm-origin"` 208 Error *Error `json:"error,omitempty"` 209 } 210 211 // Base holds the name of an OS name and its version. 212 type Base struct { 213 Name string `json:"name"` 214 Channel string `json:"channel"` 215 } 216 217 // AddMachineParams encapsulates the parameters used to create a new machine. 218 type AddMachineParams struct { 219 // The following fields hold attributes that will be given to the 220 // new machine when it is created. 221 Base *Base `json:"base,omitempty"` 222 Constraints constraints.Value `json:"constraints"` 223 Jobs []model.MachineJob `json:"jobs"` 224 225 // Disks describes constraints for disks that must be attached to 226 // the machine when it is provisioned. 227 Disks []storage.Constraints `json:"disks,omitempty"` 228 229 // If Placement is non-nil, it contains a placement directive 230 // that will be used to decide how to instantiate the machine. 231 Placement *instance.Placement `json:"placement,omitempty"` 232 233 // If ParentId is non-empty, it specifies the id of the 234 // parent machine within which the new machine will 235 // be created. In that case, ContainerType must also be 236 // set. 237 ParentId string `json:"parent-id"` 238 239 // ContainerType optionally gives the container type of the 240 // new machine. If it is non-empty, the new machine 241 // will be implemented by a container. If it is specified 242 // but ParentId is empty, a new top level machine will 243 // be created to hold the container with given series, 244 // constraints and jobs. 245 ContainerType instance.ContainerType `json:"container-type"` 246 247 // If InstanceId is non-empty, it will be associated with 248 // the new machine along with the given nonce, 249 // hardware characteristics and addresses. 250 // All the following fields will be ignored if ContainerType 251 // is set. 252 InstanceId instance.Id `json:"instance-id"` 253 Nonce string `json:"nonce"` 254 HardwareCharacteristics instance.HardwareCharacteristics `json:"hardware-characteristics"` 255 Addrs []Address `json:"addresses"` 256 } 257 258 // AddMachines holds the parameters for making the AddMachines call. 259 type AddMachines struct { 260 MachineParams []AddMachineParams `json:"params"` 261 } 262 263 // AddMachinesResults holds the results of an AddMachines call. 264 type AddMachinesResults struct { 265 Machines []AddMachinesResult `json:"machines"` 266 } 267 268 // AddMachinesResult holds the name of a machine added by the 269 // api.client.AddMachine call for a single machine. 270 type AddMachinesResult struct { 271 Machine string `json:"machine"` 272 Error *Error `json:"error,omitempty"` 273 } 274 275 // DestroyMachinesParamsV9 holds parameters for the v9 DestroyMachinesWithParams call. 276 type DestroyMachinesParamsV9 struct { 277 MachineTags []string `json:"machine-tags"` 278 Force bool `json:"force,omitempty"` 279 Keep bool `json:"keep,omitempty"` 280 281 // MaxWait specifies the amount of time that each step in machine destroy process 282 // will wait before forcing the next step to kick-off. This parameter 283 // only makes sense in combination with 'force' set to 'true'. 284 MaxWait *time.Duration `json:"max-wait,omitempty"` 285 } 286 287 // DestroyMachinesParams holds parameters for the latest DestroyMachinesWithParams call. 288 type DestroyMachinesParams struct { 289 MachineTags []string `json:"machine-tags"` 290 Force bool `json:"force,omitempty"` 291 Keep bool `json:"keep,omitempty"` 292 DryRun bool `json:"dry-run,omitempty"` 293 294 // MaxWait specifies the amount of time that each step in machine destroy process 295 // will wait before forcing the next step to kick-off. This parameter 296 // only makes sense in combination with 'force' set to 'true'. 297 MaxWait *time.Duration `json:"max-wait,omitempty"` 298 } 299 300 // RecordAgentStartInformationArgs holds the parameters for updating the 301 // information reported by one or more machine agents when they start. 302 type RecordAgentStartInformationArgs struct { 303 Args []RecordAgentStartInformationArg `json:"args"` 304 } 305 306 // RecordAgentStartInformationArg holds the information reported by a machine 307 // agnet to the controller when it starts. 308 type RecordAgentStartInformationArg struct { 309 Tag string `json:"tag"` 310 Hostname string `json:"hostname,omitempty"` 311 } 312 313 // UpdateChannelArg holds the parameters for updating the series for the 314 // specified application or machine. For Application, only known by facade 315 // version 5 and greater. For MachineManger, only known by facade version 316 // 4 or greater. 317 type UpdateChannelArg struct { 318 Entity Entity `json:"tag"` 319 Force bool `json:"force"` 320 Channel string `json:"channel"` 321 } 322 323 // UpdateChannelArgs holds the parameters for updating the series 324 // of one or more applications or machines. For Application, only known 325 // by facade version 5 and greater. For MachineManger, only known by facade 326 // version 4 or greater. 327 type UpdateChannelArgs struct { 328 Args []UpdateChannelArg `json:"args"` 329 } 330 331 // LXDProfileUpgrade holds the parameters for an application 332 // lxd profile machines 333 type LXDProfileUpgrade struct { 334 Entities []Entity `json:"entities"` 335 ApplicationName string `json:"application-name"` 336 } 337 338 // UpgradeCharmProfileStatusResult contains the lxd profile status result for an upgrading 339 // machine or container. 340 type UpgradeCharmProfileStatusResult struct { 341 Error *Error `json:"error,omitempty"` 342 Status string `json:"status,omitempty"` 343 } 344 345 // UpgradeCharmProfileStatusResults contains the lxd profile status results for 346 // upgrading machines or container. 347 type UpgradeCharmProfileStatusResults struct { 348 Results []UpgradeCharmProfileStatusResult `json:"results,omitempty"` 349 } 350 351 // ConfigResult holds configuration values for an entity. 352 type ConfigResult struct { 353 Config map[string]interface{} `json:"config"` 354 Error *Error `json:"error,omitempty"` 355 } 356 357 // ModelOperatorInfo holds infor needed for a model operator. 358 type ModelOperatorInfo struct { 359 APIAddresses []string `json:"api-addresses"` 360 ImageDetails DockerImageInfo `json:"image-details"` 361 Version version.Number `json:"version"` 362 } 363 364 // OperatorProvisioningInfoResults holds OperatorProvisioningInfo results. 365 type OperatorProvisioningInfoResults struct { 366 Results []OperatorProvisioningInfo `json:"results"` 367 } 368 369 // OperatorProvisioningInfo holds info need to provision an operator. 370 type OperatorProvisioningInfo struct { 371 ImageDetails DockerImageInfo `json:"image-details"` 372 BaseImageDetails DockerImageInfo `json:"base-image-details"` 373 Version version.Number `json:"version"` 374 APIAddresses []string `json:"api-addresses"` 375 Tags map[string]string `json:"tags,omitempty"` 376 CharmStorage *KubernetesFilesystemParams `json:"charm-storage,omitempty"` 377 Error *Error `json:"error,omitempty"` 378 } 379 380 // IssueOperatorCertificateResult contains an x509 certificate 381 // for a CAAS Operator. 382 type IssueOperatorCertificateResult struct { 383 CACert string `json:"ca-cert"` 384 Cert string `json:"cert"` 385 PrivateKey string `json:"private-key"` 386 Error *Error `json:"error,omitempty"` 387 } 388 389 // IssueOperatorCertificateResults holds IssueOperatorCertificate results. 390 type IssueOperatorCertificateResults struct { 391 Results []IssueOperatorCertificateResult `json:"results"` 392 } 393 394 // PublicAddress holds parameters for the PublicAddress call. 395 type PublicAddress struct { 396 Target string `json:"target"` 397 } 398 399 // PublicAddressResults holds results of the PublicAddress call. 400 type PublicAddressResults struct { 401 PublicAddress string `json:"public-address"` 402 } 403 404 // PrivateAddress holds parameters for the PrivateAddress call. 405 type PrivateAddress struct { 406 Target string `json:"target"` 407 } 408 409 // PrivateAddressResults holds results of the PrivateAddress call. 410 type PrivateAddressResults struct { 411 PrivateAddress string `json:"private-address"` 412 } 413 414 // Resolved holds parameters for the Resolved call. 415 type Resolved struct { 416 UnitName string `json:"unit-name"` 417 Retry bool `json:"retry"` 418 } 419 420 // ResolvedResults holds results of the Resolved call. 421 type ResolvedResults struct { 422 Application string `json:"application"` 423 Charm string `json:"charm"` 424 Settings map[string]interface{} `json:"settings"` 425 } 426 427 // UnitsResolved holds parameters for the ResolveUnitErrors call. 428 type UnitsResolved struct { 429 Tags Entities `json:"tags,omitempty"` 430 Retry bool `json:"retry,omitempty"` 431 All bool `json:"all,omitempty"` 432 } 433 434 // AddApplicationUnitsResults holds the names of the units added by the 435 // AddUnits call. 436 type AddApplicationUnitsResults struct { 437 Units []string `json:"units"` 438 } 439 440 // AddApplicationUnits holds parameters for the AddUnits call. 441 type AddApplicationUnits struct { 442 ApplicationName string `json:"application"` 443 NumUnits int `json:"num-units"` 444 Placement []*instance.Placement `json:"placement"` 445 Policy string `json:"policy,omitempty"` 446 AttachStorage []string `json:"attach-storage,omitempty"` 447 } 448 449 // AddApplicationUnitsV5 holds parameters for the AddUnits call. 450 // V5 is missing the new policy arg. 451 type AddApplicationUnitsV5 struct { 452 ApplicationName string `json:"application"` 453 NumUnits int `json:"num-units"` 454 Placement []*instance.Placement `json:"placement"` 455 AttachStorage []string `json:"attach-storage,omitempty"` 456 } 457 458 // UpdateApplicationUnitArgs holds the parameters for 459 // updating application units. 460 type UpdateApplicationUnitArgs struct { 461 Args []UpdateApplicationUnits `json:"args"` 462 } 463 464 // UpdateApplicationUnits holds unit parameters for a specified application. 465 type UpdateApplicationUnits struct { 466 ApplicationTag string `json:"application-tag"` 467 Scale *int `json:"scale,omitempty"` 468 Generation *int64 `json:"generation,omitempty"` 469 Status EntityStatus `json:"status,omitempty"` 470 Units []ApplicationUnitParams `json:"units"` 471 } 472 473 // ApplicationUnitParams holds unit parameters used to update a unit. 474 type ApplicationUnitParams struct { 475 ProviderId string `json:"provider-id"` 476 UnitTag string `json:"unit-tag"` 477 Address string `json:"address"` 478 Ports []string `json:"ports"` 479 Stateful bool `json:"stateful,omitempty"` 480 FilesystemInfo []KubernetesFilesystemInfo `json:"filesystem-info,omitempty"` 481 Status string `json:"status"` 482 Info string `json:"info"` 483 Data map[string]interface{} `json:"data,omitempty"` 484 } 485 486 // UpdateApplicationUnitResults holds results from UpdateApplicationUnits 487 type UpdateApplicationUnitResults struct { 488 Results []UpdateApplicationUnitResult `json:"results"` 489 } 490 491 // UpdateApplicationUnitResult holds a single result from UpdateApplicationUnits 492 type UpdateApplicationUnitResult struct { 493 Info *UpdateApplicationUnitsInfo `json:"info,omitempty"` 494 Error *Error `json:"error,omitempty"` 495 } 496 497 // UpdateApplicationUnitsInfo holds info about the application units after a call to 498 // UpdateApplicationUnits 499 type UpdateApplicationUnitsInfo struct { 500 Units []ApplicationUnitInfo `json:"units"` 501 } 502 503 // ApplicationUnitInfo holds info about the unit in the application. 504 type ApplicationUnitInfo struct { 505 ProviderId string `json:"provider-id"` 506 UnitTag string `json:"unit-tag"` 507 } 508 509 // ApplicationMergeBindingsArgs holds the parameters for updating application 510 // bindings. 511 type ApplicationMergeBindingsArgs struct { 512 Args []ApplicationMergeBindings `json:"args"` 513 } 514 515 // ApplicationMergeBindings holds a list of operator-defined bindings to be 516 // merged with the current application bindings. 517 type ApplicationMergeBindings struct { 518 ApplicationTag string `json:"application-tag"` 519 Bindings map[string]string `json:"bindings"` 520 Force bool `json:"force"` 521 } 522 523 // DestroyUnitsParamsV15 holds bulk parameters for the Application.DestroyUnit call. 524 type DestroyUnitsParamsV15 struct { 525 Units []DestroyUnitParamsV15 `json:"units"` 526 } 527 528 // DestroyUnitParams holds parameters for the Application.DestroyUnit call. 529 type DestroyUnitParamsV15 struct { 530 // UnitTag holds the tag of the unit to destroy. 531 UnitTag string `json:"unit-tag"` 532 533 // DestroyStorage controls whether or not storage 534 // attached to the unit should be destroyed. 535 DestroyStorage bool `json:"destroy-storage,omitempty"` 536 537 // Force controls whether or not the destruction of an application 538 // will be forced, i.e. ignore operational errors. 539 Force bool `json:"force"` 540 541 // MaxWait specifies the amount of time that each step in unit removal 542 // will wait before forcing the next step to kick-off. This parameter 543 // only makes sense in combination with 'force' set to 'true'. 544 MaxWait *time.Duration `json:"max-wait,omitempty"` 545 } 546 547 // DestroyApplicationUnits holds parameters for the deprecated 548 // Application.DestroyUnits call. 549 type DestroyApplicationUnits struct { 550 UnitNames []string `json:"unit-names"` 551 } 552 553 // DestroyUnitsParams holds bulk parameters for the Application.DestroyUnit call. 554 type DestroyUnitsParams struct { 555 Units []DestroyUnitParams `json:"units"` 556 } 557 558 // DestroyUnitParams holds parameters for the Application.DestroyUnit call. 559 type DestroyUnitParams struct { 560 // UnitTag holds the tag of the unit to destroy. 561 UnitTag string `json:"unit-tag"` 562 563 // DestroyStorage controls whether or not storage 564 // attached to the unit should be destroyed. 565 DestroyStorage bool `json:"destroy-storage,omitempty"` 566 567 // Force controls whether or not the destruction of an application 568 // will be forced, i.e. ignore operational errors. 569 Force bool `json:"force,omitempty"` 570 571 // MaxWait specifies the amount of time that each step in unit removal 572 // will wait before forcing the next step to kick-off. This parameter 573 // only makes sense in combination with 'force' set to 'true'. 574 MaxWait *time.Duration `json:"max-wait,omitempty"` 575 576 // DryRun specifies whether to perform the destroy action or 577 // just return what this action will destroy 578 DryRun bool `json:"dry-run,omitempty"` 579 } 580 581 // Creds holds credentials for identifying an entity. 582 type Creds struct { 583 AuthTag string `json:"auth-tag"` 584 Password string `json:"password"` 585 Nonce string `json:"nonce"` 586 } 587 588 // LoginRequest holds credentials for identifying an entity to the Login v1 589 // facade. AuthTag holds the tag of the user to connect as. If it is empty, 590 // then the provided macaroon slices will be used for authentication (if 591 // any one is valid, the authentication succeeds). If there are no 592 // valid macaroons and macaroon authentication is configured, 593 // the LoginResult will contain a macaroon that when 594 // discharged, may allow access. 595 type LoginRequest struct { 596 AuthTag string `json:"auth-tag"` 597 Credentials string `json:"credentials"` 598 Nonce string `json:"nonce"` 599 Macaroons []macaroon.Slice `json:"macaroons"` 600 BakeryVersion bakery.Version `json:"bakery-version,omitempty"` 601 Token string `json:"token,omitempty"` 602 CLIArgs string `json:"cli-args,omitempty"` 603 UserData string `json:"user-data"` 604 ClientVersion string `json:"client-version,omitempty"` 605 } 606 607 // LoginRequestCompat holds credentials for identifying an entity to the Login v1 608 // or earlier (v0 or even pre-facade). 609 type LoginRequestCompat struct { 610 LoginRequest `json:"login-request"` 611 Creds `json:"creds"` 612 } 613 614 // GetAnnotationsResults holds annotations associated with an entity. 615 type GetAnnotationsResults struct { 616 Annotations map[string]string `json:"annotations"` 617 } 618 619 // GetAnnotations stores parameters for making the GetAnnotations call. 620 type GetAnnotations struct { 621 Tag string `json:"tag"` 622 } 623 624 // SetAnnotations stores parameters for making the SetAnnotations call. 625 type SetAnnotations struct { 626 Tag string `json:"tag"` 627 Pairs map[string]string `json:"annotations"` 628 } 629 630 // GetConstraintsResults holds results of the GetConstraints call. 631 type GetConstraintsResults struct { 632 Constraints constraints.Value `json:"constraints"` 633 } 634 635 // SetConstraints stores parameters for making the SetConstraints call. 636 type SetConstraints struct { 637 ApplicationName string `json:"application"` //optional, if empty, model constraints are set. 638 Constraints constraints.Value `json:"constraints"` 639 } 640 641 // ResolveCharms stores charm references for a ResolveCharms call. 642 type ResolveCharms struct { 643 References []string `json:"references"` 644 } 645 646 // ResolveCharmResult holds the result of resolving a charm reference to a URL, or any error that occurred. 647 type ResolveCharmResult struct { 648 // URL is a string representation of charm.URL. 649 URL string `json:"url,omitempty"` 650 Error string `json:"error,omitempty"` 651 } 652 653 // ResolveCharmResults holds results of the ResolveCharms call. 654 type ResolveCharmResults struct { 655 URLs []ResolveCharmResult `json:"urls"` 656 } 657 658 // ResolveCharmWithChannel contains a charm reference with the desired 659 // channel to be resolved. 660 type ResolveCharmWithChannel struct { 661 Reference string `json:"reference"` 662 Origin CharmOrigin `json:"charm-origin"` 663 664 // SwitchCharm is set to true when the purpose of this resolve request 665 // is to switch a different charm (potentially from a different store). 666 SwitchCharm bool `json:"switch-charm,omitempty"` 667 } 668 669 // ResolveCharmsWithChannel contains of slice of data on charms to be 670 // resolved. 671 type ResolveCharmsWithChannel struct { 672 Resolve []ResolveCharmWithChannel `json:"resolve"` 673 Macaroon *macaroon.Macaroon `json:"macaroon,omitempty"` 674 } 675 676 // ResolveCharmWithChannelResult is the result of a single charm resolution. 677 type ResolveCharmWithChannelResult struct { 678 URL string `json:"url"` 679 Origin CharmOrigin `json:"charm-origin"` 680 SupportedBases []Base `json:"supported-bases"` 681 Error *Error `json:"error,omitempty"` 682 } 683 684 // ResolveCharmWithChannelResults holds the results of ResolveCharmsWithChannel. 685 type ResolveCharmWithChannelResults struct { 686 Results []ResolveCharmWithChannelResult 687 } 688 689 // ResolveCharmWithChannelResult is the result of a single charm resolution. 690 type ResolveCharmWithChannelResultV6 struct { 691 URL string `json:"url"` 692 Origin CharmOrigin `json:"charm-origin"` 693 SupportedSeries []string `json:"supported-series"` 694 Error *Error `json:"error,omitempty"` 695 } 696 697 // ResolveCharmWithChannelResults holds the results of ResolveCharmsWithChannel. 698 type ResolveCharmWithChannelResultsV6 struct { 699 Results []ResolveCharmWithChannelResultV6 700 } 701 702 // CharmURLAndOrigins contains a slice of charm urls with a given origin. 703 type CharmURLAndOrigins struct { 704 Entities []CharmURLAndOrigin `json:"entities"` 705 } 706 707 // CharmURLAndOrigin holds the information for selecting one bundle 708 type CharmURLAndOrigin struct { 709 CharmURL string `json:"charm-url"` 710 Origin CharmOrigin `json:"charm-origin"` 711 Macaroon *macaroon.Macaroon `json:"macaroon,omitempty"` 712 } 713 714 // DownloadInfoResults returns the download url for a given request. 715 type DownloadInfoResults struct { 716 Results []DownloadInfoResult `json:"results"` 717 } 718 719 // DownloadInfoResult returns a given bundle for a request. 720 type DownloadInfoResult struct { 721 URL string `json:"url"` 722 Origin CharmOrigin `json:"charm-origin"` 723 } 724 725 // AllWatcherId holds the id of an AllWatcher. 726 type AllWatcherId struct { 727 AllWatcherId string `json:"watcher-id"` 728 } 729 730 // AllWatcherNextResults holds deltas returned from calling AllWatcher.Next(). 731 type AllWatcherNextResults struct { 732 Deltas []Delta `json:"deltas"` 733 } 734 735 // ListSSHKeys stores parameters used for a KeyManager.ListKeys call. 736 type ListSSHKeys struct { 737 Entities `json:"entities"` 738 Mode ssh.ListMode `json:"mode"` 739 } 740 741 // ModifyUserSSHKeys stores parameters used for a KeyManager.Add|Delete|Import call for a user. 742 type ModifyUserSSHKeys struct { 743 User string `json:"user"` 744 Keys []string `json:"ssh-keys"` 745 } 746 747 // StateServingInfo holds information needed by a state 748 // server. 749 type StateServingInfo struct { 750 APIPort int `json:"api-port"` 751 ControllerAPIPort int `json:"controller-api-port,omitempty"` 752 StatePort int `json:"state-port"` 753 // The controller cert and corresponding private key. 754 Cert string `json:"cert"` 755 PrivateKey string `json:"private-key"` 756 // The private key for the CA cert so that a new controller 757 // cert can be generated when needed. 758 CAPrivateKey string `json:"ca-private-key"` 759 // this will be passed as the KeyFile argument to MongoDB 760 SharedSecret string `json:"shared-secret"` 761 SystemIdentity string `json:"system-identity"` 762 } 763 764 // IsMasterResult holds the result of an IsMaster API call. 765 type IsMasterResult struct { 766 // Master reports whether the connected agent 767 // lives on the same instance as the mongo replica 768 // set master. 769 Master bool `json:"master"` 770 } 771 772 // ContainerManagerConfigParams contains the parameters for the 773 // ContainerManagerConfig provisioner API call. 774 type ContainerManagerConfigParams struct { 775 Type instance.ContainerType `json:"type"` 776 } 777 778 // ContainerManagerConfig contains information from the model config 779 // that is needed for configuring the container manager. 780 type ContainerManagerConfig struct { 781 ManagerConfig map[string]string `json:"config"` 782 } 783 784 // UpdateBehavior contains settings that are duplicated in several 785 // places. Let's just embed this instead. 786 type UpdateBehavior struct { 787 EnableOSRefreshUpdate bool `json:"enable-os-refresh-update"` 788 EnableOSUpgrade bool `json:"enable-os-upgrade"` 789 } 790 791 // ContainerConfig contains information from the model config that is 792 // needed for container cloud-init. 793 type ContainerConfig struct { 794 ProviderType string `json:"provider-type"` 795 AuthorizedKeys string `json:"authorized-keys"` 796 SSLHostnameVerification bool `json:"ssl-hostname-verification"` 797 LegacyProxy proxy.Settings `json:"legacy-proxy"` 798 JujuProxy proxy.Settings `json:"juju-proxy"` 799 AptProxy proxy.Settings `json:"apt-proxy"` 800 SnapProxy proxy.Settings `json:"snap-proxy"` 801 SnapStoreAssertions string `json:"snap-store-assertions"` 802 SnapStoreProxyID string `json:"snap-store-proxy-id"` 803 SnapStoreProxyURL string `json:"snap-store-proxy-url"` 804 AptMirror string `json:"apt-mirror,omitempty"` 805 CloudInitUserData map[string]interface{} `json:"cloudinit-userdata,omitempty"` 806 ContainerInheritProperties string `json:"container-inherit-properties,omitempty"` 807 *UpdateBehavior 808 } 809 810 // ProvisioningScriptParams contains the parameters for the 811 // ProvisioningScript client API call. 812 type ProvisioningScriptParams struct { 813 MachineId string `json:"machine-id"` 814 Nonce string `json:"nonce"` 815 816 // DataDir may be "", in which case the default will be used. 817 DataDir string `json:"data-dir"` 818 819 // DisablePackageCommands may be set to disable all 820 // package-related commands. It is then the responsibility of the 821 // provisioner to ensure that all the packages required by Juju 822 // are available. 823 DisablePackageCommands bool `json:"disable-package-commands"` 824 } 825 826 // ProvisioningScriptResult contains the result of the 827 // ProvisioningScript client API call. 828 type ProvisioningScriptResult struct { 829 Script string `json:"script"` 830 } 831 832 // DeployerConnectionValues containers the result of deployer.ConnectionInfo 833 // API call. 834 type DeployerConnectionValues struct { 835 APIAddresses []string `json:"api-addresses"` 836 } 837 838 // JobsResult holds the jobs for a machine that are returned by a call to Jobs. 839 type JobsResult struct { 840 Jobs []model.MachineJob `json:"jobs"` 841 Error *Error `json:"error,omitempty"` 842 } 843 844 // JobsResults holds the result of a call to Jobs. 845 type JobsResults struct { 846 Results []JobsResult `json:"results"` 847 } 848 849 // DistributionGroupResult contains the result of 850 // the DistributionGroup provisioner API call. 851 type DistributionGroupResult struct { 852 Error *Error `json:"error,omitempty"` 853 Result []instance.Id `json:"result"` 854 } 855 856 // DistributionGroupResults is the bulk form of 857 // DistributionGroupResult. 858 type DistributionGroupResults struct { 859 Results []DistributionGroupResult `json:"results"` 860 } 861 862 // FacadeVersions describes the available Facades and what versions of each one 863 // are available 864 type FacadeVersions struct { 865 Name string `json:"name"` 866 Versions []int `json:"versions"` 867 } 868 869 // RedirectInfoResult holds the result of a RedirectInfo call. 870 type RedirectInfoResult struct { 871 // Servers holds an entry for each server that holds the 872 // addresses for the server. 873 Servers [][]HostPort `json:"servers"` 874 875 // CACert holds the CA certificate for the server. 876 // TODO(rogpeppe) allow this to be empty if the 877 // server has a globally trusted certificate? 878 CACert string `json:"ca-cert"` 879 } 880 881 // ReauthRequest holds a challenge/response token meaningful to the identity 882 // provider. 883 type ReauthRequest struct { 884 Prompt string `json:"prompt"` 885 Nonce string `json:"nonce"` 886 } 887 888 // AuthUserInfo describes a logged-in local user or remote identity. 889 type AuthUserInfo struct { 890 DisplayName string `json:"display-name"` 891 Identity string `json:"identity"` 892 LastConnection *time.Time `json:"last-connection,omitempty"` 893 894 // Credentials contains an optional opaque credential value to be held by 895 // the client, if any. 896 Credentials *string `json:"credentials,omitempty"` 897 898 // ControllerAccess holds the access the user has to the connected controller. 899 // It will be empty if the user has no access to the controller. 900 ControllerAccess string `json:"controller-access"` 901 902 // ModelAccess holds the access the user has to the connected model. 903 ModelAccess string `json:"model-access"` 904 } 905 906 // LoginResult holds the result of an Admin Login call. 907 type LoginResult struct { 908 // DischargeRequired implies that the login request has failed, and none of 909 // the other fields are populated. It contains a macaroon which, when 910 // discharged, will grant access on a subsequent call to Login. 911 // Note: It is OK to use the Macaroon type here as it is explicitly 912 // designed to provide stable serialisation of macaroons. It's good 913 // practice to only use primitives in types that will be serialised, 914 // however because of the above it is suitable to use the Macaroon type 915 // here. 916 DischargeRequired *macaroon.Macaroon `json:"discharge-required,omitempty"` 917 918 // BakeryDischargeRequired implies that the login request has failed, and none of 919 // the other fields are populated. It contains a macaroon which, when 920 // discharged, will grant access on a subsequent call to Login. 921 // Note: It is OK to use the Macaroon type here as it is explicitly 922 // designed to provide stable serialisation of macaroons. It's good 923 // practice to only use primitives in types that will be serialised, 924 // however because of the above it is suitable to use the Macaroon type 925 // here. 926 // This is the macaroon emitted by newer Juju controllers using bakery.v2. 927 BakeryDischargeRequired *bakery.Macaroon `json:"bakery-discharge-required,omitempty"` 928 929 // DischargeRequiredReason holds the reason that the above discharge was 930 // required. 931 DischargeRequiredReason string `json:"discharge-required-error,omitempty"` 932 933 // Servers is the list of API server addresses. 934 Servers [][]HostPort `json:"servers,omitempty"` 935 936 // PublicDNSName holds the host name for which an officially 937 // signed certificate will be used for TLS connection to the server. 938 // If empty, the private Juju CA certificate must be used to verify 939 // the connection. 940 PublicDNSName string `json:"public-dns-name,omitempty"` 941 942 // ModelTag is the tag for the model that is being connected to. 943 ModelTag string `json:"model-tag,omitempty"` 944 945 // ControllerTag is the tag for the controller that runs the API servers. 946 ControllerTag string `json:"controller-tag,omitempty"` 947 948 // UserInfo describes the authenticated user, if any. 949 UserInfo *AuthUserInfo `json:"user-info,omitempty"` 950 951 // Facades describes all the available API facade versions to the 952 // authenticated client. 953 Facades []FacadeVersions `json:"facades,omitempty"` 954 955 // ServerVersion is the string representation of the server version 956 // if the server supports it. 957 ServerVersion string `json:"server-version,omitempty"` 958 } 959 960 // ControllersSpec contains arguments for 961 // the EnableHA client API call. 962 type ControllersSpec struct { 963 NumControllers int `json:"num-controllers"` 964 Constraints constraints.Value `json:"constraints,omitempty"` 965 // Placement defines specific machines to become new controller machines. 966 Placement []string `json:"placement,omitempty"` 967 } 968 969 // ControllersSpecs contains all the arguments 970 // for the EnableHA API call. 971 type ControllersSpecs struct { 972 Specs []ControllersSpec `json:"specs"` 973 } 974 975 // ControllersChangeResult contains the results 976 // of a single EnableHA API call or 977 // an error. 978 type ControllersChangeResult struct { 979 Result ControllersChanges `json:"result"` 980 Error *Error `json:"error,omitempty"` 981 } 982 983 // ControllersChangeResults contains the results 984 // of the EnableHA API call. 985 type ControllersChangeResults struct { 986 Results []ControllersChangeResult `json:"results"` 987 } 988 989 // ControllersChanges lists the servers 990 // that have been added, removed or maintained in the 991 // pool as a result of an enable-ha operation. 992 type ControllersChanges struct { 993 Added []string `json:"added,omitempty"` 994 Maintained []string `json:"maintained,omitempty"` 995 Removed []string `json:"removed,omitempty"` 996 Converted []string `json:"converted,omitempty"` 997 } 998 999 // FindToolsParams defines parameters for the FindTools method. 1000 type FindToolsParams struct { 1001 // Number will be used to match tools versions exactly if non-zero. 1002 Number version.Number `json:"number"` 1003 1004 // MajorVersion will be used to match the major version if non-zero. 1005 // TODO(juju 3.1) - remove 1006 MajorVersion int `json:"major"` 1007 1008 // Arch will be used to match tools by architecture if non-empty. 1009 Arch string `json:"arch"` 1010 1011 // OSType will be used to match tools by os type if non-empty. 1012 OSType string `json:"os-type"` 1013 1014 // AgentStream will be used to set agent stream to search 1015 AgentStream string `json:"agentstream"` 1016 } 1017 1018 // FindToolsResult holds a list of tools from FindTools and any error. 1019 type FindToolsResult struct { 1020 List tools.List `json:"list"` 1021 Error *Error `json:"error,omitempty"` 1022 } 1023 1024 // RebootActionResults holds a list of RebootActionResult and any error. 1025 type RebootActionResults struct { 1026 Results []RebootActionResult `json:"results,omitempty"` 1027 } 1028 1029 // RebootActionResult holds the result of a single call to 1030 // machine.ShouldRebootOrShutdown. 1031 type RebootActionResult struct { 1032 Result RebootAction `json:"result,omitempty"` 1033 Error *Error `json:"error,omitempty"` 1034 } 1035 1036 // LogRecord is used to transmit log messages to the logsink API 1037 // endpoint. Single character field names are used for serialisation 1038 // to keep the size down. These messages are going to be sent a lot. 1039 type LogRecord struct { 1040 Time time.Time `json:"t"` 1041 Module string `json:"m"` 1042 Location string `json:"l"` 1043 Level string `json:"v"` 1044 Message string `json:"x"` 1045 Entity string `json:"e,omitempty"` 1046 Labels []string `json:"c,omitempty"` 1047 } 1048 1049 // PubSubMessage is used to propagate pubsub messages from one api server to the 1050 // others. 1051 type PubSubMessage struct { 1052 Topic string `json:"topic"` 1053 Data map[string]interface{} `json:"data"` 1054 } 1055 1056 // LeaseOperations is used to send raft operational messages between controllers. 1057 type LeaseOperations struct { 1058 Operations []LeaseOperation `json:"commands"` 1059 } 1060 1061 // LeaseOperation is used to send raft operational messages between controllers. 1062 type LeaseOperation struct { 1063 Command string `json:"command"` 1064 } 1065 1066 // LeaseOperationsV2 is used to send raft operational messages between 1067 // controllers. 1068 type LeaseOperationsV2 struct { 1069 Operations []LeaseOperationCommand `json:"commands"` 1070 } 1071 1072 // LeaseOperationCommand is used to send raft operational messages between 1073 // controllers. 1074 type LeaseOperationCommand struct { 1075 // Version of the command format in case it changes, 1076 // and we need to handle multiple formats. 1077 Version int `json:"version"` 1078 1079 // Operation is one of claim, extend, expire or setTime. 1080 Operation string `json:"operation"` 1081 1082 // Namespace is the kind of lease. 1083 Namespace string `json:"namespace,omitempty"` 1084 1085 // ModelUUID identifies the model the lease belongs to. 1086 ModelUUID string `json:"model-uuid,omitempty"` 1087 1088 // Lease is the name of the lease the command affects. 1089 Lease string `json:"lease,omitempty"` 1090 1091 // Holder is the name of the party claiming or extending the 1092 // lease. 1093 Holder string `json:"holder,omitempty"` 1094 1095 // Duration is how long the lease should last. 1096 Duration time.Duration `json:"duration,omitempty"` 1097 1098 // OldTime is the previous time for time updates (to avoid 1099 // applying stale ones). 1100 OldTime time.Time `json:"old-time,omitempty"` 1101 1102 // NewTime is the time to store as the global time. 1103 NewTime time.Time `json:"new-time,omitempty"` 1104 1105 // PinEntity is a tag representing an entity concerned 1106 // with a pin or unpin operation. 1107 PinEntity string `json:"pin-entity,omitempty"` 1108 } 1109 1110 // ExportBundleParams holds parameters for exporting Bundles. 1111 type ExportBundleParams struct { 1112 IncludeCharmDefaults bool `json:"include-charm-defaults,omitempty"` 1113 IncludeSeries bool `json:"include-series,omitempty"` 1114 } 1115 1116 // BundleChangesParams holds parameters for making Bundle.GetChanges calls. 1117 type BundleChangesParams struct { 1118 // BundleDataYAML is the YAML-encoded charm bundle data 1119 // (see "github.com/juju/charm.BundleData"). 1120 BundleDataYAML string `json:"yaml"` 1121 BundleURL string `json:"bundleURL"` 1122 } 1123 1124 // BundleChangesResults holds results of the Bundle.GetChanges call. 1125 type BundleChangesResults struct { 1126 // Changes holds the list of changes required to deploy the bundle. 1127 // It is omitted if the provided bundle YAML has verification errors. 1128 Changes []*BundleChange `json:"changes,omitempty"` 1129 // Errors holds possible bundle verification errors. 1130 Errors []string `json:"errors,omitempty"` 1131 } 1132 1133 // BundleChange holds a single change required to deploy a bundle. 1134 type BundleChange struct { 1135 // Id is the unique identifier for this change. 1136 Id string `json:"id"` 1137 // Method is the action to be performed to apply this change. 1138 Method string `json:"method"` 1139 // Args holds a list of arguments to pass to the method. 1140 Args []interface{} `json:"args"` 1141 // Requires holds a list of dependencies for this change. Each dependency 1142 // is represented by the corresponding change id, and must be applied 1143 // before this change is applied. 1144 Requires []string `json:"requires"` 1145 } 1146 1147 // BundleChangesMapArgsResults holds results of the Bundle.GetChanges call. 1148 type BundleChangesMapArgsResults struct { 1149 // Changes holds the list of changes required to deploy the bundle. 1150 // It is omitted if the provided bundle YAML has verification errors. 1151 Changes []*BundleChangesMapArgs `json:"changes,omitempty"` 1152 // Errors holds possible bundle verification errors. 1153 Errors []string `json:"errors,omitempty"` 1154 } 1155 1156 // BundleChangesMapArgs holds a single change required to deploy a bundle. 1157 // BundleChangesMapArgs has Args represented as a map of arguments rather 1158 // than a series. 1159 type BundleChangesMapArgs struct { 1160 // Id is the unique identifier for this change. 1161 Id string `json:"id"` 1162 // Method is the action to be performed to apply this change. 1163 Method string `json:"method"` 1164 // Args holds a list of arguments to pass to the method. 1165 Args map[string]interface{} `json:"args"` 1166 // Requires holds a list of dependencies for this change. Each dependency 1167 // is represented by the corresponding change id, and must be applied 1168 // before this change is applied. 1169 Requires []string `json:"requires"` 1170 } 1171 1172 type MongoVersion struct { 1173 Major int `json:"major"` 1174 Minor int `json:"minor"` 1175 Patch string `json:"patch"` 1176 StorageEngine string `json:"engine"` 1177 } 1178 1179 // MeterStatusParam holds meter status information to be set for the specified tag. 1180 type MeterStatusParam struct { 1181 Tag string `json:"tag"` 1182 Code string `json:"code"` 1183 Info string `json:"info,omitempty"` 1184 } 1185 1186 // MeterStatusParams holds parameters for making SetMeterStatus calls. 1187 type MeterStatusParams struct { 1188 Statuses []MeterStatusParam `json:"statues"` 1189 } 1190 1191 // MacaroonResults contains a set of MacaroonResults. 1192 type MacaroonResults struct { 1193 Results []MacaroonResult `json:"results"` 1194 } 1195 1196 // MacaroonResult contains a macaroon or an error. 1197 type MacaroonResult struct { 1198 Result *macaroon.Macaroon `json:"result,omitempty"` 1199 Error *Error `json:"error,omitempty"` 1200 } 1201 1202 // DestroyMachineResults contains the results of a MachineManager.Destroy 1203 // API request. 1204 type DestroyMachineResults struct { 1205 Results []DestroyMachineResult `json:"results,omitempty"` 1206 } 1207 1208 // DestroyMachineResult contains one of the results of a MachineManager.Destroy 1209 // API request. 1210 type DestroyMachineResult struct { 1211 Error *Error `json:"error,omitempty"` 1212 Info *DestroyMachineInfo `json:"info,omitempty"` 1213 } 1214 1215 // DestroyMachineInfo contains information related to the removal of 1216 // a machine. 1217 type DestroyMachineInfo struct { 1218 // MachineId is the ID if the machine that will be destroyed 1219 MachineId string `json:"machine-id"` 1220 1221 // DetachedStorage is the tags of storage instances that will be 1222 // detached from the machine (assigned units) as a result of 1223 // destroying the machine, and will remain in the model after 1224 // the machine and unit are removed. 1225 DetachedStorage []Entity `json:"detached-storage,omitempty"` 1226 1227 // DestroyedStorage is the tags of storage instances that will be 1228 // destroyed as a result of destroying the machine. 1229 DestroyedStorage []Entity `json:"destroyed-storage,omitempty"` 1230 1231 // DestroyedUnits are the tags of units that will be destroyed 1232 // as a result of destroying the machine. 1233 DestroyedUnits []Entity `json:"destroyed-units,omitempty"` 1234 1235 // DestroyedContainers are the results of the destroyed containers hosted 1236 // on a machine, destroyed as a result of destroying the machine 1237 DestroyedContainers []DestroyMachineResult `json:"destroyed-containers,omitempty"` 1238 } 1239 1240 // DestroyUnitResults contains the results of a DestroyUnit API request. 1241 type DestroyUnitResults struct { 1242 Results []DestroyUnitResult `json:"results,omitempty"` 1243 } 1244 1245 // DestroyUnitResult contains one of the results of a 1246 // DestroyUnit API request. 1247 type DestroyUnitResult struct { 1248 Error *Error `json:"error,omitempty"` 1249 Info *DestroyUnitInfo `json:"info,omitempty"` 1250 } 1251 1252 // DestroyUnitInfo contains information related to the removal of 1253 // an application unit. 1254 type DestroyUnitInfo struct { 1255 // DetachedStorage is the tags of storage instances that will be 1256 // detached from the unit, and will remain in the model after 1257 // the unit is removed. 1258 DetachedStorage []Entity `json:"detached-storage,omitempty"` 1259 1260 // DestroyedStorage is the tags of storage instances that will be 1261 // destroyed as a result of destroying the unit. 1262 DestroyedStorage []Entity `json:"destroyed-storage,omitempty"` 1263 } 1264 1265 // DumpModelRequest wraps the request for a dump-model call. 1266 // A simplified dump will not contain a complete export, but instead 1267 // a reduced set that is determined by the server. 1268 type DumpModelRequest struct { 1269 Entities []Entity `json:"entities"` 1270 Simplified bool `json:"simplified"` 1271 } 1272 1273 // UpgradeSeriesStatusResult contains the upgrade series status result for an upgrading 1274 // machine or unit 1275 type UpgradeSeriesStatusResult struct { 1276 Error *Error `json:"error,omitempty"` 1277 Status model.UpgradeSeriesStatus `json:"status,omitempty"` 1278 Target string `json:"target,omitempty"` 1279 } 1280 1281 // UpgradeSeriesStatusResults contains the upgrade series status results for 1282 // upgrading machines or units. 1283 type UpgradeSeriesStatusResults struct { 1284 Results []UpgradeSeriesStatusResult `json:"results,omitempty"` 1285 } 1286 1287 // UpgradeSeriesStatusParams contains the entities and desired statuses for 1288 // those entities. 1289 type UpgradeSeriesStatusParams struct { 1290 Params []UpgradeSeriesStatusParam `json:"params"` 1291 } 1292 1293 // UpgradeSeriesStatusParam contains the entity and desired status for that 1294 // entity along with a context message describing why the change to the status 1295 // is being requested. 1296 type UpgradeSeriesStatusParam struct { 1297 Entity Entity `json:"entity"` 1298 Status model.UpgradeSeriesStatus `json:"status"` 1299 Message string `json:"message"` 1300 } 1301 1302 // UpgradeSeriesStartUnitCompletionParam contains entities and a context message. 1303 type UpgradeSeriesStartUnitCompletionParam struct { 1304 Entities []Entity `json:"entities"` 1305 Message string `json:"message"` 1306 } 1307 1308 type UpgradeSeriesNotificationParams struct { 1309 Params []UpgradeSeriesNotificationParam `json:"params"` 1310 } 1311 1312 type UpgradeSeriesNotificationParam struct { 1313 Entity Entity `json:"entity"` 1314 WatcherId string `json:"watcher-id"` 1315 } 1316 1317 // UpgradeSeriesUnitsResults contains the units affected by a series per 1318 // machine entity. 1319 type UpgradeSeriesUnitsResults struct { 1320 Results []UpgradeSeriesUnitsResult 1321 } 1322 1323 // UpgradeSeriesUnitsResult contains the units affected by a series for 1324 // a given machine. 1325 type UpgradeSeriesUnitsResult struct { 1326 Error *Error `json:"error,omitempty"` 1327 UnitNames []string `json:"unit-names"` 1328 } 1329 1330 type UpgradeSeriesValidationErrorInfo struct { 1331 Status string 1332 } 1333 1334 // AsMap encodes the error info as a map that can be attached to an Error. 1335 func (e UpgradeSeriesValidationErrorInfo) AsMap() map[string]interface{} { 1336 return serializeToMap(e) 1337 } 1338 1339 type ProfileArg struct { 1340 Entity Entity `json:"entity"` 1341 UnitName string `json:"unit-name"` 1342 } 1343 1344 type ProfileArgs struct { 1345 Args []ProfileArg `json:"args"` 1346 } 1347 1348 type ProfileInfoResult struct { 1349 ApplicationName string `json:"application-name,omitempty"` 1350 Revision int `json:"revision,omitempty"` 1351 Profile *CharmLXDProfile `json:"profile,omitempty"` 1352 Error *Error `json:"error,omitempty"` 1353 } 1354 1355 type ProfileChangeResult struct { 1356 OldProfileName string `json:"old-profile-name,omitempty"` 1357 NewProfileName string `json:"new-profile-name,omitempty"` 1358 Profile *CharmLXDProfile `json:"profile,omitempty"` 1359 Subordinate bool `json:"subordinate,omitempty"` 1360 Error *Error `json:"error,omitempty"` 1361 } 1362 1363 type ProfileChangeResults struct { 1364 Results []ProfileChangeResult `json:"results"` 1365 } 1366 1367 type SetProfileArgs struct { 1368 Args []SetProfileArg `json:"args"` 1369 } 1370 1371 type SetProfileArg struct { 1372 Entity Entity `json:"entity"` 1373 Profiles []string `json:"profiles"` 1374 } 1375 1376 type SetProfileUpgradeCompleteArgs struct { 1377 Args []SetProfileUpgradeCompleteArg `json:"args"` 1378 } 1379 1380 type SetProfileUpgradeCompleteArg struct { 1381 Entity Entity `json:"entity"` 1382 UnitName string `json:"unit-name"` 1383 Message string `json:"message"` 1384 } 1385 1386 // BranchArg represents an in-flight branch via its model and branch name. 1387 type BranchArg struct { 1388 BranchName string `json:"branch"` 1389 } 1390 1391 // GenerationId represents an GenerationId from a branch. 1392 type GenerationId struct { 1393 GenerationId int `json:"generation-id"` 1394 } 1395 1396 // BranchInfoArgs transports arguments to the BranchInfo method 1397 type BranchInfoArgs struct { 1398 // BranchNames is the names of branches for which info is being requested. 1399 BranchNames []string `json:"branches"` 1400 1401 // Detailed indicates whether full unit tracking detail should returned, 1402 // or a summary. 1403 Detailed bool `json:"detailed"` 1404 } 1405 1406 // BranchTrackArg identifies an in-flight branch and a collection of 1407 // entities that should be set to track changes made under the branch. 1408 type BranchTrackArg struct { 1409 BranchName string `json:"branch"` 1410 Entities []Entity `json:"entities"` 1411 NumUnits int `json:"num-units,omitempty"` 1412 } 1413 1414 // GenerationApplication represents changes to an application 1415 // made under a branch. 1416 type GenerationApplication struct { 1417 // ApplicationsName is the name of the application. 1418 ApplicationName string `json:"application"` 1419 1420 // UnitProgress is summary information about units tracking the branch. 1421 UnitProgress string `json:"progress"` 1422 1423 // UnitsTracking is the names of application units that have been set to 1424 // track the branch. 1425 UnitsTracking []string `json:"tracking,omitempty"` 1426 1427 // UnitsPending is the names of application units that are still tracking 1428 // the master generation. 1429 UnitsPending []string `json:"pending,omitempty"` 1430 1431 // Config changes are the effective new configuration values resulting from 1432 // changes made under this branch. 1433 ConfigChanges map[string]interface{} `json:"config"` 1434 } 1435 1436 // Generation represents a model generation's details including config changes. 1437 type Generation struct { 1438 // BranchName uniquely identifies a branch *amongst in-flight branches*. 1439 BranchName string `json:"branch"` 1440 1441 // Created is the Unix timestamp at generation creation. 1442 Created int64 `json:"created"` 1443 1444 // Created is the user who created the generation. 1445 CreatedBy string `json:"created-by"` 1446 1447 // Completed is the Unix timestamp at generation completion/commit. 1448 Completed int64 `json:"completed,omitempty"` 1449 1450 // CompletedBy is the user who committed/completed the generation. 1451 CompletedBy string `json:"completed-by,omitempty"` 1452 1453 // GenerationId is the id . 1454 GenerationId int `json:"generation-id,omitempty"` 1455 1456 // Applications holds the collection of application changes 1457 // made under this generation. 1458 Applications []GenerationApplication `json:"applications"` 1459 } 1460 1461 // BranchResults transports a collection of generation details. 1462 type BranchResults struct { 1463 // Generations holds the details of the requested generations. 1464 Generations []Generation `json:"generations"` 1465 1466 // Error holds the value of any error that occurred processing the request. 1467 Error *Error `json:"error,omitempty"` 1468 } 1469 1470 // GenerationResult transports a generation detail. 1471 type GenerationResult struct { 1472 // Generation holds the details of the requested generation. 1473 Generation Generation `json:"generation"` 1474 1475 // Error holds the value of any error that occurred processing the request. 1476 Error *Error `json:"error,omitempty"` 1477 } 1478 1479 // CharmProfilingInfoResult contains the result based on ProfileInfoArg values 1480 // to update profiles on a machine. 1481 type CharmProfilingInfoResult struct { 1482 InstanceId instance.Id `json:"instance-id"` 1483 ModelName string `json:"model-name"` 1484 ProfileChanges []ProfileInfoResult `json:"profile-changes"` 1485 CurrentProfiles []string `json:"current-profiles"` 1486 Error *Error `json:"error"` 1487 } 1488 1489 // WatchContainerStartArg contains arguments for watching for container start 1490 // events on a CAAS application. 1491 type WatchContainerStartArg struct { 1492 Entity Entity `json:"entity"` 1493 Container string `json:"container,omitempty"` 1494 } 1495 1496 // WatchContainerStartArgs holds the details to watch many containers for start 1497 // events. 1498 type WatchContainerStartArgs struct { 1499 Args []WatchContainerStartArg `json:"args"` 1500 } 1501 1502 // CLICommands holds credentials, model and a list of CLI commands to run. 1503 type CLICommands struct { 1504 User string `json:"user"` 1505 Credentials string `json:"credentials,omitempty"` 1506 Macaroons []macaroon.Slice `json:"macaroons,omitempty"` 1507 1508 ActiveBranch string `json:"active-branch,omitempty"` 1509 Commands []string `json:"commands"` 1510 } 1511 1512 // CLICommandStatus represents a status update for a CLI command. 1513 type CLICommandStatus struct { 1514 Output []string `json:"output,omitempty"` 1515 Done bool `json:"done,omitempty"` 1516 Error *Error `json:"error,omitempty"` 1517 }