github.com/verrazzano/verrazzano-monitoring-operator@v0.0.30/verrazzano-backup-hook/types/model.go (about) 1 // Copyright (c) 2022, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package types 5 6 import ( 7 "time" 8 ) 9 10 // ConnectionData object used to communicate with Object Store 11 type ConnectionData struct { 12 Secret ObjectStoreSecret `json:"secret"` 13 Endpoint string `json:"endpoint"` 14 RegionName string `json:"region_name"` 15 BucketName string `json:"bucket_name"` 16 BackupName string `json:"backup_name"` 17 VeleroTimeout string `json:"velero_timeout"` 18 } 19 20 // ObjectStoreSecret to render secret details 21 type ObjectStoreSecret struct { 22 SecretName string `json:"secret_name"` 23 SecretKey string `json:"secret_key"` 24 ObjectAccessKey string `json:"object_store_access_key"` 25 ObjectSecretKey string `json:"object_store_secret_key"` 26 } 27 28 // VeleroBackupStorageLocation defines the spec for BSL 29 type VeleroBackupStorageLocation struct { 30 APIVersion string `json:"apiVersion"` 31 Kind string `json:"kind"` 32 Metadata struct { 33 Annotations struct { 34 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 35 } `json:"annotations"` 36 CreationTimestamp time.Time `json:"creationTimestamp"` 37 Generation int `json:"generation"` 38 Name string `json:"name"` 39 Namespace string `json:"namespace"` 40 ResourceVersion string `json:"resourceVersion"` 41 UID string `json:"uid"` 42 } `json:"metadata"` 43 Spec struct { 44 BackupSyncPeriod string `json:"backupSyncPeriod"` 45 Config struct { 46 Region string `json:"region"` 47 S3ForcePathStyle string `json:"s3ForcePathStyle"` 48 S3URL string `json:"s3Url"` 49 } `json:"config"` 50 Credential struct { 51 Key string `json:"key"` 52 Name string `json:"name"` 53 } `json:"credential"` 54 ObjectStorage struct { 55 Bucket string `json:"bucket"` 56 Prefix string `json:"prefix"` 57 } `json:"objectStorage"` 58 Provider string `json:"provider"` 59 } `json:"spec"` 60 Status struct { 61 LastSyncedTime time.Time `json:"lastSyncedTime"` 62 LastValidationTime time.Time `json:"lastValidationTime"` 63 Phase string `json:"phase"` 64 } `json:"status"` 65 } 66 67 // VeleroBackup defines the spec for backup 68 type VeleroBackup struct { 69 APIVersion string `json:"apiVersion"` 70 Kind string `json:"kind"` 71 Metadata struct { 72 Annotations struct { 73 KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"` 74 VeleroIoSourceClusterK8SGitversion string `json:"velero.io/source-cluster-k8s-gitversion"` 75 VeleroIoSourceClusterK8SMajorVersion string `json:"velero.io/source-cluster-k8s-major-version"` 76 VeleroIoSourceClusterK8SMinorVersion string `json:"velero.io/source-cluster-k8s-minor-version"` 77 } `json:"annotations"` 78 CreationTimestamp time.Time `json:"creationTimestamp"` 79 Generation int `json:"generation"` 80 Labels struct { 81 VeleroIoStorageLocation string `json:"velero.io/storage-location"` 82 } `json:"labels"` 83 Name string `json:"name"` 84 Namespace string `json:"namespace"` 85 ResourceVersion string `json:"resourceVersion"` 86 UID string `json:"uid"` 87 } `json:"metadata"` 88 Spec struct { 89 DefaultVolumesToRestic bool `json:"defaultVolumesToRestic"` 90 Hooks struct { 91 Resources []struct { 92 IncludedNamespaces []string `json:"includedNamespaces"` 93 LabelSelector struct { 94 MatchLabels struct { 95 App string `json:"app"` 96 } `json:"matchLabels"` 97 } `json:"labelSelector"` 98 Name string `json:"name"` 99 Post []struct { 100 Exec struct { 101 Command []string `json:"command"` 102 Container string `json:"container"` 103 OnError string `json:"onError"` 104 Timeout string `json:"timeout"` 105 } `json:"exec"` 106 } `json:"post"` 107 } `json:"resources"` 108 } `json:"hooks"` 109 IncludedNamespaces []string `json:"includedNamespaces"` 110 StorageLocation string `json:"storageLocation"` 111 TTL string `json:"ttl"` 112 } `json:"spec"` 113 Status struct { 114 CompletionTimestamp time.Time `json:"completionTimestamp"` 115 Expiration time.Time `json:"expiration"` 116 FormatVersion string `json:"formatVersion"` 117 Phase string `json:"phase"` 118 Progress struct { 119 ItemsBackedUp int `json:"itemsBackedUp"` 120 TotalItems int `json:"totalItems"` 121 } `json:"progress"` 122 StartTimestamp time.Time `json:"startTimestamp"` 123 Version int `json:"version"` 124 } `json:"status"` 125 } 126 127 // OpenSearchHealthResponse used to determine health details 128 type OpenSearchHealthResponse struct { 129 ClusterName string `json:"cluster_name"` 130 Status string `json:"status"` 131 TimedOut bool `json:"timed_out"` 132 NumberOfNodes int `json:"number_of_nodes"` 133 NumberOfDataNodes int `json:"number_of_data_nodes"` 134 DiscoveredMaster bool `json:"discovered_master"` 135 ActivePrimaryShards int `json:"active_primary_shards"` 136 ActiveShards int `json:"active_shards"` 137 RelocatingShards int `json:"relocating_shards"` 138 InitializingShards int `json:"initializing_shards"` 139 UnassignedShards int `json:"unassigned_shards"` 140 DelayedUnassignedShards int `json:"delayed_unassigned_shards"` 141 NumberOfPendingTasks int `json:"number_of_pending_tasks"` 142 NumberOfInFlightFetch int `json:"number_of_in_flight_fetch"` 143 TaskMaxWaitingInQueueMillis int `json:"task_max_waiting_in_queue_millis"` 144 ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"` 145 } 146 147 // OpenSearchSnapshotRequestPayload struct for registering a snapshot 148 type OpenSearchSnapshotRequestPayload struct { 149 Type string `json:"type"` 150 Settings struct { 151 Client string `json:"client"` 152 Bucket string `json:"bucket"` 153 Region string `json:"region"` 154 Endpoint string `json:"endpoint"` 155 PathStyleAccess bool `json:"path_style_access"` 156 } `json:"settings"` 157 } 158 159 // OpenSearchOperationResponse to render common operational responses 160 type OpenSearchOperationResponse struct { 161 Acknowledged bool `json:"acknowledged,omitempty"` 162 } 163 164 // OpenSearchSnapshotResponse to render snapshot response 165 type OpenSearchSnapshotResponse struct { 166 Accepted bool `json:"accepted,omitempty"` 167 } 168 169 // OpenSearchSnapshotStatus to render all snapshot status 170 type OpenSearchSnapshotStatus struct { 171 Snapshots []Snapshot `json:"snapshots"` 172 } 173 174 // Snapshot to render snapshot status 175 type Snapshot struct { 176 Snapshot string `json:"snapshot"` 177 UUID string `json:"uuid"` 178 VersionID int `json:"version_id"` 179 Version string `json:"version"` 180 Indices []string `json:"indices"` 181 DataStreams []string `json:"data_streams"` 182 IncludeGlobalState bool `json:"include_global_state"` 183 State string `json:"state"` 184 StartTime time.Time `json:"start_time"` 185 StartTimeInMillis int64 `json:"start_time_in_millis"` 186 EndTime time.Time `json:"end_time"` 187 EndTimeInMillis int64 `json:"end_time_in_millis"` 188 DurationInMillis int `json:"duration_in_millis"` 189 Failures []interface{} `json:"failures"` 190 Shards struct { 191 Total int `json:"total"` 192 Failed int `json:"failed"` 193 Successful int `json:"successful"` 194 } `json:"shards"` 195 } 196 197 // OpenSearchDataStreams struct to render array of data streams info 198 type OpenSearchDataStreams struct { 199 DataStreams []DataStreams `json:"data_streams"` 200 } 201 202 // DataStreams struct to render data streams info 203 type DataStreams struct { 204 Name string `json:"name"` 205 TimestampField struct { 206 Name string `json:"name"` 207 } `json:"timestamp_field"` 208 Indices []struct { 209 IndexName string `json:"index_name"` 210 IndexUUID string `json:"index_uuid"` 211 } `json:"indices"` 212 Generation int `json:"generation"` 213 Status string `json:"status"` 214 Template string `json:"template"` 215 } 216 217 // OpenSearchClusterInfo renders opensearch cluster reachability 218 type OpenSearchClusterInfo struct { 219 Name string `json:"name"` 220 ClusterName string `json:"cluster_name"` 221 ClusterUUID string `json:"cluster_uuid"` 222 Version struct { 223 Distribution string `json:"distribution"` 224 Number string `json:"number"` 225 BuildType string `json:"build_type"` 226 BuildHash string `json:"build_hash"` 227 BuildDate time.Time `json:"build_date"` 228 BuildSnapshot bool `json:"build_snapshot"` 229 LuceneVersion string `json:"lucene_version"` 230 MinimumWireCompatibilityVersion string `json:"minimum_wire_compatibility_version"` 231 MinimumIndexCompatibilityVersion string `json:"minimum_index_compatibility_version"` 232 } `json:"version"` 233 Tagline string `json:"tagline"` 234 } 235 236 // OpenSearchSecureSettingsReloadStatus renders status of nodes on reload secure settings 237 type OpenSearchSecureSettingsReloadStatus struct { 238 ClusterNodes struct { 239 Total int `json:"total"` 240 Successful int `json:"successful"` 241 Failed int `json:"failed"` 242 } `json:"_nodes"` 243 ClusterName string `json:"cluster_name"` 244 }