oc-lib/models/discovery/discovery.go
2024-08-22 13:11:21 +02:00

55 lines
1.1 KiB
Go

package discovery
import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools"
"github.com/google/uuid"
)
type Discovery struct {
utils.AbstractObject
Host string `json:"host,omitempty" bson:"host,omitempty"`
Port string `json:"port,omitempty" bson:"port,omitempty"`
State int `json:"state,omitempty" bson:"state,omitempty"`
}
func (ao *Discovery) GetID() string {
return ao.UUID
}
func (r *Discovery) GenerateID() {
r.UUID = uuid.New().String()
}
func (d *Discovery) GetName() string {
return d.Name
}
func (d *Discovery) GetAccessor(caller *tools.HTTPCaller) utils.Accessor {
data := New()
data.Init(utils.BOOKING, caller)
return data
}
func (dma *Discovery) Deserialize(j map[string]interface{}) utils.DBObject {
d := &Discovery{}
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, d)
return d
}
func (dma *Discovery) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
return nil
}
json.Unmarshal(b, &m)
return m
}