shared

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContractNegotiationState

func ContractNegotiationState(fl validator.FieldLevel) bool

func DecodeValid

func DecodeValid[T any](r *http.Request) (T, error)

func EncodeValid

func EncodeValid[T any](w http.ResponseWriter, r *http.Request, status int, v T) error

func GetDSPContext

func GetDSPContext() jsonld.Context

GetDSPContext returns the DSP context. TODO: Replace all the hardcoded ones with this function.

func IDToURN

func IDToURN(s string) string

IDtoURN generates the URN for the ID. Right now we only support preformatted URNs, UUIDs, and OIDs.

func MustParseURL

func MustParseURL(u string) *url.URL

func RegisterValidators

func RegisterValidators(v *validator.Validate) error

This registers all the validators of this package, and also calls the odrl register function as this package uses the odrl structs as well.

func TransferProcessState

func TransferProcessState(fl validator.FieldLevel) bool

func URNtoRawID

func URNtoRawID(s string) (string, error)

URNtoRawID strips the URN part and returns the ID without any metadata. This function only works on URNs with 3 parts like the uuid or oid URNs. This function returns an error when we can't properly split it. TODO: Verify that all providers support URNs so that we can remove this function.

func UnmarshalAndValidate

func UnmarshalAndValidate[T any](ctx context.Context, b []byte, s T) (T, error)

func ValidateAndMarshal

func ValidateAndMarshal[T any](ctx context.Context, s T) ([]byte, error)

Types

type CatalogAcknowledgement

type CatalogAcknowledgement struct {
	Context jsonld.Context `json:"@context"`
	Dataset
	Datasets      []Dataset     `json:"dcat:dataset"`
	Service       []DataService `json:"dcat:service" validate:"gte=1"`
	ParticipantID string        `json:"dspace:participantID,omitempty"`
	Homepage      string        `json:"foaf:homepage,omitempty"`
}

CatalogAcknowledgement is an acknowledgement for a catalog, containing a dataset.

type CatalogRequestMessage

type CatalogRequestMessage struct {
	Context jsonld.Context `json:"@context"`
	Type    string         `json:"@type" validate:"required,eq=dspace:CatalogRequestMessage"`
	Filter  []any          `json:"dspace:filter"`
}

CatalogRequestMessage is a message to request a catalog. Note that the filter format is defined as "implementation specific" and nothing else in the spec. TODO: define how we want to support filters.

type Checksum added in v0.0.2

type Checksum struct {
	Algorithm string `json:"spdx:algorithm,omitempty"`
	Value     string `json:"spdx:checksumValue,omitempty"`
}

Checksum is a DCAT checksum.

type ContractAgreementMessage

type ContractAgreementMessage struct {
	Context         jsonld.Context `json:"@context"`
	Type            string         `json:"@type" validate:"required,eq=dspace:ContractAgreementMessage"`
	ProviderPID     string         `json:"dspace:providerPid" validate:"required"`
	ConsumerPID     string         `json:"dspace:consumerPid"`
	Agreement       odrl.Agreement `json:"dspace:agreement" validate:"required"`
	CallbackAddress string         `json:"dspace:callbackAddress" validate:"required"`
}

ContractAgreementMessage is a DSP contract agreement.

type ContractAgreementVerificationMessage

type ContractAgreementVerificationMessage struct {
	Context     jsonld.Context `json:"@context"`
	Type        string         `json:"@type" validate:"required,eq=dspace:ContractAgreementVerificationMessage"`
	ProviderPID string         `json:"dspace:providerPid" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid" validate:"required"`
}

ContractAgreementVerificationMessage verifies the contract agreement.

type ContractNegotiation

type ContractNegotiation struct {
	Context     jsonld.Context `json:"@context"`
	Type        string         `json:"@type" validate:"required,eq=dspace:ContractNegotiation"`
	ProviderPID string         `json:"dspace:providerPid" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid" validate:"required"`
	State       string         `json:"dspace:state" validate:"required"`
}

ContractNegotiation is a response to show the state of the contract negotiation.

type ContractNegotiationEventMessage

type ContractNegotiationEventMessage struct {
	Context     jsonld.Context `json:"@context"`
	Type        string         `json:"@type" validate:"required,eq=dspace:ContractNegotiationEventMessage"`
	ProviderPID string         `json:"dspace:providerPid" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid" validate:"required"`
	EventType   string         `json:"dspace:eventType" validate:"required,oneof=dspace:ACCEPTED dspace:FINALIZED"`
}

ContractNegotiationEventMessage notifies of a contract event.

type ContractNegotiationTerminationMessage

type ContractNegotiationTerminationMessage struct {
	Context     jsonld.Context  `json:"@context"`
	Type        string          `json:"@type" validate:"required,eq=dspace:ContractNegotiationTerminationMessage"`
	ProviderPID string          `json:"dspace:providerPid" validate:"required"`
	ConsumerPID string          `json:"dspace:consumerPid" validate:"required"`
	Code        string          `json:"dspace:code"`
	Reason      []Multilanguage `json:"dspace:reason"`
}

