Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/update-backup-model #328

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 83 additions & 41 deletions pkg/rorresources/rortypes/resourcedef_backupjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "time"
type ResourceBackupJob struct {
Id string `json:"id"`
Provider string `json:"provider"`
Source string `json:"source"`
Status ResourceBackupJobStatus `json:"status"`
Spec ResourceBackupJobSpec `json:"spec"`
}
Expand All @@ -18,16 +19,11 @@ type ResourceBackupJobSpec struct {
// Status of the backup job, active, paused, etc.
Status string `json:"status"`

// Defines the name of the system the run originates from
SourceName string `json:"sourceName"`

// Defines the id of the system the run originates from
SourceId string `json:"sourceId"`

// Defines the policy if applicable at the local system
// If policies are not used these can be left as blank
PolicyId string `json:"policyId"`
PolicyName string `json:"policyName"`
PolicyId string `json:"policyId"`

Schedules []ResourceBackupSchedule `json:"schedules"`

// Direct targets for this backup job
ActiveTargets []ResourceBackupTarget `json:"activeTargets"`
Expand All @@ -37,51 +33,58 @@ type ResourceBackupJobSpec struct {

// Any destination defined by this backup job
BackupDestinations []ResourceBackupDestination `json:"backupDestinations"`

// Some backup systems allow StartTime to be defined per backupJob, while some use policies
StartTime time.Time `json:"startTime"`

// Some backup systems allow EndTime to be defined per backupJob, while some use policies
EndTime time.Time `json:"endTime"`

// Some backup systems allow ExpiryTime to be defined per backupJob, while some use policies
ExpiryTime time.Time `json:"expiryTime"`
}

// The observed parameters about a job
type ResourceBackupJobStatus struct {
ResourceBackupJobSpec
Runs []ResourceBackupRun `json:"runs"`
Location string `json:"location"`
LastUpdated time.Time `json:"lastUpdated"`
PolicyName string `json:"policyName"`
Runs []ResourceBackupRun `json:"runs"`
}

// Once instance of a run from a backup job
type ResourceBackupRun struct {
BackupTargets []ResourceBackupTarget `json:"backupTargets"`
BackupDestinations []ResourceBackupDestination `json:"backupDestinations"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
ExpiryTime time.Time `json:"expiryTime"`
BackupStorage ResourceBackupStorage `json:"backupStorage"`
}
Id string `json:"id"`
BackupTargets []ResourceBackupTarget `json:"backupTargets"`
BackupDestinations []ResourceBackupRunDestination `json:"backupDestinations"`

// When the run was started
StartTime time.Time `json:"startTime"`

// When the run was finished
EndTime time.Time `json:"endTime"`

// Defines a singular direct backup target, this could be a VM, a storage object, etc.
type ResourceDirectBackupTarget struct {
BackupTargets []ResourceBackupTarget `json:"backupTargets"`
BackupDestination ResourceBackupDestination `json:"backupDestination"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
ExpiryTime time.Time `json:"expiryTime"`
BackupStorage ResourceBackupStorage `json:"backupStorage"`
// When the run will expire and be deleted
ExpiryTime time.Time `json:"expiryTime"`
BackupStorage ResourceBackupStorage `json:"backupStorage"`
}

// Defines a singular backup target, this could be a VM, a storage object, etc.
type ResourceBackupTarget struct {
Name string `json:"name"` // Defines the object's name
Id string `json:"id"` // Defines the object's id
ExternalIds map[string]string `json:"externalIds"` // Defines any external ids by the backup system(s)
// Defines the object's name
Name string `json:"name"`

// Defines the object's id
Id string `json:"id"`

// Defines any external id
ExternalId string `json:"externalId"`

// Defines the source of this object to the backup system
Source *ResourceBackupSource `json:"source,omitempty"`
}

// The backup target's source, a vCenter, a NetApp system, etc.
type ResourceBackupSource struct {
Name string `json:"name"`
Id string `json:"id"`
Uuid string `json:"Uuid"`
Type string `json:"type"`
}

// Defines a indrect backup target, which can result into multiple objects (For example a tag or multiple tags should result into being in a backup job)
// Defines a indirect backup target, which can result into multiple objects (For example a tag or multiple tags should result into being in a backup job)
// One instance indicates all should match
// Multiple instances would indicate different matching groups
type ResourceIndirectBackupTarget struct {
Expand All @@ -97,14 +100,53 @@ type ResourceBackupDestination struct {
// Local, remote, archive, etc.
Type string `json:"type"`

// Status spesific to the destination - remote being unavailable
Status string `json:"status"`
}

type ResourceBackupRunDestination struct {
Name string `json:"name"`
Id string `json:"id"`

// Local, remote, archive, etc.
Type string `json:"type"`

// Status spesific to the destination - remote being unavailable
Status string `json:"status"`
ExpiryTime time.Time `json:"expiryTime"` // ExpiryTime is defined per destination
}

type ResourceBackupStorage struct {
Unit string `json:"unit"`
SourceSize int `json:"sourceSize"` // Total changed data in the run, incremental will have changes since last time, full runs will have the entire VM - not including unusued space
LogicalSize int `json:"logicalSize"` // The total logical size of the VM
PhysicalSize int `json:"physicalSize"` // Physical data written to the backup system
// What unit are the sizes in
Unit string `json:"unit"`

// Total changed data in the run, incremental will have changes since last time, full runs will have the entire VM - not including unusued space
SourceSize int `json:"sourceSize"`

// The total logical size of the VM
LogicalSize int `json:"logicalSize"`

// Physical data written to the backup system
PhysicalSize int `json:"physicalSize"`
}

type ResourceBackupSchedule struct {

// When will the job start
StartTime string `json:"startTime"`

// When will the job be forcibly stopped, if empty it will continue indefinitely
EndTime string `json:"endTime"`

// How many time per unit will this backup run
Frequency int `json:"frequency"`

// What unit of time is this schedule going to run in
Unit string `json:"unit"`
Retention ResourceBackupRetention `json:"retention"`
}

type ResourceBackupRetention struct {
Unit string `json:"unit"`
Duration int `json:"duration"`
}
49 changes: 34 additions & 15 deletions typescript/models/src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@ export enum ResourceTagProperties {
export interface ResourceBackupJobSpec {
name: string;
status: string;
sourceName: string;
sourceId: string;
policyId: string;
policyName: string;
schedules: ResourceBackupSchedule[];
activeTargets: ResourceBackupTarget[];
indirectBackupTargets: ResourceIndirectBackupTarget[];
backupDestinations: ResourceBackupDestination[];
startTime: Time;
endTime: Time;
expiryTime: Time;
}
export interface ResourceBackupStorage {
unit: string;
sourceSize: number;
logicalSize: number;
physicalSize: number;
}
export interface ResourceBackupRunDestination {
name: string;
id: string;
type: string;
status: string;
expiryTime: Time;
}
export interface ResourceBackupRun {
id: string;
backupTargets: ResourceBackupTarget[];
backupDestinations: ResourceBackupDestination[];
backupDestinations: ResourceBackupRunDestination[];
startTime: Time;
endTime: Time;
expiryTime: Time;
Expand All @@ -47,36 +50,52 @@ export interface ResourceBackupDestination {
id: string;
type: string;
status: string;
expiryTime: Time;
}
export interface ResourceIndirectBackupTarget {
type: string;
ids: string[];
keyValues: { [key: string]: string[] };
}
export interface ResourceBackupSource {
name: string;
id: string;
Uuid: string;
type: string;
}
export interface ResourceBackupTarget {
name: string;
id: string;
externalIds: { [key: string]: string };
externalId: string;
source?: ResourceBackupSource;
}
export interface ResourceBackupRetention {
unit: string;
duration: number;
}
export interface ResourceBackupSchedule {
startTime: string;
endTime: string;
frequency: number;
unit: string;
retention: ResourceBackupRetention;
}
export interface ResourceBackupJobStatus {
name: string;
status: string;
sourceName: string;
sourceId: string;
policyId: string;
policyName: string;
schedules: ResourceBackupSchedule[];
activeTargets: ResourceBackupTarget[];
indirectBackupTargets: ResourceIndirectBackupTarget[];
backupDestinations: ResourceBackupDestination[];
startTime: Time;
endTime: Time;
expiryTime: Time;
location: string;
lastUpdated: Time;
policyName: string;
runs: ResourceBackupRun[];
}
export interface ResourceBackupJob {
id: string;
provider: string;
source: string;
status: ResourceBackupJobStatus;
spec: ResourceBackupJobSpec;
}
Expand Down