github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cbr/v3/tasks/results.go (about) 1 package tasks 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 type commonResult struct { 9 golangsdk.Result 10 } 11 12 type GetResult struct { 13 commonResult 14 } 15 16 type TaskPage struct { 17 pagination.SinglePageBase 18 } 19 20 type OperationLog struct { 21 CheckpointID string `json:"checkpoint_id"` 22 CreatedAt string `json:"created_at"` 23 EndedAt string `json:"ended_at"` 24 ErrorInfo OpErrorInfo `json:"error_info"` 25 ExtraInfo OpExtraInfo `json:"extra_info"` 26 ID string `json:"id"` 27 OperationType string `json:"operation_type"` 28 PolicyID string `json:"policy_id"` 29 ProjectID string `json:"project_id"` 30 ProviderID string `json:"provider_id"` 31 StartedAt string `json:"started_at"` 32 Status string `json:"status"` 33 UpdatedAt string `json:"updated_at"` 34 VaultID string `json:"vault_id"` 35 VaultName string `json:"vault_name"` 36 } 37 38 type OpErrorInfo struct { 39 Code string `json:"code"` 40 Message string `json:"message"` 41 } 42 43 type OpExtraInfo struct { 44 Backup OpExtendInfoBackup `json:"backup"` 45 Common OpExtendInfoCommon `json:"common"` 46 Delete OpExtendInfoDelete `json:"delete"` 47 Sync OpExtendInfoSync `json:"sync"` 48 RemoveResources OpExtendInfoRemoveResources `json:"remove_resources"` 49 Replication OpExtendInfoReplication `json:"replication"` 50 Resource Resource `json:"resource"` 51 Restore OpExtendInfoRestore `json:"restore"` 52 VaultDelete OpExtendInfoVaultDelete `json:"vault_delete"` 53 } 54 55 type OpExtendInfoBackup struct { 56 AppConsistencyErrorCode string `json:"app_consistency_error_code"` 57 AppConsistencyErrorMessage string `json:"app_consistency_error_message"` 58 AppConsistencyStatus string `json:"app_consistency_status"` 59 BackupID string `json:"backup_id"` 60 BackupName string `json:"backup_name"` 61 Incremental string `json:"incremental"` 62 } 63 64 type OpExtendInfoCommon struct { 65 Progress int `json:"progress"` 66 RequestID string `json:"request_id"` 67 TaskID string `json:"task_id"` 68 } 69 70 type OpExtendInfoDelete struct { 71 BackupID string `json:"backup_id"` 72 BackupName string `json:"backup_name"` 73 } 74 75 type OpExtendInfoSync struct { 76 SyncBackupNum int `json:"sync_backup_num"` 77 DeleteBackupNum int `json:"delete_backup_num"` 78 ErrSyncBackupNum int `json:"err_sync_backup_num"` 79 } 80 81 type OpExtendInfoRemoveResources struct { 82 FailCount int `json:"fail_count"` 83 TotalCount int `json:"total_count"` 84 Resources []Resource `json:"resources"` 85 } 86 87 type Resource struct { 88 ExtraInfo ResourceExtraInfo `json:"extra_info"` 89 ID string `json:"id"` 90 Name string `json:"name"` 91 Type string `json:"type"` 92 } 93 94 type OpExtendInfoReplication struct { 95 DestinationBackupID string `json:"destination_backup_id"` 96 DestinationCheckpointID string `json:"destination_checkpoint_id"` 97 DestinationProjectID string `json:"destination_project_id"` 98 DestinationRegion string `json:"destination_region"` 99 SourceBackupID string `json:"source_backup_id"` 100 SourceCheckpointID string `json:"source_checkpoint_id"` 101 SourceProjectID string `json:"source_project_id"` 102 SourceRegion string `json:"source_region"` 103 SourceBackupName string `json:"source_backup_name"` 104 DestinationBackupName string `json:"destination_backup_name"` 105 } 106 107 type ResourceExtraInfo struct { 108 ExcludeVolumes []string `json:"exclude_volumes"` 109 IncludeVolumes []ResourceExtraInfoIncludeVolumes `json:"include_volumes"` 110 } 111 112 type ResourceExtraInfoIncludeVolumes struct { 113 ID string `json:"id"` 114 OsVersion string `json:"os_version"` 115 } 116 117 type OpExtendInfoRestore struct { 118 BackupID string `json:"backup_id"` 119 BackupName string `json:"backup_name"` 120 TargetResourceId string `json:"target_resource_id"` 121 TargetResourceName string `json:"target_resource_name"` 122 } 123 124 type OpExtendInfoVaultDelete struct { 125 FailCount int `json:"fail_count"` 126 TotalCount int `json:"total_count"` 127 } 128 129 func (r commonResult) Extract() (*OperationLog, error) { 130 var s struct { 131 Operation *OperationLog `json:"operation_log"` 132 } 133 err := r.ExtractInto(&s) 134 return s.Operation, err 135 } 136 137 func ExtractTasks(r pagination.Page) (*[]OperationLog, error) { 138 var s struct { 139 OperationLog []OperationLog `json:"operation_logs"` 140 } 141 err := r.(TaskPage).Result.ExtractInto(&s) 142 return &s.OperationLog, err 143 }