github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/rpc/params/storage.go (about) 1 // Copyright 2015 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/juju/core/life" 10 "github.com/juju/juju/storage" 11 ) 12 13 // MachineBlockDevices holds a machine tag and the block devices present 14 // on that machine. 15 type MachineBlockDevices struct { 16 Machine string `json:"machine"` 17 BlockDevices []storage.BlockDevice `json:"block-devices,omitempty"` 18 } 19 20 // SetMachineBlockDevices holds the arguments for recording the block 21 // devices present on a set of machines. 22 type SetMachineBlockDevices struct { 23 MachineBlockDevices []MachineBlockDevices `json:"machine-block-devices"` 24 } 25 26 // BlockDeviceResult holds the result of an API call to retrieve details 27 // of a block device. 28 type BlockDeviceResult struct { 29 Result storage.BlockDevice `json:"result"` 30 Error *Error `json:"error,omitempty"` 31 } 32 33 // BlockDeviceResults holds the result of an API call to retrieve details 34 // of multiple block devices. 35 type BlockDeviceResults struct { 36 Results []BlockDeviceResult `json:"results,omitempty"` 37 } 38 39 // BlockDevicesResult holds the result of an API call to retrieve details 40 // of all block devices relating to some entity. 41 type BlockDevicesResult struct { 42 Result []storage.BlockDevice `json:"result"` 43 Error *Error `json:"error,omitempty"` 44 } 45 46 // BlockDevicesResults holds the result of an API call to retrieve details 47 // of all block devices relating to some entities. 48 type BlockDevicesResults struct { 49 Results []BlockDevicesResult `json:"results,omitempty"` 50 } 51 52 // StorageInstance describes a storage instance. 53 type StorageInstance struct { 54 StorageTag string `json:"storage-tag"` 55 OwnerTag string `json:"owner-tag"` 56 Kind StorageKind `json:"kind"` 57 } 58 59 // StorageKind is the kind of a storage instance. 60 type StorageKind int 61 62 const ( 63 StorageKindUnknown StorageKind = iota 64 StorageKindBlock 65 StorageKindFilesystem 66 ) 67 68 // String returns representation of StorageKind for readability. 69 func (k *StorageKind) String() string { 70 switch *k { 71 case StorageKindBlock: 72 return "block" 73 case StorageKindFilesystem: 74 return "filesystem" 75 default: 76 return "unknown" 77 } 78 } 79 80 // StorageInstanceResult holds the result of an API call to retrieve details 81 // of a storage instance. 82 type StorageInstanceResult struct { 83 Result StorageInstance `json:"result"` 84 Error *Error `json:"error,omitempty"` 85 } 86 87 // StorageInstanceResults holds the result of an API call to retrieve details 88 // of multiple storage instances. 89 type StorageInstanceResults struct { 90 Results []StorageInstanceResult `json:"results,omitempty"` 91 } 92 93 // StorageAttachment describes a unit's attached storage instance. 94 type StorageAttachment struct { 95 StorageTag string `json:"storage-tag"` 96 OwnerTag string `json:"owner-tag"` 97 UnitTag string `json:"unit-tag"` 98 99 Kind StorageKind `json:"kind"` 100 Location string `json:"location"` 101 Life life.Value `json:"life"` 102 } 103 104 // StorageAttachmentId identifies a storage attachment by the tags of the 105 // related unit and storage instance. 106 type StorageAttachmentId struct { 107 StorageTag string `json:"storage-tag"` 108 UnitTag string `json:"unit-tag"` 109 } 110 111 // StorageAttachmentIds holds a set of storage attachment identifiers. 112 type StorageAttachmentIds struct { 113 Ids []StorageAttachmentId `json:"ids"` 114 } 115 116 type StorageDetachmentParams struct { 117 // StorageIds to detach 118 StorageIds StorageAttachmentIds `json:"ids"` 119 120 // Force specifies whether relation destruction will be forced, i.e. 121 // keep going despite operational errors. 122 Force *bool `json:"force,omitempty"` 123 124 // MaxWait specifies the amount of time that each step in relation destroy process 125 // will wait before forcing the next step to kick-off. This parameter 126 // only makes sense in combination with 'force' set to 'true'. 127 MaxWait *time.Duration `json:"max-wait,omitempty"` 128 } 129 130 // StorageAttachmentIdsResult holds the result of an API call to retrieve the 131 // IDs of a unit's attached storage instances. 132 type StorageAttachmentIdsResult struct { 133 Result StorageAttachmentIds `json:"result"` 134 Error *Error `json:"error,omitempty"` 135 } 136 137 // StorageAttachmentIdsResults holds the result of an API call to retrieve the 138 // IDs of multiple units attached storage instances. 139 type StorageAttachmentIdsResults struct { 140 Results []StorageAttachmentIdsResult `json:"results,omitempty"` 141 } 142 143 // StorageAttachmentsResult holds the result of an API call to retrieve details 144 // of a unit's attached storage instances. 145 type StorageAttachmentsResult struct { 146 Result []StorageAttachment `json:"result"` 147 Error *Error `json:"error,omitempty"` 148 } 149 150 // StorageAttachmentsResults holds the result of an API call to retrieve details 151 // of multiple units' attached storage instances. 152 type StorageAttachmentsResults struct { 153 Results []StorageAttachmentsResult `json:"results,omitempty"` 154 } 155 156 // StorageAttachmentResult holds the result of an API call to retrieve details 157 // of a storage attachment. 158 type StorageAttachmentResult struct { 159 Result StorageAttachment `json:"result"` 160 Error *Error `json:"error,omitempty"` 161 } 162 163 // StorageAttachmentResults holds the result of an API call to retrieve details 164 // of multiple storage attachments. 165 type StorageAttachmentResults struct { 166 Results []StorageAttachmentResult `json:"results,omitempty"` 167 } 168 169 // MachineStorageId identifies the attachment of a storage entity 170 // to a machine, by their tags. 171 type MachineStorageId struct { 172 MachineTag string `json:"machine-tag"` 173 // AttachmentTag is the tag of the volume or filesystem whose 174 // attachment to the machine is represented. 175 AttachmentTag string `json:"attachment-tag"` 176 } 177 178 // MachineStorageIds holds a set of machine/storage-entity 179 // attachment identifiers. 180 type MachineStorageIds struct { 181 Ids []MachineStorageId `json:"ids"` 182 } 183 184 // Volume identifies and describes a storage volume in the model. 185 type Volume struct { 186 VolumeTag string `json:"volume-tag"` 187 Info VolumeInfo `json:"info"` 188 } 189 190 // VolumeInfo describes a storage volume in the model. 191 type VolumeInfo struct { 192 VolumeId string `json:"volume-id"` 193 HardwareId string `json:"hardware-id,omitempty"` 194 WWN string `json:"wwn,omitempty"` 195 // Pool is the name of the storage pool used to 196 // allocate the volume. Juju controllers older 197 // than 2.2 do not populate this field, so it may 198 // be omitted. 199 Pool string `json:"pool,omitempty"` 200 // Size is the size of the volume in MiB. 201 Size uint64 `json:"size"` 202 Persistent bool `json:"persistent"` 203 } 204 205 // Volumes describes a set of storage volumes in the model. 206 type Volumes struct { 207 Volumes []Volume `json:"volumes"` 208 } 209 210 // VolumeAttachment identifies and describes a volume attachment. 211 type VolumeAttachment struct { 212 VolumeTag string `json:"volume-tag"` 213 MachineTag string `json:"machine-tag"` 214 Info VolumeAttachmentInfo `json:"info"` 215 } 216 217 // VolumeAttachmentPlan identifies and describes a volume attachment plan. 218 type VolumeAttachmentPlan struct { 219 VolumeTag string `json:"volume-tag"` 220 MachineTag string `json:"machine-tag"` 221 Life life.Value `json:"life,omitempty"` 222 PlanInfo VolumeAttachmentPlanInfo `json:"plan-info"` 223 // BlockDevice should only be set by machine agents after 224 // the AttachVolume() function is called. It represents the machines 225 // view of the block device represented by the plan. 226 BlockDevice storage.BlockDevice `json:"block-device,omitempty"` 227 } 228 229 type VolumeAttachmentPlans struct { 230 VolumeAttachmentPlans []VolumeAttachmentPlan `json:"volume-plans"` 231 } 232 233 // VolumeAttachmentPlanInfo describes info needed by machine agents 234 // to initialize attached volumes 235 type VolumeAttachmentPlanInfo struct { 236 DeviceType storage.DeviceType `json:"device-type,omitempty"` 237 DeviceAttributes map[string]string `json:"device-attributes,omitempty"` 238 } 239 240 // VolumeAttachmentInfo describes a volume attachment. 241 type VolumeAttachmentInfo struct { 242 DeviceName string `json:"device-name,omitempty"` 243 DeviceLink string `json:"device-link,omitempty"` 244 BusAddress string `json:"bus-address,omitempty"` 245 ReadOnly bool `json:"read-only,omitempty"` 246 PlanInfo *VolumeAttachmentPlanInfo `json:"plan-info,omitempty"` 247 } 248 249 // VolumeAttachments describes a set of storage volume attachments. 250 type VolumeAttachments struct { 251 VolumeAttachments []VolumeAttachment `json:"volume-attachments"` 252 } 253 254 // VolumeParams holds the parameters for creating a storage volume. 255 type VolumeParams struct { 256 VolumeTag string `json:"volume-tag"` 257 Size uint64 `json:"size"` 258 Provider string `json:"provider"` 259 Attributes map[string]interface{} `json:"attributes,omitempty"` 260 Tags map[string]string `json:"tags,omitempty"` 261 Attachment *VolumeAttachmentParams `json:"attachment,omitempty"` 262 } 263 264 // RemoveVolumeParams holds the parameters for destroying or releasing a 265 // storage volume. 266 type RemoveVolumeParams struct { 267 // Provider is the storage provider that manages the volume. 268 Provider string `json:"provider"` 269 270 // VolumeId is the storage provider's unique ID for the volume. 271 VolumeId string `json:"volume-id"` 272 273 // Destroy controls whether the volume should be completely 274 // destroyed, or otherwise merely released from Juju's management. 275 Destroy bool `json:"destroy,omitempty"` 276 } 277 278 // VolumeAttachmentParams holds the parameters for creating a volume 279 // attachment. 280 type VolumeAttachmentParams struct { 281 VolumeTag string `json:"volume-tag"` 282 MachineTag string `json:"machine-tag"` 283 VolumeId string `json:"volume-id,omitempty"` 284 InstanceId string `json:"instance-id,omitempty"` 285 Provider string `json:"provider"` 286 ReadOnly bool `json:"read-only,omitempty"` 287 } 288 289 // VolumeAttachmentsResult holds the volume attachments for a single 290 // machine, or an error. 291 type VolumeAttachmentsResult struct { 292 Attachments []VolumeAttachment `json:"attachments,omitempty"` 293 Error *Error `json:"error,omitempty"` 294 } 295 296 // VolumeAttachmentsResults holds a set of VolumeAttachmentsResults for 297 // a set of machines. 298 type VolumeAttachmentsResults struct { 299 Results []VolumeAttachmentsResult `json:"results,omitempty"` 300 } 301 302 // VolumeAttachmentResult holds the details of a single volume attachment, 303 // or an error. 304 type VolumeAttachmentResult struct { 305 Result VolumeAttachment `json:"result"` 306 Error *Error `json:"error,omitempty"` 307 } 308 309 // VolumeAttachmentResults holds a set of VolumeAttachmentResults. 310 type VolumeAttachmentResults struct { 311 Results []VolumeAttachmentResult `json:"results,omitempty"` 312 } 313 314 // VolumeAttachmentPlanResult holds the details of a single volume attachment plan, 315 // or an error. 316 type VolumeAttachmentPlanResult struct { 317 Result VolumeAttachmentPlan `json:"result"` 318 Error *Error `json:"error,omitempty"` 319 } 320 321 // VolumeAttachmentPlanResults holds a set of VolumeAttachmentPlanResult. 322 type VolumeAttachmentPlanResults struct { 323 Results []VolumeAttachmentPlanResult `json:"results,omitempty"` 324 } 325 326 // VolumeResult holds information about a volume. 327 type VolumeResult struct { 328 Result Volume `json:"result"` 329 Error *Error `json:"error,omitempty"` 330 } 331 332 // VolumeResults holds information about multiple volumes. 333 type VolumeResults struct { 334 Results []VolumeResult `json:"results,omitempty"` 335 } 336 337 // VolumeParamsResult holds provisioning parameters for a volume. 338 type VolumeParamsResult struct { 339 Result VolumeParams `json:"result"` 340 Error *Error `json:"error,omitempty"` 341 } 342 343 // VolumeParamsResults holds provisioning parameters for multiple volumes. 344 type VolumeParamsResults struct { 345 Results []VolumeParamsResult `json:"results,omitempty"` 346 } 347 348 // RemoveVolumeParamsResult holds parameters for destroying a volume. 349 type RemoveVolumeParamsResult struct { 350 Result RemoveVolumeParams `json:"result"` 351 Error *Error `json:"error,omitempty"` 352 } 353 354 // RemoveVolumeParamsResults holds parameters for destroying multiple volumes. 355 type RemoveVolumeParamsResults struct { 356 Results []RemoveVolumeParamsResult `json:"results,omitempty"` 357 } 358 359 // VolumeAttachmentParamsResult holds provisioning parameters for a volume 360 // attachment. 361 type VolumeAttachmentParamsResult struct { 362 Result VolumeAttachmentParams `json:"result"` 363 Error *Error `json:"error,omitempty"` 364 } 365 366 // VolumeAttachmentParamsResults holds provisioning parameters for multiple 367 // volume attachments. 368 type VolumeAttachmentParamsResults struct { 369 Results []VolumeAttachmentParamsResult `json:"results,omitempty"` 370 } 371 372 // Filesystem identifies and describes a storage filesystem in the model. 373 type Filesystem struct { 374 FilesystemTag string `json:"filesystem-tag"` 375 VolumeTag string `json:"volume-tag,omitempty"` 376 Info FilesystemInfo `json:"info"` 377 } 378 379 // FilesystemInfo describes a storage filesystem in the model. 380 type FilesystemInfo struct { 381 FilesystemId string `json:"filesystem-id"` 382 // Pool is the name of the storage pool used to 383 // allocate the filesystem. Juju controllers older 384 // than 2.2 do not populate this field, so it may 385 // be omitted. 386 Pool string `json:"pool"` 387 // Size is the size of the filesystem in MiB. 388 Size uint64 `json:"size"` 389 } 390 391 // Filesystems describes a set of storage filesystems in the model. 392 type Filesystems struct { 393 Filesystems []Filesystem `json:"filesystems"` 394 } 395 396 // FilesystemAttachment identifies and describes a filesystem attachment. 397 type FilesystemAttachment struct { 398 FilesystemTag string `json:"filesystem-tag"` 399 MachineTag string `json:"machine-tag"` 400 Info FilesystemAttachmentInfo `json:"info"` 401 } 402 403 // FilesystemAttachmentInfo describes a filesystem attachment. 404 type FilesystemAttachmentInfo struct { 405 MountPoint string `json:"mount-point,omitempty"` 406 ReadOnly bool `json:"read-only,omitempty"` 407 } 408 409 // FilesystemAttachments describes a set of storage filesystem attachments. 410 type FilesystemAttachments struct { 411 FilesystemAttachments []FilesystemAttachment `json:"filesystem-attachments"` 412 } 413 414 // FilesystemParams holds the parameters for creating a storage filesystem. 415 type FilesystemParams struct { 416 FilesystemTag string `json:"filesystem-tag"` 417 VolumeTag string `json:"volume-tag,omitempty"` 418 Size uint64 `json:"size"` 419 Provider string `json:"provider"` 420 Attributes map[string]interface{} `json:"attributes,omitempty"` 421 Tags map[string]string `json:"tags,omitempty"` 422 Attachment *FilesystemAttachmentParams `json:"attachment,omitempty"` 423 } 424 425 // RemoveFilesystemParams holds the parameters for destroying or releasing 426 // a filesystem. 427 type RemoveFilesystemParams struct { 428 // Provider is the storage provider that manages the filesystem. 429 Provider string `json:"provider"` 430 431 // FilesystemId is the storage provider's unique ID for the filesystem. 432 FilesystemId string `json:"filesystem-id"` 433 434 // Destroy controls whether the filesystem should be completely 435 // destroyed, or otherwise merely released from Juju's management. 436 Destroy bool `json:"destroy,omitempty"` 437 } 438 439 // FilesystemAttachmentParams holds the parameters for creating a filesystem 440 // attachment. 441 type FilesystemAttachmentParams struct { 442 FilesystemTag string `json:"filesystem-tag"` 443 MachineTag string `json:"machine-tag"` 444 FilesystemId string `json:"filesystem-id,omitempty"` 445 InstanceId string `json:"instance-id,omitempty"` 446 Provider string `json:"provider"` 447 MountPoint string `json:"mount-point,omitempty"` 448 ReadOnly bool `json:"read-only,omitempty"` 449 } 450 451 // FilesystemAttachmentResult holds the details of a single filesystem attachment, 452 // or an error. 453 type FilesystemAttachmentResult struct { 454 Result FilesystemAttachment `json:"result"` 455 Error *Error `json:"error,omitempty"` 456 } 457 458 // FilesystemAttachmentResults holds a set of FilesystemAttachmentResults. 459 type FilesystemAttachmentResults struct { 460 Results []FilesystemAttachmentResult `json:"results,omitempty"` 461 } 462 463 // FilesystemResult holds information about a filesystem. 464 type FilesystemResult struct { 465 Result Filesystem `json:"result"` 466 Error *Error `json:"error,omitempty"` 467 } 468 469 // FilesystemResults holds information about multiple filesystems. 470 type FilesystemResults struct { 471 Results []FilesystemResult `json:"results,omitempty"` 472 } 473 474 // FilesystemParamsResult holds provisioning parameters for a filesystem. 475 type FilesystemParamsResult struct { 476 Result FilesystemParams `json:"result"` 477 Error *Error `json:"error,omitempty"` 478 } 479 480 // FilesystemParamsResults holds provisioning parameters for multiple filesystems. 481 type FilesystemParamsResults struct { 482 Results []FilesystemParamsResult `json:"results,omitempty"` 483 } 484 485 // RemoveFilesystemParamsResult holds parameters for destroying or releasing 486 // a filesystem. 487 type RemoveFilesystemParamsResult struct { 488 Result RemoveFilesystemParams `json:"result"` 489 Error *Error `json:"error,omitempty"` 490 } 491 492 // RemoveFilesystemParamsResults holds parameters for destroying or releasing 493 // multiple filesystems. 494 type RemoveFilesystemParamsResults struct { 495 Results []RemoveFilesystemParamsResult `json:"results,omitempty"` 496 } 497 498 // FilesystemAttachmentParamsResult holds provisioning parameters for a filesystem 499 // attachment. 500 type FilesystemAttachmentParamsResult struct { 501 Result FilesystemAttachmentParams `json:"result"` 502 Error *Error `json:"error,omitempty"` 503 } 504 505 // FilesystemAttachmentParamsResults holds provisioning parameters for multiple 506 // filesystem attachments. 507 type FilesystemAttachmentParamsResults struct { 508 Results []FilesystemAttachmentParamsResult `json:"results,omitempty"` 509 } 510 511 // StorageDetails holds information about storage. 512 type StorageDetails struct { 513 // StorageTag holds tag for this storage. 514 StorageTag string `json:"storage-tag"` 515 516 // OwnerTag holds tag for the owner of this storage, unit or application. 517 OwnerTag string `json:"owner-tag"` 518 519 // Kind holds what kind of storage this instance is. 520 Kind StorageKind `json:"kind"` 521 522 // Status contains the status of the storage instance. 523 Status EntityStatus `json:"status"` 524 525 // Life contains the lifecycle state of the storage. 526 // Juju controllers older than 2.2 do not populate this 527 // field, so it may be omitted. 528 Life life.Value `json:"life,omitempty"` 529 530 // Persistent reports whether or not the underlying volume or 531 // filesystem is persistent; i.e. whether or not it outlives 532 // the machine that it is attached to. 533 Persistent bool `json:"persistent"` 534 535 // Attachments contains a mapping from unit tag to 536 // storage attachment details. 537 Attachments map[string]StorageAttachmentDetails `json:"attachments,omitempty"` 538 } 539 540 // StorageFilter holds filter terms for listing storage details. 541 type StorageFilter struct { 542 // We don't currently implement any filters. This exists to get the 543 // API structure right, and so we can add filters later as necessary. 544 } 545 546 // StorageFilters holds a set of storage filters. 547 type StorageFilters struct { 548 Filters []StorageFilter `json:"filters,omitempty"` 549 } 550 551 // StorageDetailsResult holds information about a storage instance 552 // or error related to its retrieval. 553 type StorageDetailsResult struct { 554 Result *StorageDetails `json:"result,omitempty"` 555 Error *Error `json:"error,omitempty"` 556 } 557 558 // StorageDetailsResults holds results for storage details or related storage error. 559 type StorageDetailsResults struct { 560 Results []StorageDetailsResult `json:"results,omitempty"` 561 } 562 563 // StorageDetailsListResult holds a collection of storage details. 564 type StorageDetailsListResult struct { 565 Result []StorageDetails `json:"result,omitempty"` 566 Error *Error `json:"error,omitempty"` 567 } 568 569 // StorageDetailsListResults holds a collection of collections of storage details. 570 type StorageDetailsListResults struct { 571 Results []StorageDetailsListResult `json:"results,omitempty"` 572 } 573 574 // StorageAttachmentDetails holds detailed information about a storage attachment. 575 type StorageAttachmentDetails struct { 576 // StorageTag is the tag of the storage instance. 577 StorageTag string `json:"storage-tag"` 578 579 // UnitTag is the tag of the unit attached to the storage instance. 580 UnitTag string `json:"unit-tag"` 581 582 // MachineTag is the tag of the machine that the attached unit is assigned to. 583 MachineTag string `json:"machine-tag"` 584 585 // Location holds location (mount point/device path) of 586 // the attached storage. 587 Location string `json:"location,omitempty"` 588 589 // Life contains the lifecycle state of the storage attachment. 590 // Juju controllers older than 2.2 do not populate this 591 // field, so it may be omitted. 592 Life life.Value `json:"life,omitempty"` 593 } 594 595 // StoragePool holds data for a pool instance. 596 type StoragePool struct { 597 // Name is the pool's name. 598 Name string `json:"name"` 599 600 // Provider is the type of storage provider this pool represents, eg "loop", "ebs". 601 Provider string `json:"provider"` 602 603 // Attrs are the pool's configuration attributes. 604 Attrs map[string]interface{} `json:"attrs"` 605 } 606 607 // StoragePoolArgs contains a set of StoragePool. 608 type StoragePoolArgs struct { 609 Pools []StoragePool `json:"pools"` 610 } 611 612 // StoragePoolDeleteArg holds data for a pool instance to be deleted. 613 type StoragePoolDeleteArg struct { 614 Name string `json:"name"` 615 } 616 617 // StoragePoolDeleteArgs contains a set of StorageDeleteArg. 618 type StoragePoolDeleteArgs struct { 619 Pools []StoragePoolDeleteArg `json:"pools"` 620 } 621 622 // StoragePoolFilter holds a filter for matching storage pools. 623 type StoragePoolFilter struct { 624 // Names are pool's names to filter on. 625 Names []string `json:"names,omitempty"` 626 627 // Providers are pool's storage provider types to filter on. 628 Providers []string `json:"providers,omitempty"` 629 } 630 631 // StoragePoolFilters holds a collection of storage pool filters. 632 type StoragePoolFilters struct { 633 Filters []StoragePoolFilter `json:"filters,omitempty"` 634 } 635 636 // StoragePoolsResult holds a collection of storage pools. 637 type StoragePoolsResult struct { 638 Result []StoragePool `json:"storage-pools,omitempty"` 639 Error *Error `json:"error,omitempty"` 640 } 641 642 // StoragePoolsResults holds a collection of storage pools results. 643 type StoragePoolsResults struct { 644 Results []StoragePoolsResult `json:"results,omitempty"` 645 } 646 647 // VolumeFilter holds a filter for volume list API call. 648 type VolumeFilter struct { 649 // Machines are machine tags to filter on. 650 Machines []string `json:"machines,omitempty"` 651 } 652 653 // IsEmpty determines if filter is empty 654 func (f *VolumeFilter) IsEmpty() bool { 655 return len(f.Machines) == 0 656 } 657 658 // VolumeFilters holds a collection of volume filters. 659 type VolumeFilters struct { 660 Filters []VolumeFilter `json:"filters,omitempty"` 661 } 662 663 // FilesystemFilter holds a filter for filter list API call. 664 type FilesystemFilter struct { 665 // Machines are machine tags to filter on. 666 Machines []string `json:"machines,omitempty"` 667 } 668 669 // IsEmpty determines if filter is empty 670 func (f *FilesystemFilter) IsEmpty() bool { 671 return len(f.Machines) == 0 672 } 673 674 // FilesystemFilters holds a collection of filesystem filters. 675 type FilesystemFilters struct { 676 Filters []FilesystemFilter `json:"filters,omitempty"` 677 } 678 679 // VolumeDetails describes a storage volume in the model 680 // for the purpose of volume CLI commands. 681 // 682 // This is kept separate from Volume which contains only information 683 // specific to the volume model, whereas VolumeDetails is intended 684 // to contain complete information about a volume and related 685 // information (status, attachments, storage). 686 type VolumeDetails struct { 687 // VolumeTag is the tag for the volume. 688 VolumeTag string `json:"volume-tag"` 689 690 // Info contains information about the volume. 691 Info VolumeInfo `json:"info"` 692 693 // Life contains the lifecycle state of the volume. 694 // Juju controllers older than 2.2 do not populate this 695 // field, so it may be omitted. 696 Life life.Value `json:"life,omitempty"` 697 698 // Status contains the status of the volume. 699 Status EntityStatus `json:"status"` 700 701 // MachineAttachments contains a mapping from 702 // machine tag to volume attachment information. 703 MachineAttachments map[string]VolumeAttachmentDetails `json:"machine-attachments,omitempty"` 704 705 // UnitAttachments contains a mapping from 706 // unit tag to volume attachment information (CAAS models). 707 UnitAttachments map[string]VolumeAttachmentDetails `json:"unit-attachments,omitempty"` 708 709 // Storage contains details about the storage instance 710 // that the volume is assigned to, if any. 711 Storage *StorageDetails `json:"storage,omitempty"` 712 } 713 714 // VolumeAttachmentDetails describes a volume attachment. 715 type VolumeAttachmentDetails struct { 716 // NOTE(axw) for backwards-compatibility, this must not be given a 717 // json tag. This ensures that we collapse VolumeAttachmentInfo. 718 // 719 // TODO(axw) when we can break backwards-compatibility (Juju 3.0), 720 // give this a field name of "info", like we have in VolumeDetails 721 // above. 722 VolumeAttachmentInfo 723 724 // Life contains the lifecycle state of the volume attachment. 725 // Juju controllers older than 2.2 do not populate this 726 // field, so it may be omitted. 727 Life life.Value `json:"life,omitempty"` 728 } 729 730 // VolumeDetailsResult contains details about a volume, its attachments or 731 // an error preventing retrieving those details. 732 type VolumeDetailsResult struct { 733 // Result describes the volume in detail. 734 Result *VolumeDetails `json:"details,omitempty"` 735 736 // Error contains volume retrieval error. 737 Error *Error `json:"error,omitempty"` 738 } 739 740 // VolumeDetailsResults holds volume details. 741 type VolumeDetailsResults struct { 742 Results []VolumeDetailsResult `json:"results,omitempty"` 743 } 744 745 // VolumeDetailsListResult holds a collection of volume details. 746 type VolumeDetailsListResult struct { 747 Result []VolumeDetails `json:"result,omitempty"` 748 Error *Error `json:"error,omitempty"` 749 } 750 751 // VolumeDetailsListResults holds a collection of collections of volume details. 752 type VolumeDetailsListResults struct { 753 Results []VolumeDetailsListResult `json:"results,omitempty"` 754 } 755 756 // FilesystemDetails describes a storage filesystem in the model 757 // for the purpose of filesystem CLI commands. 758 // 759 // This is kept separate from Filesystem which contains only information 760 // specific to the filesystem model, whereas FilesystemDetails is intended 761 // to contain complete information about a filesystem and related 762 // information (status, attachments, storage). 763 type FilesystemDetails struct { 764 // FilesystemTag is the tag for the filesystem. 765 FilesystemTag string `json:"filesystem-tag"` 766 767 // VolumeTag is the tag for the volume backing the 768 // filesystem, if any. 769 VolumeTag string `json:"volume-tag,omitempty"` 770 771 // Info contains information about the filesystem. 772 Info FilesystemInfo `json:"info"` 773 774 // Life contains the lifecycle state of the filesystem. 775 // Juju controllers older than 2.2 do not populate this 776 // field, so it may be omitted. 777 Life life.Value `json:"life,omitempty"` 778 779 // Status contains the status of the filesystem. 780 Status EntityStatus `json:"status"` 781 782 // MachineAttachments contains a mapping from 783 // machine tag to filesystem attachment information (IAAS models). 784 MachineAttachments map[string]FilesystemAttachmentDetails `json:"machine-attachments,omitempty"` 785 786 // UnitAttachments contains a mapping from 787 // unit tag to filesystem attachment information. 788 UnitAttachments map[string]FilesystemAttachmentDetails `json:"unit-attachments,omitempty"` 789 790 // Storage contains details about the storage instance 791 // that the volume is assigned to, if any. 792 Storage *StorageDetails `json:"storage,omitempty"` 793 } 794 795 // FilesystemAttachmentDetails describes a filesystem attachment. 796 type FilesystemAttachmentDetails struct { 797 // NOTE(axw) for backwards-compatibility, this must not be given a 798 // json tag. This ensures that we collapse FilesystemAttachmentInfo. 799 // 800 // TODO(axw) when we can break backwards-compatibility (Juju 3.0), 801 // give this a field name of "info", like we have in FilesystemDetails 802 // above. 803 FilesystemAttachmentInfo 804 805 // Life contains the lifecycle state of the filesystem attachment. 806 // Juju controllers older than 2.2 do not populate this 807 // field, so it may be omitted. 808 Life life.Value `json:"life,omitempty"` 809 } 810 811 // FilesystemDetailsResult contains details about a filesystem, its attachments or 812 // an error preventing retrieving those details. 813 type FilesystemDetailsResult struct { 814 Result *FilesystemDetails `json:"result,omitempty"` 815 Error *Error `json:"error,omitempty"` 816 } 817 818 // FilesystemDetailsResults holds filesystem details. 819 type FilesystemDetailsResults struct { 820 Results []FilesystemDetailsResult `json:"results,omitempty"` 821 } 822 823 // FilesystemDetailsListResult holds a collection of filesystem details. 824 type FilesystemDetailsListResult struct { 825 Result []FilesystemDetails `json:"result,omitempty"` 826 Error *Error `json:"error,omitempty"` 827 } 828 829 // FilesystemDetailsListResults holds a collection of collections of 830 // filesystem details. 831 type FilesystemDetailsListResults struct { 832 Results []FilesystemDetailsListResult `json:"results,omitempty"` 833 } 834 835 // StorageConstraints contains constraints for storage instance. 836 type StorageConstraints struct { 837 // Pool is the name of the storage pool from which to provision the 838 // storage instance. 839 Pool string `json:"pool,omitempty"` 840 841 // Size is the required size of the storage instance, in MiB. 842 Size *uint64 `json:"size,omitempty"` 843 844 // Count is the required number of storage instances. 845 Count *uint64 `json:"count,omitempty"` 846 } 847 848 // StorageAddParams holds storage details to add to a unit dynamically. 849 type StorageAddParams struct { 850 // UnitTag is unit name. 851 UnitTag string `json:"unit"` 852 853 // StorageName is the name of the storage as specified in the charm. 854 StorageName string `json:"name"` 855 856 // Constraints are specified storage constraints. 857 Constraints StorageConstraints `json:"storage"` 858 } 859 860 // StoragesAddParams holds storage details to add to units dynamically. 861 type StoragesAddParams struct { 862 Storages []StorageAddParams `json:"storages"` 863 } 864 865 // RemoveStorage holds the parameters for removing storage from the model. 866 type RemoveStorage struct { 867 Storage []RemoveStorageInstance `json:"storage"` 868 } 869 870 // RemoveStorageInstance holds the parameters for removing a storage instance. 871 type RemoveStorageInstance struct { 872 // Tag is the tag of the storage instance to be destroyed. 873 Tag string `json:"tag"` 874 875 // DestroyAttachments controls whether or not the storage attachments 876 // will be destroyed automatically. If DestroyAttachments is false, 877 // then the storage must already be detached. 878 DestroyAttachments bool `json:"destroy-attachments,omitempty"` 879 880 // DestroyStorage controls whether or not the associated cloud storage 881 // is destroyed. If DestroyStorage is true, the cloud storage will be 882 // destroyed; otherwise it will only be released from Juju's control. 883 DestroyStorage bool `json:"destroy-storage,omitempty"` 884 885 // Force specifies whether relation destruction will be forced, i.e. 886 // keep going despite operational errors. 887 Force *bool `json:"force,omitempty"` 888 889 // MaxWait specifies the amount of time that each step in relation destroy process 890 // will wait before forcing the next step to kick-off. This parameter 891 // only makes sense in combination with 'force' set to 'true'. 892 MaxWait *time.Duration `json:"max-wait,omitempty"` 893 } 894 895 // BulkImportStorageParams contains the parameters for importing a collection 896 // of storage entities. 897 type BulkImportStorageParams struct { 898 Storage []ImportStorageParams `json:"storage"` 899 } 900 901 // ImportStorageParams contains the parameters for importing a storage entity. 902 type ImportStorageParams struct { 903 // Kind is the kind of the storage entity to import. 904 Kind StorageKind `json:"kind"` 905 906 // Pool is the name of the storage pool into which the storage is to 907 // be imported. 908 Pool string `json:"pool"` 909 910 // ProviderId is the storage provider's unique ID for the storage, 911 // e.g. the EBS volume ID. 912 ProviderId string `json:"provider-id"` 913 914 // StorageName is the name of the storage to assign to the entity. 915 StorageName string `json:"storage-name"` 916 } 917 918 // ImportStorageResults contains the results of importing a collection of 919 // storage entities. 920 type ImportStorageResults struct { 921 Results []ImportStorageResult `json:"results"` 922 } 923 924 // ImportStorageResult contains the result of importing a storage entity. 925 type ImportStorageResult struct { 926 Result *ImportStorageDetails `json:"result,omitempty"` 927 Error *Error `json:"error,omitempty"` 928 } 929 930 // ImportStorageDetails contains the details of an imported storage entity. 931 type ImportStorageDetails struct { 932 // StorageTag contains the string representation of the storage tag 933 // assigned to the imported storage entity. 934 StorageTag string `json:"storage-tag"` 935 } 936 937 // AddStorageResults contains the results of adding storage to units. 938 type AddStorageResults struct { 939 Results []AddStorageResult `json:"results"` 940 } 941 942 // AddStorageResult contains the result of adding storage to a unit. 943 type AddStorageResult struct { 944 Result *AddStorageDetails `json:"result,omitempty"` 945 Error *Error `json:"error,omitempty"` 946 } 947 948 // AddStorageDetails contains the details of added storage. 949 type AddStorageDetails struct { 950 // StorageTags contains the string representation of the storage tags 951 // of the added storage instances. 952 StorageTags []string `json:"storage-tags"` 953 }