ContractNegotiationTerminationMessage terminates the negotiation.

type ContractOfferMessage

type ContractOfferMessage struct {
	Context         jsonld.Context    `json:"@context"`
	Type            string            `json:"@type" validate:"required,eq=dspace:ContractOfferMessage"`
	ProviderPID     string            `json:"dspace:providerPid" validate:"required"`
	ConsumerPID     string            `json:"dspace:consumerPid"`
	Offer           odrl.MessageOffer `json:"dspace:offer" validate:"required"`
	CallbackAddress string            `json:"dspace:callbackAddress" validate:"required"`
}

ContractOfferMessage is a DSP contract offer.

type ContractRequestMessage

type ContractRequestMessage struct {
	Context         jsonld.Context    `json:"@context"`
	Type            string            `json:"@type" validate:"required,eq=dspace:ContractRequestMessage"`
	ProviderPID     string            `json:"dspace:providerPid,omitempty"`
	ConsumerPID     string            `json:"dspace:consumerPid" validate:"required"`
	Offer           odrl.MessageOffer `json:"dspace:offer" validate:"required"`
	CallbackAddress string            `json:"dspace:callbackAddress" validate:"required"`
}

ContractRequestMessage is a dsp contract request.

type DSPError

type DSPError struct {
	Context     jsonld.Context  `json:"@context"`
	Type        string          `json:"@type"`
	ProviderPID string          `json:"dspace:providerPid,omitempty"`
	ConsumerPID string          `json:"dspace:consumerPid,omitempty"`
	Code        string          `json:"dspace:code,omitempty"`
	Reason      []Multilanguage `json:"dspace:reason,omitempty"`
	Description []Multilanguage `json:"dct:description,omitempty"`
}

DSPError is an amalgamation of all DSP errors combined into one.

type DataAddress

type DataAddress struct {
	Type               string             `json:"@type,omitempty" validate:"required,eq=dspace:DataAddress"`
	EndpointType       string             `json:"endpointType" validate:"required"`
	Endpoint           string             `json:"endpoint" validate:"required"`
	EndpointProperties []EndpointProperty `json:"endpointProperties"`
}

DataAddress represents a dataspace data address.

type DataService

type DataService struct {
	Resource
	EndpointDescription string    `json:"dcat:endpointDescription,omitempty"`
	EndpointURL         string    `json:"dcat:endpointURL,omitempty"`
	ServesDataset       []Dataset `json:"dcat:servesDataset,omitempty"`
}

DataService is a DCAT dataservice.

type Dataset

type Dataset struct {
	Resource
	HasPolicy    []odrl.Offer   `json:"odrl:hasPolicy,omitempty"`
	Distribution []Distribution `json:"dcat:distribution,omitempty"`
}

Dataset is a DCAT dataset.

type DatasetRequestMessage

type DatasetRequestMessage struct {
	Context jsonld.Context `json:"@context"`
	Type    string         `json:"@type" validate:"required,eq=dspace:DatasetRequestMessage"`
	Dataset string         `json:"dspace:dataset" validate:"required"`
}

DatasetRequestMessage is a message to request a dataset.

type Distribution

type Distribution struct {
	Type           string          `json:"@type,omitempty" validate:"required,eq=dcat:Distribution"`
	Format         string          `json:"dct:format,omitempty"`
	Title          string          `json:"dct:title,omitempty"`
	Description    []Multilanguage `json:"dct:description,omitempty"`
	Issued         string          `json:"dct:issued,omitempty"`
	Modified       string          `json:"dct:modified,omitempty"`
	HasPolicy      []odrl.Offer    `json:"odrl:hasPolicy,omitempty"`
	AccessService  []DataService   `json:"dcat:accessService,omitempty" validate:"required,gte=1"`
	License        string          `json:"dcterms:license,omitempty"`
	AccessRights   string          `json:"dcterms:accessRights,omitempty"`
	Rights         string          `json:"dcterms:rights,omitempty"`
	ByteSize       int             `json:"dcat:byteSize,omitempty"`
	MediaType      string          `json:"dcat:mediaType,omitempty"`
	CompressFormat string          `json:"dcat:compressFormat,omitempty"`
	PackageFormat  string          `json:"dcat:packageFormat,omitempty"`
	Checksum       *Checksum       `json:"spdx:checksum,omitempty"`
}

Distribution is a DCAT distribution.

type EndpointProperty

type EndpointProperty struct {
	Type  string `json:"@type,omitempty" validate:"required,eq=dspace:EndpointProperty"`
	Name  string `json:"dspace:name" validate:"required"`
	Value string `json:"dspace:value" validate:"required"`
}

EndpointProperty represents endpoint properties.

type HTTPRequester

type HTTPRequester struct {
	Client *http.Client
}

func (*HTTPRequester) SendHTTPRequest

func (hr *HTTPRequester) SendHTTPRequest(
	ctx context.Context, method string, url *url.URL, reqBody []byte,
) ([]byte, error)

type Multilanguage

