v2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BootstrappedService = "V2 Service"

BootstrappedService key maps to the Service implementation in Bootstrap context.

View Source
const ErrInvalidRoleID = errors.Error("Invalid RoleID")

ErrInvalidRoleID for invalid roleID in the api path.

View Source
const ErrInvalidRuleID = errors.Error("Invalid Transition Rule ID")

ErrInvalidRuleID for invalid ruleID in the api path.

View Source
const RoleIDParam = "role_id"

RoleIDParam is the key for roleID in the API path.

View Source
const RuleIDParam = "rule_id"

RuleIDParam is the key for ruleID in the API path.

Variables

This section is empty.

Functions

func Register

func Register(ctx map[string]interface{}, r chi.Router)

Register registers the core apis to the router.

Types

type AddRole

type AddRole struct {
	// Key is either hex encoded 32 byte ID or string label.
	// String label is used as a preimage to sha256 for 32 byte hash.
	Key           string         `json:"key"`
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

AddRole used for marshalling add request for role.

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

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

Bootstrap adds transaction.Repository into context.

type CreateDocumentRequest

type CreateDocumentRequest struct {
	DocumentRequest
	DocumentID byteutils.OptionalHex `json:"document_id" swaggertype:"primitive,string"` // if provided, creates the next version of the document.
}

CreateDocumentRequest defines the payload for creating documents.

type DocumentRequest

type DocumentRequest = coreapi.CreateDocumentRequest

DocumentRequest is an alias to coreapi Document request. Aliased here to fix the swagger generation issues.

type RemoveCollaboratorsRequest

type RemoveCollaboratorsRequest struct {
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

RemoveCollaboratorsRequest contains the list of collaborators that are to be removed from the document

type Role

type Role struct {
	ID            byteutils.HexBytes   `json:"id" swaggertype:"primitive,string"`
	Collaborators []byteutils.HexBytes `json:"collaborators" swaggertype:"array,string"`
}

Role is a single role in the document.

type Service

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

Service is the entry point for all the V2 APIs.

func (Service) AddRole

func (s Service) AddRole(ctx context.Context, docID []byte, roleKey string, dids []identity.DID) (*coredocumentpb.Role, error)

AddRole adds a new role to the document

func (Service) AddSignedAttribute

func (s Service) AddSignedAttribute(ctx context.Context, docID []byte, label string, payload []byte, valType documents.AttributeType) (documents.Model, error)

AddSignedAttribute signs the payload with acc signing key and add it the document associated with docID.

func (Service) AddTransitionRules

func (s Service) AddTransitionRules(
	ctx context.Context, docID []byte, addRules pending.AddTransitionRules) ([]*coredocumentpb.TransitionRule, error)

AddTransitionRules adds new rules to the document

func (Service) Commit

func (s Service) Commit(ctx context.Context, docID []byte) (documents.Model, jobs.JobID, error)

Commit creates a document out of a pending document.

func (Service) CreateDocument

func (s Service) CreateDocument(ctx context.Context, req documents.UpdatePayload) (documents.Model, error)

CreateDocument creates a pending document from the given payload. if the document_id is provided, next version of the document is created.

func (Service) DeleteTransitionRule

func (s Service) DeleteTransitionRule(ctx context.Context, docID, ruleID []byte) error

DeleteTransitionRule deletes the transition rule associated with ruleID from the document.

func (Service) GetDocument

func (s Service) GetDocument(ctx context.Context, docID []byte, status documents.Status) (documents.Model, error)

GetDocument returns the document associated with docID and status.

func (Service) GetDocumentVersion

func (s Service) GetDocumentVersion(ctx context.Context, docID, versionID []byte) (documents.Model, error)

GetDocumentVersion returns the specific version of the document.

func (Service) GetRole

func (s Service) GetRole(ctx context.Context, docID, roleID []byte) (*coredocumentpb.Role, error)

GetRole gets the role from the document

func (Service) GetTransitionRule

func (s Service) GetTransitionRule(ctx context.Context, docID, ruleID []byte) (*coredocumentpb.TransitionRule, error)

GetTransitionRule returns the transition rule associated with ruleID in the document.

func (Service) RemoveCollaborators

func (s Service) RemoveCollaborators(ctx context.Context, docID []byte, dids []identity.DID) (documents.Model, error)

RemoveCollaborators removes collaborators from the document.

func (Service) UpdateDocument

func (s Service) UpdateDocument(ctx context.Context, req documents.UpdatePayload) (documents.Model, error)

UpdateDocument updates a pending document with the given payload

func (Service) UpdateRole

func (s Service) UpdateRole(ctx context.Context, docID, roleID []byte, dids []identity.DID) (*coredocumentpb.Role, error)

UpdateRole updates the role in the document

type SignedAttributeRequest

type SignedAttributeRequest struct {
	Label   string `json:"label"`
	Type    string `json:"type" enums:"integer,string,bytes,timestamp"`
	Payload string `json:"payload"`
}

SignedAttributeRequest contains the payload to be signed and added to the document.

type TransitionRule

type TransitionRule struct {
	RuleID byteutils.HexBytes   `json:"rule_id" swaggertype:"primitive,string"`
	Roles  []byteutils.HexBytes `json:"roles" swaggertype:"array,string"`
	Field  byteutils.HexBytes   `json:"field" swaggertype:"primitive,string"`
	Action string               `json:"action"`
}

TransitionRule holds the ruleID, roles, and fields in hex format

type TransitionRules

type TransitionRules struct {
	Rules []TransitionRule `json:"rules"`
}

TransitionRules holds the list of transition rule.

type UpdateDocumentRequest

type UpdateDocumentRequest struct {
	DocumentRequest
}

UpdateDocumentRequest defines the payload to patch an existing document.

type UpdateRole

type UpdateRole struct {
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

UpdateRole holds the collaborators that are to be replaced with older one in the role.

Jump to

Keyboard shortcuts

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