strategyrestseeder

package module
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: 6 Imported by: 0

README

strategy-rest-seeder

Executes a series of instructions against an endpoint using a specified authentication on a given strategy.

Strategy

Strategy is a setting against which to perform one or more rest calls to ensuren idempotent update.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindDeletePostStrategyFunc

func FindDeletePostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

FindDeletePostStrategyFunc

func FindPostStrategyFunc

func FindPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

FindPostStrategyFunc 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 FindPutPostStrategyFunc

func FindPutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

FindPutPostStrategyFunc unknown ID and only know a name or other indicator the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present

func GetPostStrategyFunc

func GetPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

FindPostStrategyFunc 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 GetPutPostStrategyFunc

func GetPutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

GetPutPostStrategyFunc known ID and only know a name or other indicator the pathExpression must not evaluate to an empty string in order to for the PUT to be called else POST will be called as item was not present

func PutPostStrategyFunc

func PutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

PutPostStrategyFunc known id to update

func PutStrategyFunc

func PutStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

PutStrategyFunc

Types

type Auth

type Auth struct {
	AuthStrategy AuthType `yaml:"type"`
	// contains filtered or unexported fields
}

Auth holds the auth strategy for

type AuthType

type AuthType string
const (
	Basic        AuthType = "basicAuth"
	OAuth        AuthType = "oAuthClientCredentials"
	BasicToToken AuthType = "basicToToken"
)

type StrategyConfig

type StrategyConfig struct {
	AuthConfig Auth                   `yaml:"auth"`
	Seeders    map[string]rest.Action `yaml:"seed"`
}

StrategyConfig defines top level

type StrategyFunc

type StrategyFunc func(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error

type StrategyRestSeeder

type StrategyRestSeeder struct {
	Auth     Auth
	Strategy map[StrategyType]StrategyFunc
	// contains filtered or unexported fields
}

func New

func New() *StrategyRestSeeder

New initializes a default StrategySeeder with error log level and os.StdErr as log writer uses standard http.Client as rest client for rest SeederImplementation

func (*StrategyRestSeeder) Execute

func (s *StrategyRestSeeder) Execute() []error

Execute the built actions list TODO: create a custom error object

func (*StrategyRestSeeder) WithActions

func (s *StrategyRestSeeder) WithActions(actions map[string]rest.Action) *StrategyRestSeeder

WithActions builds the actions list empty actions will result in no restActions executing

func (*StrategyRestSeeder) WithLogger

func (s *StrategyRestSeeder) WithLogger(w io.Writer, lvl log.LogLevel) *StrategyRestSeeder

WithLogger overwrites the default logger and passes it down to rest.SeederImpl

func (*StrategyRestSeeder) WithRestClient

func (s *StrategyRestSeeder) WithRestClient(rc rest.Client) *StrategyRestSeeder

WithRestClient overwrites the default RestClient

type StrategyType

type StrategyType string
const (
	GET_POST         StrategyType = "GET/POST"
	FIND_POST        StrategyType = "FIND/POST"
	POST_PUT         StrategyType = "POST/PUT"
	GET_PUT_POST     StrategyType = "GET/PUT/POST"
	FIND_PUT_POST    StrategyType = "FIND/PUT/POST"
	FIND_DELETE      StrategyType = "FIND/DELETE"
	FIND_DELETE_POST StrategyType = "FIND/DELETE/POST"
	PUT              StrategyType = "PUT"
)

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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