rest

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Reader
	Writer
}

Client knows how to perform CRUD operations on Object

func NewForConfig

func NewForConfig(cfg *rest.Config) (Client, error)

NewForConfig creates a new rest client

type Object

type Object interface {
	TypeLink(segments ...string) string
	SelfLink(segments ...string) string
	Data() ([]byte, error)
	Parse(bt []byte) error
}

Object is the object entity for a rest request. It knows how to get request url, parsing object and do the deepcopy.

type ObjectList

type ObjectList interface {
	TypeLink() string
	Parse(bt []byte) error
}

ObjectList is the object list entity for a rest request. It knows how to get request url, and deepcopy the objects.

type Patch

type Patch interface {
	// Type is the PatchType of the patch.
	Type() types2.PatchType
	// Data is the raw data representing the patch.
	Data(obj Object) ([]byte, error)
}

Patch is a patch that can be applied to a rest object.

func ConstantPatch

func ConstantPatch(patchType types.PatchType, data []byte) Patch

ConstantPatch constructs a new Patch with the given PatchType and data.

func MergeFrom

func MergeFrom(obj runtime.Object) Patch

MergeFrom creates a Patch that patches using the merge-patch strategy with the given object as base.

type Reader

type Reader interface {
	// Get retrieves an obj for the given object key from the rest object.
	// obj must be a struct pointer so that obj can be updated with the response
	// returned by the Server.
	Get(ctx context.Context, obj Object) error

	// List retrieves list of objects for a given namespace and list options. On a
	// successful call, Items field in the list will be populated with the
	// result returned from the server.
	List(ctx context.Context, obj ObjectList, option types.Option) error
}

Reader knows how to read and list objects.

type Writer

type Writer interface {
	// Create saves the object obj in the rest object.
	Create(ctx context.Context, obj Object, option types.Option) error

	// Delete deletes the given obj from rest object.
	Delete(ctx context.Context, obj Object, option types.Option) error

	// Update updates the given obj in the rest object. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Update(ctx context.Context, obj Object, option types.Option) error

	// Update updates the given obj in the rest object. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Patch(ctx context.Context, obj Object, patch Patch) error
}

Writer knows how to create, delete, and update rest objects.

Jump to

Keyboard shortcuts

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