(deps commandDeps)
| 252 | } |
| 253 | |
| 254 | func newAutomationJobsUpdateCommand(deps commandDeps) *cobra.Command { |
| 255 | var ( |
| 256 | name string |
| 257 | agentName string |
| 258 | workspaceRef string |
| 259 | prompt string |
| 260 | scheduleRaw string |
| 261 | retryRaw string |
| 262 | enabled bool |
| 263 | ) |
| 264 | |
| 265 | cmd := &cobra.Command{ |
| 266 | Use: automationUpdateIDValue, |
| 267 | Short: "Update an automation job", |
| 268 | Args: exactOneNonBlankArg(), |
| 269 | RunE: func(cmd *cobra.Command, args []string) error { |
| 270 | client, err := clientFromDeps(deps) |
| 271 | if err != nil { |
| 272 | return err |
| 273 | } |
| 274 | |
| 275 | request, err := buildAutomationJobUpdateRequest(cmd, client, automationJobUpdateInput{ |
| 276 | Name: name, |
| 277 | AgentName: agentName, |
| 278 | WorkspaceRef: workspaceRef, |
| 279 | Prompt: prompt, |
| 280 | ScheduleRaw: scheduleRaw, |
| 281 | RetryRaw: retryRaw, |
| 282 | Enabled: enabled, |
| 283 | }) |
| 284 | if err != nil { |
| 285 | return err |
| 286 | } |
| 287 | if !request.HasChanges() { |
| 288 | return errors.New("cli: automation job update requires at least one change flag") |
| 289 | } |
| 290 | |
| 291 | updated, err := client.UpdateAutomationJob(cmd.Context(), args[0], request) |
| 292 | if err != nil { |
| 293 | return err |
| 294 | } |
| 295 | return writeCommandOutput(cmd, automationJobBundle(updated)) |
| 296 | }, |
| 297 | } |
| 298 | cmd.Flags().StringVar(&name, automationNameKey, "", "Update the job name") |
| 299 | cmd.Flags().StringVar(&agentName, "agent", "", "Update the agent definition") |
| 300 | cmd.Flags().StringVar(&workspaceRef, "workspace", "", "Update the workspace path, name, or ID") |
| 301 | cmd.Flags().StringVar(&prompt, automationPromptKey, "", "Update the prompt body") |
| 302 | cmd.Flags().StringVar(&scheduleRaw, "schedule", "", "Update the schedule spec") |
| 303 | cmd.Flags(). |
| 304 | StringVar(&retryRaw, automationRetryKey, "", `Update retry policy: "none", "backoff", or "backoff:<max_retries>:<base_delay>"`) |
| 305 | cmd.Flags().BoolVar(&enabled, automationEnabledKey, false, "Update the enabled state") |
| 306 | return cmd |
| 307 | } |
| 308 | |
| 309 | func buildAutomationJobUpdateRequest( |
| 310 | cmd *cobra.Command, |
no test coverage detected