type Multilanguage struct {
	Value    string `json:"@value" validate:"required"`
	Language string `json:"@language" validate:"required"`
}

Multilanguage is a DCAT multilanguage set.

type ProtocolVersion

type ProtocolVersion struct {
	Version string `json:"version" validate:"required"`
	Path    string `json:"path" validate:"required"`
}

ProtocolVersion contains a version and the path to the endpoints.

type PublishInfo

type PublishInfo struct {
	URL   string
	Token string
}

PublishInfo is a simplified struct to store where to download a file.

type Reference

type Reference struct {
	ID string `json:"@id" validate:"required"`
}

Reference is a DCAT reference.

type Requester

type Requester interface {
	SendHTTPRequest(ctx context.Context, method string, url *url.URL, reqBody []byte) ([]byte, error)
}

type Resource

type Resource struct {
	ID          string          `json:"@id" validate:"required"`
	Type        string          `json:"@type" validate:"required"`
	Keyword     []string        `json:"dcat:keyword,omitempty"`
	Theme       []Reference     `json:"dcat:theme,omitempty"`
	ConformsTo  string          `json:"dct:conformsTo,omitempty"`
	Creator     string          `json:"dct:creator,omitempty"`
	Description []Multilanguage `json:"dct:description,omitempty"`
	Identifier  string          `json:"dct:identifier,omitempty"`
	Issued      string          `json:"dct:issued,omitempty"`
	Modified    string          `json:"dct:modified,omitempty"`
	Title       string          `json:"dct:title,omitempty"`
}

Resource is a DCAT resource.

type TransferCompletionMessage

type TransferCompletionMessage struct {
	Context     jsonld.Context `json:"@context,omitempty"`
	Type        string         `json:"@type,omitempty" validate:"required,eq=dspace:TransferCompletionMessage"`
	ProviderPID string         `json:"dspace:providerPid,omitempty" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid,omitempty" validate:"required"`
}

TransferCompletionMessage signals the completion of a datatransfer.

type TransferProcess

type TransferProcess struct {
	Context     jsonld.Context `json:"@context,omitempty"`
	Type        string         `json:"@type,omitempty" validate:"required,eq=dspace:TransferProcess"`
	ProviderPID string         `json:"dspace:providerPid,omitempty" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid,omitempty" validate:"required"`
	State       string         `json:"dspace:state" validate:"required,transfer_state"`
}

TransferProcess are state change reponses.

type TransferRequestMessage

type TransferRequestMessage struct {
	Context         jsonld.Context `json:"@context,omitempty"`
	Type            string         `json:"@type,omitempty" validate:"required,eq=dspace:TransferRequestMessage"`
	AgreementID     string         `json:"dspace:agreementID" validate:"required"`
	Format          string         `json:"dct:format" validate:"required"`
	DataAddress     *DataAddress   `json:"dspace:dataAddress,omitempty"`
	CallbackAddress string         `json:"dspace:callbackAddress" validate:"required"`
	ConsumerPID     string         `json:"dspace:consumerPid" validate:"required"`
}

TransferRequestMessage requests a data transfer.

type TransferStartMessage

type TransferStartMessage struct {
	Context     jsonld.Context `json:"@context,omitempty"`
	Type        string         `json:"@type,omitempty" validate:"required,eq=dspace:TransferStartMessage"`
	ProviderPID string         `json:"dspace:providerPid" validate:"required"`
	ConsumerPID string         `json:"dspace:consumerPid" validate:"required"`
	DataAddress DataAddress    `json:"dspace:dataAddress"`
}

TransferStartMessage signals a transfer start.

type TransferSuspensionMessage

type TransferSuspensionMessage struct {
	Context     jsonld.Context   `json:"@context,omitempty"`
	Type        string           `json:"@type,omitempty" validate:"required,eq=dspace:TransferSuspensionMessage"`
	ProviderPID string           `json:"dspace:providerPid,omitempty" validate:"required"`
	ConsumerPID string           `json:"dspace:consumerPid,omitempty" validate:"required"`
	Code        string           `json:"code,omitempty"`
	Reason      []map[string]any `json:"reason,omitempty"`
}

TransferSuspensionMessage signals the suspension of a datatransfer.

type TransferTerminationMessage

type TransferTerminationMessage struct {
	Context     jsonld.Context   `json:"@context,omitempty"`
	Type        string           `json:"@type,omitempty" validate:"required,eq=dspace:TransferTerminationMessage"`
	ProviderPID string           `json:"dspace:providerPid,omitempty" validate:"required"`
	ConsumerPID string           `json:"dspace:consumerPid,omitempty" validate:"required"`
	Code        string           `json:"code,omitempty"`
	Reason      []map[string]any `json:"reason,omitempty"`
}

TransferTerminationMessage signals the suspension of a datatransfer.

type VersionResponse

type VersionResponse struct {
	Context          jsonld.Context    `json:"@context"`
	ProtocolVersions []ProtocolVersion `json:"protocolVersions" validate:"required,gte=1,dive"`
}

VersionResponse contains multiple protocol version specifications.

Jump to

Keyboard shortcuts

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