github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/cbr/v3/backups/results.go (about) 1 package backups 2 3 import "github.com/chnsz/golangsdk/pagination" 4 5 type getResp struct { 6 // The backup detail. 7 Backup BackupResp `json:"backup"` 8 } 9 10 // BackupResp is the structure that represents the backup detail. 11 type BackupResp struct { 12 // The restore point ID 13 CheckpointId string `json:"checkpoint_id"` 14 // The creation time of the backup. 15 CreatedAt string `json:"created_at"` 16 // The backup description. 17 Description string `json:"description"` 18 // The expiration time of the backup. 19 ExpiredAt string `json:"expired_at"` 20 // The extended information. 21 ExtendInfo BackupExtendInfo `json:"extend_info"` 22 // The backup ID. 23 ID string `json:"id"` 24 // The backup type. 25 ImageType string `json:"image_type"` 26 // The backup name. 27 Name string `json:"name"` 28 // The parent backup ID. 29 ParentId string `json:"parent_id"` 30 // The project ID to which the backup belongs. 31 ProjectId string `json:"project_id"` 32 // Backup time. 33 ProtectedAt string `json:"protected_at"` 34 // The availability zone where the backup resource is located. 35 ResourceAz string `json:"resource_az"` 36 // The backup resource ID. 37 ResourceId string `json:"resource_id"` 38 // The backup resource name. 39 ResourceName string `json:"resource_name"` 40 // The backup resource size, in GB. 41 ResourceSize int `json:"resource_size"` 42 // The backup resource type. 43 ResourceType string `json:"resource_type"` 44 // The backup status. 45 Status string `json:"status"` 46 // The latest update time of the backup. 47 UpdatedAt string `json:"updated_at"` 48 // The vault to which the backup resource belongs. 49 VaultId string `json:"vault_id"` 50 // The replication records. 51 ReplicationRecords []ReplicationRecord `json:"replication_record"` 52 // The enterprise project to which the backup resource belongs. 53 EnterpriseProjectId string `json:"enterprise_project_id"` 54 // The provider ID. 55 ProviderId string `json:"provider_id"` 56 // The backup list of the child resources. 57 Children []BackupResp `json:"children"` 58 } 59 60 // BackupExtendInfo is an object that represents the extended information of the backup. 61 type BackupExtendInfo struct { 62 // Whether the backup is automatically generated. 63 AutoTrigger bool `json:"auto_trigger"` 64 // Whether the backup is a system disk backup. 65 Bootable bool `json:"bootable"` 66 // Whether the backup is an incremental backup. 67 Incremental bool `json:"incremental"` 68 // Snapshot ID of the disk backup. 69 SnapshotId string `json:"snapshot_id"` 70 // Whether to allow lazyloading for fast restoration. 71 SupportLld bool `json:"support_lld"` 72 // The restoration mode. 73 SupportRestoreMode string `json:"supported_restore_mode"` 74 // The ID list of images created using backups. 75 OsImagesData []ImageData `json:"os_image_data"` 76 // Whether the VM backup data contains system disk data. 77 ContainSystemDisk bool `json:"contain_system_disk"` 78 // Whether the backup is encrypted. 79 Encrypted bool `json:"encrypted"` 80 // Whether the disk is a system disk. 81 SystemDisk bool `json:"system_disk"` 82 } 83 84 // ImageData is an object that represents the backup image detail. 85 type ImageData struct { 86 // Backup image ID. 87 ImageId string `json:"image_id"` 88 } 89 90 // ReplicationRecord is an object that represents the replication record detail. 91 type ReplicationRecord struct { 92 // The creation time of the replication. 93 CreatedAt string `json:"created_at"` 94 // The ID of the destination backup used for replication. 95 DestinationBackupId string `json:"destination_backup_id"` 96 // The record ID of the destination backup used for replication. 97 DestinationCheckpointId string `json:"destination_checkpoint_id"` 98 // The ID of the replication destination project. 99 DestinationProjectId string `json:"destination_project_id"` 100 // The replication destination region. 101 DestinationRegion string `json:"destination_region"` 102 // The destination vault ID. 103 DestinationVaultId string `json:"destination_vault_id"` 104 // The additional information of the replication. 105 ExtraInfo ReplicationRecordExtraInfo `json:"extra_info"` 106 // The replication record ID. 107 ID string `json:"id"` 108 // The ID of the source backup used for replication. 109 SourceBackupId string `json:"source_backup_id"` 110 // The ID of the source backup record used for replication. 111 SourceCheckpointId string `json:"source_checkpoint_id"` 112 // The ID of the replication source project. 113 SourceProjectId string `json:"source_project_id"` 114 // The replication source region. 115 SourceRegion string `json:"source_region"` 116 // The replication status. 117 Status string `json:"status"` 118 // The ID of the vault where the backup resides. 119 VaultId string `json:"vault_id"` 120 } 121 122 // ReplicationRecordExtraInfo is an object that represents the additional information of the replication. 123 type ReplicationRecordExtraInfo struct { 124 // The replication progress. 125 Progress int `json:"progress"` 126 // The error code. 127 FailCode string `json:"fail_code"` 128 // The error cause. 129 FailReason string `json:"fail_reason"` 130 // Whether replication is automatically scheduled. 131 AutoTrigger bool `json:"auto_trigger"` 132 // The destination vault ID. 133 DestinationVaultId string `json:"destination_vault_id"` 134 } 135 136 // BackupPage is a single page maximum result representing a query by offset page. 137 type BackupPage struct { 138 pagination.OffsetPageBase 139 } 140 141 // IsEmpty checks whether a ChannelPage struct is empty. 142 func (b BackupPage) IsEmpty() (bool, error) { 143 arr, err := ExtractBackups(b) 144 return len(arr) == 0, err 145 } 146 147 // ExtractBackups is a method to extract the list of backups. 148 func ExtractBackups(r pagination.Page) ([]BackupResp, error) { 149 var s []BackupResp 150 err := r.(BackupPage).Result.ExtractIntoSlicePtr(&s, "backups") 151 return s, err 152 }