@startuml
autonumber

actor "API User"
participant "Rapp Manager"
collections "File System"
participant "ACM Runtime"
participant "A1PMS Participant"
participant "Kserve Participant"
participant "K8s Participant"
participant "CAPIF"

autonumber
group Create Rapp Instance
"API User"->"Rapp Manager": Create Rapp Instance
"Rapp Manager"->"API User": Create Rapp Instance response
end

autonumber
group Deploy Rapp Instance
"API User"->"Rapp Manager": Deploy Rapp Instance
"Rapp Manager"->"File System": Fetch Rapp Package and Instance details
    group ACM Deploy
        "Rapp Manager"->"ACM Runtime": Instantiate and Deploy ACM Instance
        "ACM Runtime"->"A1PMS Participant": Deploy ACM Instance
        "ACM Runtime"<--"A1PMS Participant": Response
        "ACM Runtime"->"Kserve Participant": Deploy ACM Instance
        "ACM Runtime"<--"Kserve Participant": Response
        "ACM Runtime"->"K8s Participant": Deploy ACM Instance
        "ACM Runtime"<--"K8s Participant": Response
        "Rapp Manager"->"ACM Runtime": ACM Deployment Status
    end

    group SME Deploy
    "Rapp Manager"->"CAPIF": Create CAPIF entities
    "CAPIF"->"CAPIF": Create the entities as provided
    "Rapp Manager"<-"CAPIF": Response of CAPIF entities creation
    end
"API User"<-"Rapp Manager": Deploy Rapp Instance Status
end

autonumber
group Undeploy Rapp Instance
"API User"->"Rapp Manager": Undeploy Rapp Instance
"Rapp Manager"->"File System": Fetch Rapp Package and Instance details
    group ACM Undeploy
        "Rapp Manager"->"ACM Runtime": Undeploy ACM Instance
        "ACM Runtime"->"A1PMS Participant": Undeploy ACM Instance
        "ACM Runtime"<--"A1PMS Participant": Response
        "ACM Runtime"->"Kserve Participant": Undeploy ACM Instance
        "ACM Runtime"<--"Kserve Participant": Response
        "ACM Runtime"->"K8s Participant": Undeploy ACM Instance
        "ACM Runtime"<--"K8s Participant": Response
        "Rapp Manager"->"ACM Runtime": ACM Undeployment Status
        "Rapp Manager"->"ACM Runtime": Delete ACM Instance
        "Rapp Manager"<-"ACM Runtime": Delete ACM Instance response
    end

    group SME Undeploy
    "Rapp Manager"->"CAPIF": Delete CAPIF entities
    "CAPIF"->"CAPIF": Delete the entities as provided
    "Rapp Manager"<-"CAPIF": Response of CAPIF entities Deletion
    end
"API User"<-"Rapp Manager": Undeploy Rapp Instance Status
end

autonumber
group Delete Rapp Instance
"API User"->"Rapp Manager": Delete Rapp Instance
"Rapp Manager"->"API User": Delete Rapp Instance response
end

@enduml
