model

package
v0.0.0-...-d8ff57e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Association

type Association struct {
	Name                 string   `json:"name" yaml:"name"`
	Description          string   `json:"description" yaml:"description"`
	AssociationStatusUID string   `json:"associationStatusUID" yaml:"associationStatusUID"`
	AssociationModelUID  []string `json:"associationModelUID" yaml:"associationModelUID"`
}

type AssociationStatus

type AssociationStatus struct {
	Name                 string `json:"name" yaml:"name"`
	Description          string `json:"description" yaml:"description"`
	AssociationStatusUID string `json:"associationStatusUID" yaml:"associationStatusUID"`
}

type CIAssociationStatusManager

type CIAssociationStatusManager interface {
	List() (map[string]*AssociationStatus, error)

	Create(source *AssociationStatus) error
	Update(associationStatusUID string, source *AssociationStatus) error
	Retrivev(associationStatusUID string) (*AssociationStatus, error)
	Delete(associationStatusUID string) error
}

type CIModelAssociation

type CIModelAssociation interface {
	ListAssociation() (map[string]*Association, error)

	AddAssociation(relateModelUID, associationStatusUID string) error
	RetrieveAssociation(associationStatusUID string) (*Association, error)
	DeleteAssociation(associationUID string) error
}

CIModelAssociation is associated with other model.

type CIModelField

type CIModelField interface {
	ListFiled() (map[string]*Field, error)

	AddField(field *Field) error
	UpdateFiled(fieldUID string, field *Field) error
	RetrieveField(fieldUID string) (*Field, error)
	DeleteField(fieldUID string) error
}

CIModelField is all information of the collection model, not storing actual content.

type CIModelManager

type CIModelManager interface {
	List() (map[string]*Model, error)

	Create(metadata *Metadata) error

	// Update replace the metadata of the model.
	//
	// UID related update operations should not be supported to avoid state confusion.
	// UID modification should be achieved through reconstruction (both direct modification
	// and reconstruction will result in a large number of DB operations).
	//
	// The version operation decision related to revision should be
	// completed by the routing time, so this method only performs execution.
	Update(modelUID string, metadata *Metadata) error

	// Retrieve query model related data from DB.
	//
	// Default Only obtain metadata of the model to ensure overall performance,
	// other relevant information is only obtained and used separately.
	Retrieve(modelUID string, withData bool) (*Model, error)

	Delete(modelUID string) error // TODO: need support soft delete?

	SerializeExport(modelUID, exportType string, withData bool) (string, error)
	SerializeImport(source string) (*Model, error)
}

CIModelManager manager configuration item model.

type CIModelResource

type CIModelResource interface {
	ListResource() (map[string]*Resource, error)

	AddResource(resource *Resource) error
	UpdateResource(resourceUID string, resource *Resource) error
	RetrieveResource(resourceUID string) (*Resource, error)
	DeleteResource(resourceUID string) error
}

CIModelResource is all resource allocation items of the model.

type Field

type Field struct {
	Name string `json:"name" yaml:"name"`

	// FieldUID global unique field identification.
	//
	// Cannot be updated.
	FieldUID string `json:"fieldUID" yaml:"fieldUID"`

	IsEditable  bool   `json:"isEditable" yaml:"isEditable"`
	IsOptional  bool   `json:"isOptional" yaml:"isOptional"`
	Description string `json:"description" yaml:"description"`
}

type Metadata

type Metadata struct {
	// FieldUID global unique identifier of the model.
	//
	// Cannot be updated.
	UID string `json:"uid" yaml:"uid"`

	Name           string `json:"name" yaml:"name"`
	GroupUID       string `json:"groupUID" yaml:"groupUID"`
	IsBuiltin      bool   `json:"isBuiltin" yaml:"isBuiltin"`
	CreateTime     int64  `json:"createTime" yaml:"createTime"`
	LastUpdateTime int64  `json:"lastUpdateTime" yaml:"lastUpdateTime"`

	// Revision starts from 0 and records the updated version of the model,
	// which must be carried in both requests and responses.
	//
	// Before executing the update operation, it is necessary to first
	// obtain an existing revision. If it exceeds the amount carried by
	// the request, it will prompt to overwrite. If user agree to overwrite,
	// update the revision to the latest value(ensuring that SQL can execute
	// based on conditional judgment).
	//
	// When submitting an operation, SQL needs to add a revision equal to
	// the value obtained before executing and self increasing the revision.
	Revision string `json:"revision" yaml:"revision"`
}

type Model

type Model struct {
	Metadata Metadata `json:"metadata" yaml:"metadata"`

	// Field is all information of the collection model, not storing actual content.
	// Key is the UID corresponding to the Field.
	//
	// Updating fields depends on the revision of the model, ensuring the
	// accuracy of model configuration. And when updating the fields,
	// should be treated as the overall metadata update of the model.
	Field map[string]*Field `json:"field" yaml:"field"`

	// Resource is all resource allocation items of the Model.
	// Key is the UID corresponding to the Resource.
	//
	// Resource is just a collection of all the field contents of the model,
	// which is divided into automatic collection and manual maintenance.
	Resource map[string]*Resource `json:"resource" yaml:"resource"`

	// Association is associated with other Model.
	// Key is the UID corresponding to the Association.
	Association map[string]*Association `json:"association" yaml:"association"`
}

Model resource data model storage format.

Model should support JSON/YAML formatting for field sharing and custom data collector.

type Resource

type Resource struct {
	// ResourceUID global identification of resources.
	//
	// Cannot be updated.
	ResourceUID string `json:"resourceUID" yaml:"resourceUID"`

	// ResourceUID global identification of collection.
	//
	// Cannot be updated.
	DataCollectionUID string `json:"dataCollectionUID" yaml:"dataCollectionUID"`

	IsAutoCollected bool `json:"isAutoCollected" yaml:"isAutoCollected"`

	// FieldConenct store all field content as string data type.
	//
	// Any call or parsing at any position requires prior data conversion,
	// especially for integers and floating-point numbers.
	FieldConenct map[string]string `json:"fieldConenct" yaml:"fieldConenct"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL