omitempty

This commit is contained in:
mr 2024-07-22 16:39:26 +02:00
parent ebdbd97ce6
commit e44a6b65b7
5 changed files with 13 additions and 13 deletions

View File

@ -10,8 +10,8 @@ import (
type DataResource struct {
resources.AbstractResource
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
DataType string `json:"datatype,omitempty" bson:"datatype"`
Example string `json:"example,omitempty" bson:"example" description:"base64 encoded data"`
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"`
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"`
}
func (dma *DataResource) Deserialize(j map[string]interface{}) utils.DBObject {

View File

@ -9,7 +9,7 @@ import (
type DatacenterResource struct {
resources.AbstractResource
BookingPrice int `bson:"booking_price" json:"booking_price,omitempty"`
BookingPrice int `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
CPU *DatacenterCpuModel `bson:"cpu,omitempty" json:"cpu,omitempty"`
RAM *DatacenterMemoryModel `bson:"ram,omitempty" json:"ram,omitempty"`

View File

@ -16,12 +16,12 @@ type Resource interface {
type AbstractResource struct {
utils.AbstractObject
ShortDescription string `json:"short_description" bson:"short_description" validate:"required"`
Description string `json:"description,omitempty" bson:"description"`
Logo string `json:"logo" bson:"logo" validate:"required"`
Owner string `json:"owner" bson:"owner" validate:"required"`
OwnerLogo string `json:"owner_logo" bson:"owner_logo"`
SourceUrl string `json:"source_url" bson:"source_url" validate:"required"`
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
Description string `json:"description,omitempty" bson:"description,omitempty"`
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
}
func (r *AbstractResource) GetID() string {

View File

@ -8,8 +8,8 @@ import (
)
type URL struct {
Protocol string `bson:"protocol,omitempty" json:"protocol"`
Path string `bson:"path,omitempty" json:"path"`
Protocol string `bson:"protocol,omitempty" json:"protocol,omitempty"`
Path string `bson:"path,omitempty" json:"path,omitempty"`
}
type StorageResource struct {

View File

@ -11,8 +11,8 @@ import (
var validate = validator.New(validator.WithRequiredStructEnabled())
type AbstractObject struct {
UUID string `json:"id" required:"true" bson:"id" validate:"required"`
Name string `json:"name" required:"true" bson:"name" validate:"required"`
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
Name string `json:"name,omitempty" bson:"name,omitempty" validate:"required"`
}
func (ao *AbstractObject) GetID() string {