MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / Create

Method Create

module/strategy/iml.go:231–264  ·  view source on GitHub ↗
(ctx context.Context, input *strategy_dto.Create)

Source from the content-addressed store, hash-verified

229}
230
231func (i *imlStrategyModule) Create(ctx context.Context, input *strategy_dto.Create) error {
232 if input.Name == "" {
233 return fmt.Errorf("name required")
234 }
235 if input.ID == "" {
236 input.ID = uuid.NewString()
237 }
238
239 if input.Priority < 1 {
240 input.Priority = 1000
241 }
242 err := strategy_filter.CheckFilters(input.Driver, input.Scope, input.Filters)
243 if err != nil {
244 return err
245 }
246
247 err = strategy_driver.CheckConfig(input.Driver, input.Config)
248 if err != nil {
249 return err
250 }
251 filters, _ := json.Marshal(input.Filters)
252 cfg, _ := json.Marshal(input.Config)
253 return i.strategyService.Create(ctx, &strategy.Create{
254 Id: input.ID,
255 Name: input.Name,
256 Priority: input.Priority,
257 Desc: input.Desc,
258 Filters: string(filters),
259 Config: string(cfg),
260 Scope: input.Scope.Int(),
261 Target: input.Target,
262 Driver: input.Driver,
263 })
264}
265
266func (i *imlStrategyModule) Edit(ctx context.Context, id string, input *strategy_dto.Edit) error {
267 if input.Name != nil && *input.Name == "" {

Callers

nothing calls this directly

Calls 3

MarshalMethod · 0.80
CreateMethod · 0.65
IntMethod · 0.45

Tested by

no test coverage detected