resource

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateSummary

type CreateSummary struct {
	ID      string `json:"id"`
	Created bool   `json:"created"`
}

CreateSummary holds the identity of a resource, and describes weather it was created due to your operation.

type Identifier

type Identifier struct {
	Type string `json:"type"`
	ID   string `json:"id"`
}

Identifier uniquely identifies a resource entry.

type Meta

type Meta struct {
	Annotations       fields.Annotations `json:"annotations,omitempty"`
	AttributesHash    fields.Hexadecimal `json:"attributesHash,omitempty"`
	RelationshipsHash fields.Hexadecimal `json:"relationshipsHash,omitempty"`
	CreatedAt         time.Time          `json:"createdAt"`
	UpdatedAt         time.Time          `json:"updatedAt"`
}

Meta holds the meta data fields for a resource entry select view.

type Method

type Method[R any] struct {
	APIVersion string
	Method     string
}

Method is a constructor for Requests against a given RPC method.

func (Method[R]) NewRequest

func (cfg Method[R]) NewRequest(h jsonrpc.Handler, params ...jsonrpc.Param) Request[R]

type Normalizer

type Normalizer interface {
	Normalize()
}

Normalizer describes a type that should be normalized before encoding.

type NullIdentifier

type NullIdentifier Identifier

NullIdentifier is a version of Identifier where the zero-value is encoded as null in JSON.

func (NullIdentifier) MarshalJSON

func (id NullIdentifier) MarshalJSON() ([]byte, error)

func (*NullIdentifier) UnmarshalJSON

func (id *NullIdentifier) UnmarshalJSON(data []byte) error

type Request

type Request[R any] struct {
	// contains filtered or unexported fields
}

Request allows creating or updating properties based on a keyed relation.

func (Request[R]) Do

func (req Request[R]) Do(ctx context.Context, extraParams ...jsonrpc.Param) (*R, error)

Do performs the request against the server and returns the result.

type Resource

type Resource[A, R any] struct {
	Identifier
	Meta          Meta `json:"meta"`
	Attributes    A    `json:"attributes"`
	Relationships R    `json:"relationships"`
}

Resource describes a generic resource entry select view.

func (Resource[A, R]) MarshalJSON

func (e Resource[A, R]) MarshalJSON() ([]byte, error)

type SaveMethod

type SaveMethod[D, R any] struct {
	APIVersion string
	Method     string
	DataParam  string
}

SaveMethod is a constructor for Requests against a given RPC method.

func (SaveMethod[D, R]) NewRequest

func (cfg SaveMethod[D, R]) NewRequest(h jsonrpc.Handler, data D, params ...jsonrpc.Param) SaveRequest[D, R]

type SaveRequest

type SaveRequest[D, R any] struct {
	// contains filtered or unexported fields
}

SaveRequest allows creating or updating properties based on a keyed relation.

func (SaveRequest[D, R]) CreateOnly

func (req SaveRequest[D, R]) CreateOnly() SaveRequest[D, R]

CreateOnly returns a request with the createOnly property set to true. When set to true, existing resources are not updated.

func (SaveRequest[D, R]) Do

func (req SaveRequest[D, R]) Do(ctx context.Context, extraParams ...jsonrpc.Param) (*R, error)

Do performs the request against the server and returns the result.

type SaveSummary

type SaveSummary struct {
	ID      string `json:"id"`
	Created bool   `json:"created"`
	Updated bool   `json:"updated"`
}

SaveSummary holds the identity of a resource, and describes weather it was updated or created due to your operation.

type SelectMethod

type SelectMethod[R any] struct {
	APIVersion string
	Method     string
}

func (SelectMethod[R]) NewRequest

func (cfg SelectMethod[R]) NewRequest(h jsonrpc.Handler, params ...jsonrpc.Param) SelectRequest[R]

type SelectRequest

type SelectRequest[R any] struct {
	// contains filtered or unexported fields
}

func (SelectRequest[R]) Do

func (req SelectRequest[R]) Do(ctx context.Context, extraParams ...jsonrpc.Param) (*R, error)

Do performs the request against the server and returns the result.

func (SelectRequest[R]) Filter

func (req SelectRequest[R]) Filter(f query.FilterType) SelectRequest[R]

Filter returns a new request with the specified filter added to existing filters with logical AND.

func (SelectRequest[R]) Include

func (req SelectRequest[R]) Include(relationships ...string) SelectRequest[R]

Include returns a new request that includes the specified related resources. the provided list is appended to any existing include properties.

func (SelectRequest[R]) Limit

func (req SelectRequest[R]) Limit(n int) SelectRequest[R]

Limit returns a new request that limits the number of matches. Setting n < 0 will use the default limit.

func (SelectRequest[R]) Skip

func (req SelectRequest[R]) Skip(n int) SelectRequest[R]

Skip returns a new request that skips the first n matches.

func (SelectRequest[R]) Sort

func (req SelectRequest[R]) Sort(fields ...string) SelectRequest[R]

Sort returns a new request that sorts according to the specified fields. A minus (-) prefix can be used on the filed name to indicate inverse ordering.

type Selection

type Selection[E, I any] struct {
	Meta     SelectionMeta `json:"meta"`
	Data     []E           `json:"data"`
	Included I             `json:"included"`
}

Selection holds resource selection results.

type SelectionMeta

type SelectionMeta struct {
	Total               int  `json:"total"`
	GroupIncludedByType bool `json:"groupIncludedByType"`
}

SelectionMeta contains top-level meta information about a resource selection.

type ToMany

type ToMany struct {
	Meta map[string]json.RawMessage `json:"meta,omitempty"`
	Data []Identifier               `json:"data"`
}

ToMany describes a to many relationship entry.

type ToOne

type ToOne struct {
	Meta map[string]json.RawMessage `json:"meta,omitempty"`
	Data NullIdentifier             `json:"data"`
}

ToOne describes a to one relationship entry.

Jump to

Keyboard shortcuts

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