rest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 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 Action

type Action struct {
	Strategy           string             `yaml:"strategy"`
	Order              *int               `yaml:"order,omitempty"`
	Endpoint           string             `yaml:"endpoint"`
	GetEndpointSuffix  *string            `yaml:"getEndpointSuffix,omitempty"`
	PostEndpointSuffix *string            `yaml:"postEndpointSuffix,omitempty"`
	PutEndpointSuffix  *string            `yaml:"putEndpointSuffix,omitempty"`
	FindByJsonPathExpr string             `yaml:"findByJsonPathExpr,omitempty"`
	PayloadTemplate    string             `yaml:"payloadTemplate"`
	Variables          map[string]any     `yaml:"variables"`
	RuntimeVars        *map[string]string `yaml:"runtimeVars,omitempty"`
	// contains filtered or unexported fields
}

Action defines the single action to make agains an endpoint and selecting a strategy Endpoint is the base url to make the requests against GetEndpointSuffix can be used to specify a direct ID or query params PostEndpointSuffix

func (*Action) WithName

func (a *Action) WithName(name string) *Action

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

type SeederImpl

type SeederImpl struct {
	// contains filtered or unexported fields
}

func (*SeederImpl) FindPost

func (r *SeederImpl) FindPost(ctx context.Context, action *Action) error

FindPost strategy calls a GET endpoint and if item ***FOUND it does NOT do a POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func (*SeederImpl) FindPutPost

func (r *SeederImpl) FindPutPost(ctx context.Context, action *Action) error

FindPutPost strategy gets an item either by specifying a known ID in the endpoint suffix or by pathExpression. Get can look for a response in an array or in a single response object. once a single item that matches is found and the relevant ID is extracted it will do a PUT else it will do a POST as the item can be created

func (*SeederImpl) GetPost

func (r *SeederImpl) GetPost(ctx context.Context, action *Action) error

GetPost strategy calls a GET endpoint and if item ***FOUND it does NOT do a POST*** this strategy should be used sparingly and only in cases where the service REST implementation does not support an update of existing item.

func (*SeederImpl) GetPutPost

func (r *SeederImpl) GetPutPost(ctx context.Context, action *Action) error

GetPutPost strategy gets an item by specifying a known ID in the endpoint suffix If a non error or non empty response is found it will do a PUT else it will do a POST as the item can be created

func (*SeederImpl) Put

func (r *SeederImpl) Put(ctx context.Context, action *Action) error

Put strategy calls a PUT endpoint if standards compliant this should be an idempotent operation

func (*SeederImpl) PutPost

func (r *SeederImpl) PutPost(ctx context.Context, action *Action) error

Put strategy calls a PUT endpoint if standards compliant this should be an idempotent operation

func (*SeederImpl) WithClient

func (r *SeederImpl) WithClient(c Client) *SeederImpl

TODO: change this for an interface

func (*SeederImpl) WithHeader

func (r *SeederImpl) WithHeader(header *http.Header) *SeederImpl

func (*SeederImpl) WithLogger

func (r *SeederImpl) WithLogger(l log.Loggeriface) *SeederImpl

Jump to

Keyboard shortcuts

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