apis

package
v0.0.0-...-4de6f6b Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const MaximumLimit = 10000

MaximumLimit define pagination limit

View Source
const QueryParamKeyword = "keyword"

QueryParamKeyword ...param for keyword query

Variables

This section is empty.

Functions

func CheckKeys

func CheckKeys(keys []string, data map[string]interface{}) error

CheckKeys checks if keys exist

func CreateFieldsQuery

func CreateFieldsQuery(fieldlist string, metafieldslist []MetadataField, tabs int) ([]string, error)

CreateFieldsQuery translates the fields part of the qsl string to dgraph input @name,@resourceversion, metadata fields for this block's object type, creates a list of the fields of an object we want to return will be joined with newlines for the resulting query e.g. @name,@resourceversion -> [name, resourceversion]

func CreateFiltersQuery

func CreateFiltersQuery(filterlist string) (string, string, error)

CreateFiltersQuery translates the filters part of the qsl string to dgraph input @name="name",@objtype="objtype"$$limit=2,offset=2 filterfunc @name="cluster1" -> eq(name,cluster1) @name="paas-preprod-west2.cluster.k8s.local",@k8sobj="K8sObj",@resourceid="paas-preprod-west2.cluster.k8s.local" -> @filter( eq(name,paas-preprod-west2.cluster.k8s.local) and eq(k8sobj,K8sObj) and eq(resourceid,paas-preprod-west2.cluster.k8s.local) ) filterdeclaraction @name="paas-preprod-west2.cluster.k8s.local",@k8sobj="K8sObj",@resourceid="paas-preprod-west2.cluster.k8s.local" -> , $name: string, $k8sobj: string, $resourceid: string pagination $$limit=2,offset=2 -> first: 2,offset: 2

func GetTotalCnt

func GetTotalCnt(data map[string]interface{}) float64

GetTotalCnt find count from returned value

func IsAlphaNum

func IsAlphaNum(s string) bool

IsAlphaNum determine if string is made up of only alphanumeric characters

func IsStar

func IsStar(s string) bool

IsStar determine if string is made up of only *

func SetDefaultKey

func SetDefaultKey(dkMap map[string]interface{}, data map[string]interface{}) error

SetDefaultKey sets default values for the keys if any isn't set

Types

type EntityService

type EntityService struct {
	// contains filtered or unexported fields
}

EntityService provides service for controller and frontend by implement IEntityService interface

func NewEntityService

func NewEntityService(dc db.IDGClient) *EntityService

NewEntityService creates a new EntityService with the given dgraph client.

func (EntityService) CreateEntity

func (s EntityService) CreateEntity(meta string, data map[string]interface{}) (string, error)

CreateEntity save new entity to the storage

func (EntityService) CreateOrDeleteEdge

func (s EntityService) CreateOrDeleteEdge(fromType string, fromUID string, toType, toUID string, rel string, op db.Action) error

CreateOrDeleteEdge create or remove edge

func (EntityService) DeleteEntity

func (s EntityService) DeleteEntity(uuid string) error

DeleteEntity remove object with given ID

func (EntityService) DeleteEntityByResourceID

func (s EntityService) DeleteEntityByResourceID(meta string, rid string) error

DeleteEntityByResourceID remove object by given resourceid

func (EntityService) GetEntity

func (s EntityService) GetEntity(uuid string) (map[string]interface{}, error)

GetEntity get entity return the object with specified ID

func (EntityService) SyncEntities

func (s EntityService) SyncEntities(meta string, data []map[string]interface{}) error

SyncEntities ...

func (EntityService) UpdateEntity

func (s EntityService) UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext) error

UpdateEntity update entity

type IEntityService

type IEntityService interface {
	// get entity return the object with specified ID
	GetEntity(uid string) (map[string]interface{}, error)
	// remove object with given ID
	DeleteEntity(uid string) error
	// remove object with given ID
	DeleteEntityByResourceID(rid string) error
	// save new entity to the storage
	CreateEntity(meta string, data map[string]interface{}) (string, error)
	// update entity with given ID in the storage
	UpdateEntity(uuid string, data map[string]interface{}, option ...util.OptionContext)
	// create or remove relationship between entities by given IDs
	CreateOrDeleteEdge(fromUID string, toUID string, rel string, op db.Action) error
	// sync data between source and underlying database
	SyncEntities(meta string, data map[string]interface{}) error
}

