Documentation
¶
Index ¶
- func FindDeletePostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func FindPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func FindPutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func GetPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func GetPutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func PutPostStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- func PutStrategyFunc(ctx context.Context, action *rest.Action, rest *rest.SeederImpl) error
- type Seeders
- type StrategyConfig
- type StrategyFunc
- type StrategyRestSeeder
- func (s *StrategyRestSeeder) Execute(ctx context.Context) []error
- func (s *StrategyRestSeeder) WithActions(actions map[string]rest.Action) *StrategyRestSeeder
- func (s *StrategyRestSeeder) WithAuth(ra *rest.AuthMap) *StrategyRestSeeder
- func (s *StrategyRestSeeder) WithLogger(w io.Writer, lvl log.LogLevel) *StrategyRestSeeder
- func (s *StrategyRestSeeder) WithRestClient(rc rest.Client) *StrategyRestSeeder
- type StrategyType
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 is useful for when you cannot update a resource but it can be safely destroyed an recreated
func FindPostStrategyFunc ¶
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 ¶
FindPutPostStrategyFunc is useful when the resource Id is unknown i.e. handled by the system. providing a pathExpression will evaluate the response. 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 ¶
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 ¶
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 ¶
PutPostStrategyFunc is useful when the resource is created a user specified Id the PUT endpoint DOES NOT support a creation of the resource. PUT should throw a 4XX for the POST fallback to take effect
func PutStrategyFunc ¶
PutStrategyFunc calls a PUT endpoint fails if an error occurs useful when there is a known Id of a resource and PUT supports creation
Types ¶
type StrategyConfig ¶
StrategyConfig defines top level
type StrategyFunc ¶
type StrategyRestSeeder ¶
type StrategyRestSeeder struct {
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(ctx context.Context) []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) WithAuth ¶ added in v0.1.0
func (s *StrategyRestSeeder) WithAuth(ra *rest.AuthMap) *StrategyRestSeeder
WithAuth adds the AuthLogic to the entire seeder NOTE: might make more sense to have a per RestAction authTemplate (might make it very inefficient)
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" PUT_POST StrategyType = "PUT/POST" 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" )