catalogc

package
v0.0.0-...-21eebf0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContractCatalogID = "odysseycatalog"

ContractCatalogID denotes a contract that can store a catalog of owners and datasets

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	ID          string `json:"id"`
	Description string `json:"description"`
	Type        string `json:"type"`
	RuleType    string `json:"rule_type"`
	Name        string `json:"name"`
	Value       string `json:"value"`
	// If true the attribute is not enforced automatically by comparing the
	// attributes in the DARC, but it uses one of the attributes in the
	// DelegatedEnforcement struct.
	DelegatedEnforcement bool           `json:"delegated_enforcement"`
	FailedReasons        *FailedReasons `json:"failed_reasons"`
	Attributes           []*Attribute   `json:"attributes"`
}

Attribute ...

func (*Attribute) AddFailedReason

func (a *Attribute) AddFailedReason(attributeID, reason, dataset string)

AddFailedReason safely adds a reason to the list of failed reasons

func (*Attribute) ConsumerForm

func (a *Attribute) ConsumerForm(m *Metadata) string

ConsumerForm is like Form(), but it does not print attributes that have "ManualEnforcment" set to true.

func (Attribute) Darc

func (a Attribute) Darc(calypsoWriteID string) string

Darc outputs a DARC string representation of this attribute. Text field must have uniq ids acroos different datasets, that is why we append the calypsoWriteID. Does NOT browse its sub-attributes

func (Attribute) Form

func (a Attribute) Form() string

Form print the HTML field form element of an attribute and its sub attributes

func (Attribute) FoundName

func (a Attribute) FoundName(name string) bool

FoundName checks if this attribute or its subattributes use this name

func (*Attribute) GetActiveAttributesByRuleType

func (a *Attribute) GetActiveAttributesByRuleType(ruleType string) []*Attribute

GetActiveAttributesByRuleType return the attributes that have the given rule type and that has a value.

func (*Attribute) GetAttribute

func (a *Attribute) GetAttribute(id string) (*Attribute, bool)

GetAttribute return the first attribute found that has the given id

func (*Attribute) GetAttributeByValue

func (a *Attribute) GetAttributeByValue(value string) (*Attribute, bool)

GetAttributeByValue return the first attribute found that has the given id

func (*Attribute) GetAttributesByName

func (a *Attribute) GetAttributesByName(name string) []*Attribute

GetAttributesByName return the attributes with the given name

func (Attribute) HasFailedReasons

func (a Attribute) HasFailedReasons() bool

HasFailedReasons returns true if it has any failed reasons

func (Attribute) HasFilledSubattributes

func (a Attribute) HasFilledSubattributes() bool

HasFilledSubattributes checks if any of the sub-aatributes of this attribute has a value. This is convenient to gray out a sub form in case there isn't any sub-attributes filled.

func (*Attribute) Reset

func (a *Attribute) Reset()

Reset reset the value field of this attribute and all its sub-attributes

func (*Attribute) ResetFailedReasons

func (a *Attribute) ResetFailedReasons()

ResetFailedReasons set the FailedReason field of this attribute and its subattributes to an empty slice

func (Attribute) String

func (a Attribute) String() string

func (*Attribute) TryUpdate

func (a *Attribute) TryUpdate(key, val string)

TryUpdate update an attribute, if the key is found, by the value

type AttributesGroup

type AttributesGroup struct {
	Title               string       `json:"title"`
	Description         string       `json:"description"`
	ConsumerDescription string       `json:"consumer_description"`
	Attributes          []*Attribute `json:"attributes"`
}

AttributesGroup ...

func (AttributesGroup) String

func (ag AttributesGroup) String() string

type AuditBlock

type AuditBlock struct {
	BlockIndex int
	// The number of blocks before the previous in the list. If the current block
	// has an index of 7 and the previous one in the list has an index of 5, then
	// the delta is 1. This is handy for go templates where we cannot do
	// aritmetic operations. The first one has a value of -1.
	DeltaPrevious int
	// The number of blocks after the next in the list. The last one has a value
	// of -1.
	DeltaNext    int
	Transactions []*AuditTransaction
}