IEntityService define interfaces to manipulate data

type IMetaService

type IMetaService interface {
	// Get metadata by name
	GetMetadata(name string) (*Metadata, error)
	// Create new metadata
	CreateMetadata(data Metadata) (string, error)
	// Delete metadata
	DeleteMetadata(name string) error
	// Update metadata
	UpdateMetadata(name string, data map[string]interface{}) error
	// Get all metadata fields
	GetMetadataFields(name string) ([]MetadataField, error)
	// Create schema
	CreateSchema(sm db.Schema) error
	// Drop a schema
	DropSchema(name string) error
	// Remove schema from cache
	RemoveSchemaCache(cache *lru.Cache)
}

IMetaService define interfaces for metadata

type IQueryService

type IQueryService interface {
	GetQueryResult(queryMap map[string][]string) (map[string]interface{}, error)
}

IQueryService ...define interfaces to query data

type MetaService

type MetaService struct {
	// contains filtered or unexported fields
}

MetaService implements IMetaService interface

func NewMetaService

func NewMetaService(dc db.IDGClient) *MetaService

NewMetaService creates a new MetaService with the given dgraph client.

func (MetaService) CreateMetadata

func (s MetaService) CreateMetadata(data map[string]interface{}) (string, error)

CreateMetadata save new metadata to the storage

func (MetaService) CreateSchema

func (s MetaService) CreateSchema(sm db.Schema) error

CreateSchema creates schema

func (MetaService) DeleteMetadata

func (s MetaService) DeleteMetadata(name string) error

DeleteMetadata to remove metadata if not been referenced by others

func (MetaService) DropSchema

func (s MetaService) DropSchema(name string) error

DropSchema to remove schema

func (MetaService) GetMetadata

func (s MetaService) GetMetadata(name string) (*Metadata, error)

GetMetadata get entity return the object with specified ID

func (MetaService) GetMetadataFields

func (s MetaService) GetMetadataFields(name string) ([]MetadataField, error)

GetMetadataFields EntityService will call this method to get all fields to verify and create edge accordingly

func (MetaService) RemoveSchemaCache

func (s MetaService) RemoveSchemaCache(cache *lru.Cache)

RemoveSchemaCache to clean lru cache

func (MetaService) UpdateMetadata

func (s MetaService) UpdateMetadata(name string, data map[string]interface{}) error

UpdateMetadata update metadata fields The payload can include either new fields or existing fields

type Metadata

type Metadata struct {
	UID             string          `json:"uid"`
	Name            string          `json:"name"`
	ObjType         string          `json:"objtype,omitempty"`
	Fields          []MetadataField `json:"fields,omitempty"`
	ResourceVersion string          `json:"resourceversion,omitempty"`
}

Metadata Describe metadata

type MetadataField

type MetadataField struct {
	UID       string `json:"uid"`
	FieldName string `json:"fieldname"`
	// Type of filed, could be one of [int, long, string, json, double, bool, date, enum, relationship]
	FieldType string `json:"fieldtype"`
	// The field is required if value is true
	Mandatory bool `json:"mandatory"`
	// If FieldType is relationship, need to set reference object type
	RefDataType string `json:"refdatatype,omitempty"`
	// One or Many
	Cardinality string `json:"cardinality,omitempty"`
}

MetadataField describe attributes of Metadata

type QSLService

type QSLService struct {
	DBclient db.IDGClient
}

QSLService service for QSL

func NewQSLService

func NewQSLService(host db.IDGClient) *QSLService

NewQSLService creates an instance of a QSLService

func (*QSLService) CreateDgraphQuery

func (qa *QSLService) CreateDgraphQuery(query string, cntOnly bool) (string, error)

CreateDgraphQuery translates the querystring to a dgraph query

func (*QSLService) GetMetadata

func (qa *QSLService) GetMetadata(objtype string) ([]MetadataField, error)

GetMetadata - get a list of the fields supoorted for this object type

type QueryService

type QueryService struct {
	// contains filtered or unexported fields
}

QueryService ...

func NewQueryService

func NewQueryService(dc db.IDGClient) *QueryService

NewQueryService ...Create NewQueryService

func (QueryService) GetQueryResult

func (s QueryService) GetQueryResult(queryMap map[string][]string) (map[string]interface{}, error)

GetQueryResult ...Api to get Query Results

Jump to

Keyboard shortcuts

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