entityrelationship

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrERNotFound must be used to indicate that entity relationship for provided id is not found in the system
	ErrERNotFound = errors.Error("entity relationship not found in the system database.")

	// ErrERInvalidIdentifier must be used to indicate different identifier
	ErrERInvalidIdentifier = errors.Error("entity relationship contains different entity identifier")

	// ErrERNoToken must be used to indicate missing tokens
	ErrERNoToken = errors.Error("entity relationship contains no access token")

	// ErrNotEntityRelationship must be used if an expected entityRelationship model is not a entityRelationship
	ErrNotEntityRelationship = errors.Error("model not entity relationship")
)
View Source
const (

	// Scheme to identify entity relationship
	Scheme = prefix

	// ErrEntityRelationshipUpdate is a sentinel error for update failure.
	ErrEntityRelationshipUpdate = errors.Error("Entity relationship doesn't support updates.")
)
View Source
const (
	// BootstrappedEntityRelationshipService maps to the service for entity relationships
	BootstrappedEntityRelationshipService string = "BootstrappedEntityRelationshipService"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap sets the required storage and registers

type Data added in v1.0.0

type Data struct {
	// Owner of the relationship
	OwnerIdentity *identity.DID `json:"owner_identity" swaggertype:"primitive,string"`
	// Entity identifier
	EntityIdentifier byteutils.HexBytes `json:"entity_identifier" swaggertype:"primitive,string"`
	// identity which will be granted access
	TargetIdentity *identity.DID `json:"target_identity" swaggertype:"primitive,string"`
}

Data represents entity relationship data

type EntityRelationship

type EntityRelationship struct {
	*documents.CoreDocument

	Data Data `json:"data"`
}

EntityRelationship implements the documents.Document and keeps track of entity-relationship related fields and state.

func (*EntityRelationship) AddAttributes added in v1.0.0

func (e *EntityRelationship) AddAttributes(ca documents.CollaboratorsAccess, prepareNewVersion bool, attrs ...documents.Attribute) error

AddAttributes adds attributes to the EntityRelationship model.

func (*EntityRelationship) AddNFT

AddNFT is not implemented for EntityRelationship

func (*EntityRelationship) CalculateDocumentRoot

func (e *EntityRelationship) CalculateDocumentRoot() ([]byte, error)

CalculateDocumentRoot calculates the document root.

func (*EntityRelationship) CalculateSigningRoot

func (e *EntityRelationship) CalculateSigningRoot() ([]byte, error)

CalculateSigningRoot calculates the signing root of the document.

func (*EntityRelationship) CollaboratorCanUpdate

func (e *EntityRelationship) CollaboratorCanUpdate(updated documents.Document, identity identity.DID) error

CollaboratorCanUpdate checks that the identity attempting to update the document is the identity which owns the document.

func (*EntityRelationship) CreateNFTProofs

func (e *EntityRelationship) CreateNFTProofs(identity.DID, common.Address, []byte, bool, bool) (prf *documents.DocumentProof, err error)

CreateNFTProofs is not implemented for EntityRelationship.

func (*EntityRelationship) CreateProofs

func (e *EntityRelationship) CreateProofs(fields []string) (prf *documents.DocumentProof, err error)

CreateProofs generates proofs for given fields.

func (*EntityRelationship) DeleteAttribute added in v1.0.0

func (e *EntityRelationship) DeleteAttribute(key documents.AttrKey, prepareNewVersion bool) error

DeleteAttribute deletes the attribute from the model.

func (*EntityRelationship) DeriveFromClonePayload added in v1.3.0

func (e *EntityRelationship) DeriveFromClonePayload(_ context.Context, doc documents.Document) error

DeriveFromClonePayload clones a new document.

func (*EntityRelationship) DeriveFromCreatePayload added in v1.0.0

func (e *EntityRelationship) DeriveFromCreatePayload(ctx context.Context, payload documents.CreatePayload) error

DeriveFromCreatePayload unpacks the entity relationship data from the Payload.

func (*EntityRelationship) DeriveFromUpdatePayload added in v1.0.0

func (e *EntityRelationship) DeriveFromUpdatePayload(_ context.Context, payload documents.UpdatePayload) (documents.Document, error)

DeriveFromUpdatePayload removes any access tokens assigned to target did

func (*EntityRelationship) DocumentType

func (*EntityRelationship) DocumentType() string

DocumentType returns the entity relationship document type.

func (*EntityRelationship) FromJSON

func (e *EntityRelationship) FromJSON(jsonData []byte) error

FromJSON unmarshals the json bytes into EntityRelationship

func (*EntityRelationship) GetData added in v1.0.0

func (e *EntityRelationship) GetData() interface{}

GetData returns entity relationship data

func (*EntityRelationship) JSON

func (e *EntityRelationship) JSON() ([]byte, error)

JSON marshals EntityRelationship into a json bytes

func (*EntityRelationship) PackCoreDocument

func (e *EntityRelationship) PackCoreDocument() (cd coredocumentpb.CoreDocument, err error)

PackCoreDocument packs the EntityRelationship into a CoreDocument.

func (*EntityRelationship) Patch added in v1.0.0

func (e *EntityRelationship) Patch(payload documents.UpdatePayload) error

Patch merges payload data into Document.

func (*EntityRelationship) Scheme added in v1.0.0

func (e *EntityRelationship) Scheme() string

Scheme returns the entity relationship scheme.

func (*EntityRelationship) Type

func (e *EntityRelationship) Type() reflect.Type

Type gives the EntityRelationship type.

func (*EntityRelationship) UnpackCoreDocument

func (e *EntityRelationship) UnpackCoreDocument(cd coredocumentpb.CoreDocument) error

UnpackCoreDocument unpacks the core document into an EntityRelationship.

type Service

type Service interface {
	documents.Service

	// GetEntityRelationships returns a list of the latest versions of the relevant entity relationship based on an entity id
	GetEntityRelationships(ctx context.Context, entityID []byte) ([]documents.Document, error)
}

Service defines specific functions for entity

func DefaultService

func DefaultService(
	srv documents.Service,
	repo repository,
	factory identity.Factory,
	anchorSrv anchors.Service,
) Service

DefaultService returns the default implementation of the service.

Jump to

Keyboard shortcuts

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