@startuml

title "Karbor API model"

class Protectable {
    name: string
    instances: []Resource
    is_root: bool
}

Protectable --> Resource: lists

class Resource {
    id: UUID
    type: ResourceType
    schema: JSONSchema
    dependent_resources: []Resource
}

class Trigger {
}

class TimedTrigger extends Trigger {

}

class EventTrigger extends Trigger {

}

class Checkpoint {
    id: UUID
    tenant_id: UUID
    plan: ProtectionPlan
    status: string
    started_at: DateTime
}

Checkpoint *-> ProtectionPlan: stores a copy of

class AutomaticOperation {
    id: UUID
    name: string
    description: string
    tenant_id: UUID
}

class ScheduledOperation <<abstract>> extends AutomaticOperation {
        trigger: Trigger
}

ScheduledOperation *- Trigger: when should the operation should trigger


class BackupPlan extends ScheduledOperation {
    protection_plan: ProtectionPlan
}

BackupPlan *--> ProtectionPlan

class DeleteCheckpoints extends ScheduledOperation {
    query: string
    protection_provider: ProtectionProvider
}


class ProtectionProvider {
    name: string
    description: string
    extended_info_schema: [ResourceType]JSONSchema
}

ProtectionProvider o-> Checkpoint: lists

class ProtectionPlan {
    id: UUID
    is_enabled: boolean
    name: string
    status: ePlanStatus
    resources: []Resource
    protection_provider: ProtectionProvider
    parameters: dict
}

ProtectionPlan "1" *--> "N" Resource: aggregates
ProtectionPlan -> ProtectionProvider
ProtectionPlan -> ePlanStatus

enum ePlanStatus {
    started
    suspended
}

class RestoreTarget {
    keystone_uri: URI
}

class Restore {
    id: UUID
    project_id: UUID
    target: RestoreTarget
    provider: ProtectionProvider
    checkpoint: Checkpoint
    started_at: string
}

Restore *-> RestoreTarget: restores to

@enduml
