( ctx context.Context, req hostAPIAutomationTriggerCreateParams, )
| 2261 | } |
| 2262 | |
| 2263 | func (h *HostAPIHandler) triggerFromCreateParams( |
| 2264 | ctx context.Context, |
| 2265 | req hostAPIAutomationTriggerCreateParams, |
| 2266 | ) (automationpkg.Trigger, automationpkg.WebhookSecretWrite, error) { |
| 2267 | workspaceID, err := h.resolveAutomationWorkspaceID(ctx, req.WorkspaceID) |
| 2268 | if err != nil { |
| 2269 | return automationpkg.Trigger{}, automationpkg.WebhookSecretWrite{}, err |
| 2270 | } |
| 2271 | |
| 2272 | enabled := true |
| 2273 | if req.Enabled != nil { |
| 2274 | enabled = *req.Enabled |
| 2275 | } |
| 2276 | |
| 2277 | retry := automationpkg.DefaultRetryConfig() |
| 2278 | if req.Retry != nil { |
| 2279 | retry = *req.Retry |
| 2280 | } |
| 2281 | |
| 2282 | fireLimit := automationpkg.DefaultFireLimitConfig() |
| 2283 | if req.FireLimit != nil { |
| 2284 | fireLimit = *req.FireLimit |
| 2285 | } |
| 2286 | |
| 2287 | trigger := automationpkg.Trigger{ |
| 2288 | Scope: req.Scope, |
| 2289 | Name: strings.TrimSpace(req.Name), |
| 2290 | AgentName: strings.TrimSpace(req.AgentName), |
| 2291 | WorkspaceID: workspaceID, |
| 2292 | Prompt: strings.TrimSpace(req.Prompt), |
| 2293 | Event: strings.TrimSpace(req.Event), |
| 2294 | Filter: cloneHostAPIStringMap(req.Filter), |
| 2295 | Enabled: enabled, |
| 2296 | Retry: retry, |
| 2297 | FireLimit: fireLimit, |
| 2298 | Source: automationpkg.JobSourceDynamic, |
| 2299 | WebhookID: strings.TrimSpace(req.WebhookID), |
| 2300 | EndpointSlug: strings.TrimSpace(req.EndpointSlug), |
| 2301 | } |
| 2302 | write := automationpkg.WebhookSecretWrite{} |
| 2303 | if strings.TrimSpace(req.WebhookSecretValue) != "" { |
| 2304 | value := strings.TrimSpace(req.WebhookSecretValue) |
| 2305 | write.Value = &value |
| 2306 | } |
| 2307 | return trigger, write, nil |
| 2308 | } |
| 2309 | |
| 2310 | func (h *HostAPIHandler) applyTriggerUpdateParams( |
| 2311 | ctx context.Context, |
no test coverage detected