AuditBlock is a tailored version of a skipblock that we need to display something interesting

type AuditData

type AuditData struct {
	// BlocksChecked is the number of blocks checked
	BlocksChecked int
	// OccFound is the number of blocks concerned
	OccFound int
	// Blocks contains the list of audit blocks
	Blocks []*AuditBlock
}

AuditData is used by the catadmin cli to return audit infos

type AuditTransaction

type AuditTransaction struct {
	Accepted     bool
	Instructions []*byzcoin.Instruction
}

AuditTransaction is a tailored version of a transaction for audit

type CatalogData

type CatalogData struct {
	Owners   []*Owner
	Metadata *Metadata
}

CatalogData holds the data of the Odyssey catalog contract

func (*CatalogData) AddOwner

func (cd *CatalogData) AddOwner(owner *Owner) error

AddOwner adds a new owner if not already present

func (CatalogData) GetOwner

func (cd CatalogData) GetOwner(identityStr string) *Owner

GetOwner returns the owner if found, or nil

func (*CatalogData) RemoveOwner

func (cd *CatalogData) RemoveOwner(identityStr string) error

RemoveOwner removes an owner from the list of owners

func (CatalogData) String

func (cd CatalogData) String() string

String returns a human readable string representation of the project data

type Dataset

type Dataset struct {
	CalypsoWriteID string `json:"calypsoWriteID"`
	Title          string `json:"title"`
	Description    string `json:"description"`
	CloudURL       string `json:"cloudURL"`
	// This is the signer identity that owns the dataset, like 'ed25519:aef123'
	IdentityStr string    `json:"identityStr"`
	SHA2        string    `json:"sha2"`
	IsArchived  bool      `json:"is_archived"`
	Metadata    *Metadata `json:"metadata"`
}

Dataset describes the metadata of a dataset

func (Dataset) DelegatedForm

func (d Dataset) DelegatedForm(m *Metadata) string

DelegatedForm prints the form where the data scientist has to agree on custum text attributes that can not be automatically checked. It fills the value attribute if it finds an attribute that has the same id in the given metadata

func (Dataset) String

func (d Dataset) String() string

String returns a human readable string representation of a datasets

type DelegatedEnforcement

type DelegatedEnforcement struct {
	Title       string                  `json:"title"`
	Description string                  `json:"description"`
	Attributes  []*EnforcementAttribute `json:"attributes"`
}

DelegatedEnforcement describes attributes that validates other attributes (normally the ones that have the "delegated_enforcement" attribute to true)

func (DelegatedEnforcement) String

func (m DelegatedEnforcement) String() string

type EnforcementAttribute

type EnforcementAttribute struct {
	ID             string   `json:"id"`
	Description    string   `json:"description"`
	ValueFromID    string   `json:"value_from_id"`
	TriggerID      string   `json:"trigger_id"`
	TriggerValue   string   `json:"trigger_value"`
	CheckValidates []string `json:"check_validates"`
	TextValidates  string   `json:"text_validates"`
}

EnforcementAttribute is a particular type of attribute that valides other attributes. It is only a check box that, one checked, whill validates the attributes contained in the "Validates" field.

func (EnforcementAttribute) String

func (e EnforcementAttribute) String() string

type FailedReason

type FailedReason struct {
	AttributeID string `json:"attribute_id"`
	Reason      string `json:"reason"`
	Dataset     string `json:"dataset"`
}

FailedReason describes a failed reason for a specific attribute

func (FailedReason) String

func (f FailedReason) String() string

String returns the string representation of a failed reason

type FailedReasons

type FailedReasons struct {
	FailedReasons []*FailedReason `json:"failed_reasons"`
}

FailedReasons is a simple struct that holds a list a failed reasons

