patch

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action defines action of document patch

const (

	// AddPublicKeys captures enum value "add-public-keys"
	AddPublicKeys Action = "add-public-keys"

	// RemovePublicKeys captures enum value "remove-public-keys"
	RemovePublicKeys Action = "remove-public-keys"

	//AddServiceEndpoints captures "add-service-endpoints"
	AddServiceEndpoints Action = "add-service-endpoints"

	//RemoveServiceEndpoints captures "remove-service-endpoints"
	RemoveServiceEndpoints Action = "remove-service-endpoints"

	// JSONPatch captures enum value "json-patch"
	JSONPatch Action = "ietf-json-patch"
)

type Key

type Key string

Key defines key that will be used to get document patch information

const (

	// DocumentKey captures  "document" key
	DocumentKey Key = "document"

	// PatchesKey captures "patches" key
	PatchesKey Key = "patches"

	// PublicKeys captures "public_keys" key
	PublicKeys Key = "public_keys"

	//ServiceEndpointsKey captures "service_endpoints" key
	ServiceEndpointsKey Key = "service_endpoints"

	//ServiceEndpointIdsKey captures "ids" key
	ServiceEndpointIdsKey Key = "ids"

	// ActionKey captures "action" key
	ActionKey Key = "action"
)

type Patch

type Patch map[Key]interface{}

Patch defines generic patch structure

func FromBytes

func FromBytes(data []byte) (Patch, error)

FromBytes parses provided data into document patch

func NewAddPublicKeysPatch

func NewAddPublicKeysPatch(publicKeys string) (Patch, error)

NewAddPublicKeysPatch creates new patch for adding public keys

func NewAddServiceEndpointsPatch

func NewAddServiceEndpointsPatch(serviceEndpoints string) (Patch, error)

NewAddServiceEndpointsPatch creates new patch for adding service endpoints

func NewJSONPatch

func NewJSONPatch(patches string) (Patch, error)

NewJSONPatch creates new generic update patch (will be used for generic updates)

func NewRemovePublicKeysPatch

func NewRemovePublicKeysPatch(publicKeyIds string) (Patch, error)

NewRemovePublicKeysPatch creates new patch for removing public keys

func NewRemoveServiceEndpointsPatch

func NewRemoveServiceEndpointsPatch(serviceEndpointIds string) (Patch, error)

NewRemoveServiceEndpointsPatch creates new patch for removing service endpoints

func PatchesFromDocument

func PatchesFromDocument(doc string) ([]Patch, error)

PatchesFromDocument creates patches from opaque document

func (Patch) Bytes

func (p Patch) Bytes() ([]byte, error)

Bytes returns byte representation of patch

func (Patch) GetAction

func (p Patch) GetAction() Action

GetAction returns string value for specified key or "" if not found or wrong type

func (Patch) GetValue

func (p Patch) GetValue(key Key) interface{}

GetValue returns value for specified key or nil if not found

func (Patch) JSONLdObject

func (p Patch) JSONLdObject() map[Key]interface{}

JSONLdObject returns map that represents JSON LD Object

func (Patch) Validate

func (p Patch) Validate() error

Validate validates patch

Jump to

Keyboard shortcuts

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