From f1cf58635209337474d7eeabb97db513dceb5e5f Mon Sep 17 00:00:00 2001 From: Grant Arnold Date: Wed, 29 Oct 2025 21:38:56 +0000 Subject: [PATCH 1/2] Update source-id and source-type descriptions and examples. --- cmd/jobs.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/jobs.go b/cmd/jobs.go index be75f3c..f5b9743 100644 --- a/cmd/jobs.go +++ b/cmd/jobs.go @@ -132,7 +132,12 @@ func newJobsCmd() *cobra.Command { Use: "jobs", Short: "Lists jobs on FME Server", Long: "Lists running, queued, and/or queued jobs on FME Server. Pass in a job id to get information on a specific job.", - + PreRunE: func(cmd *cobra.Command, args []string) error { + if f.jobsSourceID != "" && f.jobsSourceType == "" { + return errors.New("--source-id requires --source-type to be specified") + } + return nil + }, Example: ` # List all jobs (currently limited to the most recent 1000) @@ -156,6 +161,12 @@ func newJobsCmd() *cobra.Command { # List all jobs in JSON format fmeflow jobs --json + + # List all jobs run from an automation with id 63f2489a-f3fc-4fa0-8df8-198de602b922 + fmeflow jobs --source-type automations --source-id 63f2489a-f3fc-4fa0-8df8-198de602b922 + + # List all jobs run from a schedule with id 32f819b6-b3dc-4cff-a320-8c56a7c81163 in JSON format + fmeflow jobs --source-type schedules --source-id 32f819b6-b3dc-4cff-a320-8c56a7c81163 --json # List the workspace, CPU time and peak memory usage for a given repository fmeflow jobs --repository Samples --output="custom-columns=WORKSPACE:.workspace,CPU Time:.cpuTime" @@ -179,8 +190,8 @@ func newJobsCmd() *cobra.Command { cmd.Flags().StringVar(&f.jobsRepository, "repository", "", "If specified, only jobs from the specified repository will be returned") cmd.Flags().StringVar(&f.jobsWorkspace, "workspace", "", "If specified along with repository, only jobs from the specified repository and workspace will be returned") cmd.Flags().StringVar(&f.jobsUserName, "user-name", "", "If specified, only jobs run by the specified user will be returned") - cmd.Flags().StringVar(&f.jobsSourceID, "source-id", "", "If specified along with source type, only jobs from the specified type with the specified id will be returned. For Automations, the source id is the automation id. For WorkspaceSubscriber, the source id is the id of the subscription. For Scheduler, the source id is the category and name of the schedule separated by '/'. For example, 'Category/Name'") - cmd.Flags().StringVar(&f.jobsSourceType, "source-type", "", "If specified, only jobs run by this source type will be returned") + cmd.Flags().StringVar(&f.jobsSourceID, "source-id", "", "If specified along with source type, only jobs that were run from the source with the specified id will be returned.") + cmd.Flags().StringVar(&f.jobsSourceType, "source-type", "", "If specified, only jobs run by this source type will be returned. One of: automations, workspaceSubscriptions, schedules, workspaceApps, automationApps, streams, fmeflow, dataVirtualization.") cmd.Flags().StringVarP(&f.outputType, "output", "o", "table", "Specify the output type. Should be one of table, json, or custom-columns") cmd.Flags().IntVar(&f.jobId, "id", -1, "Specify the job id to display") cmd.Flags().BoolVar(&f.noHeaders, "no-headers", false, "Don't print column headers") From 0e4a888bf71338fc586b99697a0c784b41be484c Mon Sep 17 00:00:00 2001 From: Grant Arnold Date: Wed, 29 Oct 2025 22:18:59 +0000 Subject: [PATCH 2/2] Fix tests. --- cmd/jobs.go | 10 ++++------ cmd/jobs_v3_test.go | 4 ++-- cmd/jobs_v4_test.go | 12 ++++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cmd/jobs.go b/cmd/jobs.go index f5b9743..658984b 100644 --- a/cmd/jobs.go +++ b/cmd/jobs.go @@ -132,12 +132,7 @@ func newJobsCmd() *cobra.Command { Use: "jobs", Short: "Lists jobs on FME Server", Long: "Lists running, queued, and/or queued jobs on FME Server. Pass in a job id to get information on a specific job.", - PreRunE: func(cmd *cobra.Command, args []string) error { - if f.jobsSourceID != "" && f.jobsSourceType == "" { - return errors.New("--source-id requires --source-type to be specified") - } - return nil - }, + Example: ` # List all jobs (currently limited to the most recent 1000) @@ -176,6 +171,9 @@ func newJobsCmd() *cobra.Command { if f.jobsWorkspace != "" { cmd.MarkFlagRequired("repository") } + if f.jobsSourceID != "" { + cmd.MarkFlagRequired("source-type") + } }, RunE: jobsRun(&f), } diff --git a/cmd/jobs_v3_test.go b/cmd/jobs_v3_test.go index 1709973..4b99da0 100644 --- a/cmd/jobs_v3_test.go +++ b/cmd/jobs_v3_test.go @@ -595,8 +595,8 @@ func TestJobs(t *testing.T) { { name: "get jobs by source id", statusCode: http.StatusOK, - args: []string{"jobs", "--source-id", "some-source-id"}, - wantFormParams: map[string]string{"sourceID": "some-source-id"}, + args: []string{"jobs", "--source-id", "63f2489a-f3fc-4fa0-8df8-198de602b922", "--source-type", "Automations"}, + wantFormParams: map[string]string{"sourceID": "63f2489a-f3fc-4fa0-8df8-198de602b922"}, fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, diff --git a/cmd/jobs_v4_test.go b/cmd/jobs_v4_test.go index 2a45b5e..77d3630 100644 --- a/cmd/jobs_v4_test.go +++ b/cmd/jobs_v4_test.go @@ -401,11 +401,19 @@ func TestJobsV4(t *testing.T) { { name: "get jobs v4 by source-id", statusCode: http.StatusOK, - args: []string{"jobs", "--source-id", "some-source-id"}, - wantFormParams: map[string]string{"sourceID": "some-source-id"}, + args: []string{"jobs", "--source-id", "63f2489a-f3fc-4fa0-8df8-198de602b922", "--source-type", "automations"}, + wantFormParams: map[string]string{"sourceID": "63f2489a-f3fc-4fa0-8df8-198de602b922"}, body: responseV4Active, fmeflowBuild: 25300, }, + { + name: "get jobs v4 by source-id no source-type", + statusCode: http.StatusOK, + args: []string{"jobs", "--source-id", "63f2489a-f3fc-4fa0-8df8-198de602b922"}, + wantErrText: "required flag(s) \"source-type\" not set", + body: responseV4Active, + fmeflowBuild: 25300, + }, { name: "get jobs v4 success and failure json", statusCode: http.StatusOK,