dto

package
v1.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dto is the wire shape of a grant: one request body for every shareable record, with the subject's kind a field rather than a choice of endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ShareRequest

type ShareRequest struct {
	PrincipalType *model.PrincipalType    `json:"principalType"`
	PrincipalID   string                  `json:"principalId"`
	Permission    *model.AccessPermission `json:"permission"`
}

ShareRequest grants one principal access to the resource named in the path.

There is no resource field: the path says what is being shared, so a request cannot name one resource in the URL and open up another in the body. PrincipalType is what used to be the choice between two endpoints.

func (*ShareRequest) Grant

func (r *ShareRequest) Grant() model.AccessPermission

Grant returns the permission to store, defaulting to READ. Read-only is the safe default for a share: widening it is a deliberate act.

func (*ShareRequest) Subject

func (r *ShareRequest) Subject() model.PrincipalType

Subject returns the principal type being granted to. Validation has already rejected a nil or unrecognised one.

func (*ShareRequest) Validate

func (r *ShareRequest) Validate() []httpx.FieldError

Validate implements httpx.Validator.

type ShareResponse

type ShareResponse struct {
	SharingID     string                 `json:"resourceSharingId"`
	ResourceType  model.ResourceType     `json:"resourceType"`
	ResourceID    string                 `json:"resourceId"`
	PrincipalType model.PrincipalType    `json:"principalType"`
	PrincipalID   string                 `json:"principalId"`
	Permission    model.AccessPermission `json:"permission"`
}

ShareResponse is the read model for one share.

The resource is echoed back even though the caller named it in the path: a listing is a set of rows, and a row that did not say what it opened up would be ambiguous once it left the response it arrived in.

func ToShareResponse

func ToShareResponse(s *model.Sharing) ShareResponse

func ToShareResponses

func ToShareResponses(in []model.Sharing) []ShareResponse

type ShareUpdate

type ShareUpdate struct {
	Permission *model.AccessPermission `json:"permission"`
}

ShareUpdate changes what an existing share grants. The subject is fixed at creation; only the permission is editable, because moving a share to a different principal would be a revoke and a grant wearing one id.

func (*ShareUpdate) Grant

func (r *ShareUpdate) Grant() model.AccessPermission

Grant returns the permission to store.

func (*ShareUpdate) Validate

func (r *ShareUpdate) Validate() []httpx.FieldError

Validate implements httpx.Validator.

Jump to

Keyboard shortcuts

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