func (*FailedReasons) AddReason

func (f *FailedReasons) AddReason(attributeID, reason, dataset string)

AddReason adds a reason to the list of failed reasons

func (FailedReasons) IsEmpty

func (f FailedReasons) IsEmpty() bool

IsEmpty returns true if there is

func (FailedReasons) String

func (f FailedReasons) String() string

type Metadata

type Metadata struct {
	AttributesGroups     []*AttributesGroup    `json:"attributesGroups"`
	DelegatedEnforcement *DelegatedEnforcement `json:"delegated_enforcement"`
}

Metadata is a struct that holds a list of attributes groups. This was necessary to use a struct in order to marshal/unmarshal it.

func (Metadata) Darc

func (m Metadata) Darc(calypsoWriteID string) string

Darc print the DARC representation of the metadata. Outputs something like "attr:allowed:ID1=value1&ID2=value2& attr:must_have:ID2=value2&ID3=value3"

func (Metadata) FoundName

func (m Metadata) FoundName(name string) bool

FoundName checks if an attribute uses this name

func (Metadata) GetActiveAttributesByRuleType

func (m Metadata) GetActiveAttributesByRuleType(ruleType string) []*Attribute

GetActiveAttributesByRuleType return all the attributes that has the given rule type and a non-empty value.

func (Metadata) GetAttribute

func (m Metadata) GetAttribute(id string) (*Attribute, bool)

GetAttribute return the first attribute that has the given id, and a bool that says if one was found.

func (Metadata) GetAttributeByValue

func (m Metadata) GetAttributeByValue(value string) (*Attribute, bool)

GetAttributeByValue return the first attribute that has the given value, and a bool that says if one was found.

func (Metadata) GetAttributesByName

func (m Metadata) GetAttributesByName(name string) []*Attribute

GetAttributesByName return the attributes with the given name

func (*Metadata) Reset

func (m *Metadata) Reset()

Reset reset the value field of all the attributes

func (*Metadata) ResetFailedReasons

func (m *Metadata) ResetFailedReasons()

ResetFailedReasons sets the FailedReasons field of every attribute to an empty slice

func (Metadata) String

func (m Metadata) String() string

func (*Metadata) TryUpdate

func (m *Metadata) TryUpdate(name, val string)

TryUpdate update an attribute, if the name is found, by the value

func (*Metadata) UpdateOrSet

func (m *Metadata) UpdateOrSet(name, val string)

UpdateOrSet update an attribute, if the name is found, by the value, or create a new attribute

type Owner

type Owner struct {
	Firstname string
	Lastname  string
	Datasets  []*Dataset
	// This is the signer identity, like 'ed25519:aef123'
	IdentityStr string
}

Owner describes someone that has one or more datasets

func (*Owner) AddDataset

func (o *Owner) AddDataset(dataset *Dataset) error

AddDataset adds a dataset if it doesn't already exist

func (*Owner) ArchiveDataset

func (o *Owner) ArchiveDataset(calypsoWriteID string) error

ArchiveDataset set the IsArchived attribute and removes its attributes

func (*Owner) DeleteDataset

func (o *Owner) DeleteDataset(calypsoWriteID string) error

DeleteDataset deletes the dataset at the given calypsoWriteID

func (Owner) GetDataset

func (o Owner) GetDataset(calypsoWriteID string) *Dataset

GetDataset return the dataset if found, or nil

func (*Owner) ReplaceDataset

func (o *Owner) ReplaceDataset(calypsoWriteID string, newDataset *Dataset) error

ReplaceDataset replace the dataset at the given calypsoWriteID by the newDataset

func (Owner) String

func (o Owner) String() string

String returns a human readable string representation of an owner

type Service

type Service struct {
	// We need to embed the ServiceProcessor, so that incoming messages
	// are correctly handled.
	*onet.ServiceProcessor
}

Service is only used to being able to store our contracts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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