2024-04-11 16:34:43 +02:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
2024-04-15 11:42:17 +02:00
|
|
|
"cloud.o-forge.io/core/oc-catalog/models/rtype"
|
2024-04-11 16:34:43 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Link struct {
|
2024-04-15 11:42:17 +02:00
|
|
|
// ID primitive.ObjectID `json:"ID" bson:"_id" required:"true" example:"5099803df3f4948bd2f98391"`
|
|
|
|
Source string `json:"source" description:"id in the workflow of the source object"`
|
|
|
|
Destination string `json:"destination" description:"id in the workflow of the destination object"`
|
|
|
|
DCLink bool `json:"dcLink" description:"is this a link with a datacenter"`
|
2024-04-11 16:34:43 +02:00
|
|
|
}
|
|
|
|
|
2024-04-15 11:42:17 +02:00
|
|
|
// Use ResourceObject parameter to process certain components type differently
|
|
|
|
// and Id's to identify each component as a node in an oriented graph
|
2024-04-11 16:34:43 +02:00
|
|
|
|
2024-04-15 11:42:17 +02:00
|
|
|
func NewLink(src ResourceObject, srcId string, dst ResourceObject, dstId string) (link Link) {
|
|
|
|
|
|
|
|
link.Source = srcId
|
|
|
|
link.Destination = dstId
|
|
|
|
|
|
|
|
if (src.getRtype() == rtype.DATACENTER || dst.getRtype() == rtype.DATACENTER){
|
|
|
|
link.DCLink = true
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-04-11 16:34:43 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-04-15 11:42:17 +02:00
|
|
|
// So far only computing components expect the ID of the DC in their attributes
|
|
|
|
// func (l *Link) AddLinkToDataCenter(component models.ComputingModel) {
|
|
|
|
// }
|
2024-04-11 16:34:43 +02:00
|
|
|
|