Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands for named connections #51

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions cmd/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@ func newConnectionsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "connections",
Short: "Lists connections on FME Flow",
Long: "Lists connections on FME Flow. Pass in a name to retrieve information on a single project.",
Long: "Lists connections on FME Flow. Pass in a name to retrieve information on a single connection.",
Example: `
# List all projects
fmeflow projects

# List all projects owned by the user admin
fmeflow projects --owner admin`,
# List all connections
fmeflow connections

# Get a single connection with the name "myConnection"
fmeflow connections --name myConnection

# List all connections of type "Google Drive"
fmeflow connections --type "Google Drive"

# List all database connections
fmeflow connections --category database

# List the PostgreSQL connections with custom columns showing the name and host of the database connections
fmeflow connections --category "database" --type "PostgreSQL" --output=custom-columns="NAME:.name,HOST:.parameters.HOST" `,
Args: NoArgs,
RunE: connectionsRun(&f),
}
Expand Down
10 changes: 6 additions & 4 deletions cmd/connections_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ func newConnectionCreateCmd() *cobra.Command {
Short: "Create a connection",
Long: `Create a connection.`,
Example: `
Examples:
# Create a connection with the name "myConnection" and the category "PostgreSQL" and the type "database" with username "myUser" and password "myPassword"
fmeflow connections create --name myConnection --category database --type PostgreSQL --username myUser --password myPassword
# Create a PostgreSQL connection
fmeflow connections create --name myPGSQLConnection --category database --type PostgreSQL --parameter HOST=myDBHost --parameter PORT=5432 --parameter DATASET=dbname --parameter USER_NAME=dbuser --parameter SSL_OPTIONS="" --parameter SSLMODE=prefer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting SSL_OPTIONS to an empty string required here? That is, will the endpoint complain if we don't mention it at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is required, even if it is an empty string 😄


# Create a Google Drive connection (web service must already exist on FME Flow)
fmeflow connections create --name googleDriveConn --category oauthV2 --type "Google Drive"
`,

Args: NoArgs,
Expand All @@ -56,7 +58,7 @@ func newConnectionCreateCmd() *cobra.Command {
cmd.Flags().StringVar(&f.name, "name", "", "Name of the connection to create.")
cmd.Flags().StringVar(&f.category, "category", "", "Category of the connection to create. Typically it is one of: \"basic\", \"database\", \"token\", \"oauthV1\", \"oauthV2\".")
cmd.Flags().StringVar(&f.connectionType, "type", "", "Type of connection.")
cmd.Flags().StringVar(&f.authenticationMethod, "authenticationMethod", "", "Authentication method of the connection to create.")
cmd.Flags().StringVar(&f.authenticationMethod, "authentication-method", "", "Authentication method of the connection to create.")
cmd.Flags().StringVar(&f.username, "username", "", "Username of the connection to create.")
cmd.Flags().StringVar(&f.password, "password", "", "Password of the connection to create.")
cmd.Flags().StringArrayVar(&f.parameter, "parameter", []string{}, "Parameters of the connection to create. Must be of the form name=value. Can be specified multiple times.")
Expand Down
4 changes: 2 additions & 2 deletions cmd/connections_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func TestConnectionsCreate(t *testing.T) {
{
name: "create connection",
statusCode: http.StatusCreated,
args: []string{"connections", "create", "--name", "test123aa", "--category", "database", "--type", "PostgreSQL", "--username", "test", "--password", "test", "--parameter", "HOST=a", "--parameter", "PORT=5432", "--parameter", "DATASET=dbname", "--parameter", "USER_NAME=a", "--parameter", "SSL_OPTIONS=a", "--parameter", "SSLMODE=prefer"},
args: []string{"connections", "create", "--name", "test123aa", "--category", "database", "--type", "PostgreSQL", "--parameter", "HOST=a", "--parameter", "PORT=5432", "--parameter", "DATASET=dbname", "--parameter", "USER_NAME=a", "--parameter", "SSL_OPTIONS=a", "--parameter", "SSLMODE=prefer"},
wantOutputRegex: "^[\\s]*Connection successfully created.[\\s]*$",
},
{
name: "create connection json output",
statusCode: http.StatusCreated,
args: []string{"connections", "create", "--name", "test123aa", "--category", "database", "--type", "PostgreSQL", "--username", "test", "--password", "test", "--parameter", "HOST=a", "--parameter", "PORT=5432", "--parameter", "DATASET=dbname", "--parameter", "USER_NAME=a", "--parameter", "SSL_OPTIONS=a", "--parameter", "SSLMODE=prefer", "--json"},
args: []string{"connections", "create", "--name", "test123aa", "--category", "database", "--type", "PostgreSQL", "--parameter", "HOST=a", "--parameter", "PORT=5432", "--parameter", "DATASET=dbname", "--parameter", "USER_NAME=a", "--parameter", "SSL_OPTIONS=a", "--parameter", "SSLMODE=prefer", "--json"},
wantOutputJson: "{}",
},
{
Expand Down
5 changes: 2 additions & 3 deletions cmd/connections_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ func newConnectionDeleteCmd() *cobra.Command {
Short: "Delete a connection",
Long: `Delete a connection.`,
Example: `
Examples:
# Delete a connection with the name "myConnection"
fmeflow connections delete --name myConnection
# Delete a connection with the name "myConnection"
fmeflow connections delete --name myConnection
`,

Args: NoArgs,
Expand Down
9 changes: 4 additions & 5 deletions cmd/connections_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,18 @@ func newConnectionUpdateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "update",
Short: "Update a connection",
Long: `Update a connection.`,
Long: `Update a connection. Only things that need to be modified need to be specified.`,
Example: `
Examples:
# Update a connection with the name "myConnection" and the category "PostgreSQL" and the type "database" with username "myUser" and password "myPassword"
fmeflow connections update --name myConnection --category database --username myUser --password myPassword
# Update a PostgreSQL connection with the name "myPGSQLConnection" and modify the host to "myDBHost"
fmeflow connections update --name myPGSQLConnection --parameter HOST=myDBHost
`,

Args: NoArgs,
RunE: connectionUpdateRun(&f),
}

cmd.Flags().StringVar(&f.name, "name", "", "Name of the connection to update.")
cmd.Flags().StringVar(&f.authenticationMethod, "authenticationMethod", "", "Authentication method of the connection to update.")
cmd.Flags().StringVar(&f.authenticationMethod, "authentication-method", "", "Authentication method of the connection to update.")
cmd.Flags().StringVar(&f.username, "username", "", "Username of the connection to update.")
cmd.Flags().StringVar(&f.password, "password", "", "Password of the connection to update.")
cmd.Flags().StringArrayVar(&f.parameter, "parameter", []string{}, "Parameters of the connection to update. Must be of the form name=value. Can be specified multiple times.")
Expand Down
13 changes: 6 additions & 7 deletions cmd/deploymentparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ func newDeploymentParametersCmd() *cobra.Command {
Short: "List Deployment Parameters",
Long: `Lists Deployment Parameters on the given FME Server.`,
Example: `
Examples:
# List all deployment parameters
fmeflow deploymentparameters
# List all deployment parameters
fmeflow deploymentparameters

# List a single deployment parameter
fmeflow deploymentparameters --name testParameter
# List a single deployment parameter
fmeflow deploymentparameters --name testParameter

# Output all deploymentparameters in json format
fmeflow deploymentparameters --json`,
# Output all deploymentparameters in json format
fmeflow deploymentparameters --json`,
Args: NoArgs,
RunE: deploymentParametersRun(&f),
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/deploymentparameters_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ func newDeploymentParameterCreateCmd() *cobra.Command {
Short: "Create a deployment parameter",
Long: `Create a deployment parameter.`,
Example: `
Examples:
# Create a deployment parameter with the name "myParam" and the value "myValue"
fmeflow deploymentparameters create --name myParam --value myValue
# Create a deployment parameter with the name "myParam" and the value "myValue"
fmeflow deploymentparameters create --name myParam --value myValue
`,

Args: NoArgs,
Expand Down
9 changes: 4 additions & 5 deletions cmd/deploymentparameters_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ func newDeploymentParameterDeleteCmd() *cobra.Command {
Short: "Delete a deployment parameter",
Long: `Delete a deployment parameter.`,
Example: `
Examples:
# Delete adeployment parameter with the name "myParam"
fmeflow deploymentparameters delete --name myParam
# Delete adeployment parameter with the name "myParam"
fmeflow deploymentparameters delete --name myParam

# Delete a repository with the name "myRepository" and no confirmation
fmeflow deploymentparameters delete --name myParam --no-prompt
# Delete a repository with the name "myRepository" and no confirmation
fmeflow deploymentparameters delete --name myParam --no-prompt
`,
Args: NoArgs,
RunE: deploymentParameterDeleteRun(&f),
Expand Down
6 changes: 3 additions & 3 deletions cmd/deploymentparameters_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func newDeploymentParameterUpdateCmd() *cobra.Command {
Short: "Update a deployment parameter",
Long: `Update a deployment parameter.`,
Example: `
Examples:
# Update a deployment parameter with the name "myParam" and the value "myValue"
fmeflow deploymentparameters update --name myParam --value myValue

# Update a deployment parameter with the name "myParam" and the value "myValue"
fmeflow deploymentparameters update --name myParam --value myValue
`,

Args: NoArgs,
Expand Down
21 changes: 10 additions & 11 deletions cmd/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,20 @@ func newRepositoryCmd() *cobra.Command {
Short: "List repositories",
Long: `Lists repositories on the given FME Server. Pass in a name to get information on a specific repository.`,
Example: `
Examples:
# List all repositories
fmeflow repositories
# List all repositories
fmeflow repositories

# List all repositories owned by the admin user
fmeflow repositories --owner admin
# List all repositories owned by the admin user
fmeflow repositories --owner admin

# List a single repository with the name "Samples"
fmeflow repositories --name Samples
# List a single repository with the name "Samples"
fmeflow repositories --name Samples

# Output just the name of all the repositories
fmeflow repositories --output=custom-columns=NAME:.name --no-headers
# Output just the name of all the repositories
fmeflow repositories --output=custom-columns=NAME:.name --no-headers

# Output all repositories in json format
fmeflow repositories --json`,
# Output all repositories in json format
fmeflow repositories --json`,
Args: NoArgs,
PreRunE: func(cmd *cobra.Command, args []string) error {
// get build to decide if we should use v3 or v4
Expand Down
9 changes: 4 additions & 5 deletions cmd/repositories_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ func newRepositoryCreateCmd() *cobra.Command {
Short: "Create a new repository.",
Long: `Create a new repository.`,
Example: `
Examples:
# Create a repository with the name "myRepository" and no description
fmeflow repositories create --name myRepository
# Create a repository with the name "myRepository" and no description
fmeflow repositories create --name myRepository

# Output just the name of all the repositories
fmeflow repositories create --name myRepository --description "This is my new repository"
# Output just the name of all the repositories
fmeflow repositories create --name myRepository --description "This is my new repository"
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// get build to decide if we should use v3 or v4
Expand Down
9 changes: 4 additions & 5 deletions cmd/repositories_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ func newRepositoryDeleteCmd() *cobra.Command {
Short: "Delete a repository.",
Long: `Delete a repository.`,
Example: `
Examples:
# Delete a repository with the name "myRepository"
fmeflow repositories delete --name myRepository
# Delete a repository with the name "myRepository"
fmeflow repositories delete --name myRepository

# Delete a repository with the name "myRepository" and no confirmation
fmeflow repositories delete --name myRepository --no-prompt
# Delete a repository with the name "myRepository" and no confirmation
fmeflow repositories delete --name myRepository --no-prompt
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
// get build to decide if we should use v3 or v4
Expand Down
29 changes: 14 additions & 15 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,25 @@ func newRunCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "run",
Short: "Run a workspace on FME Server.",
Long: `Run a workspace on FME Server.

Examples:
# Submit a job asynchronously
fmeflow run --repository Samples --workspace austinApartments.fmw
Long: `Run a workspace on FME Server.`,
Example: `
# Submit a job asynchronously
fmeflow run --repository Samples --workspace austinApartments.fmw

# Submit a job and wait for it to complete
fmeflow run --repository Samples --workspace austinApartments.fmw --wait
# Submit a job and wait for it to complete
fmeflow run --repository Samples --workspace austinApartments.fmw --wait

# Submit a job to a specific queue and set a time to live in the queue
fmeflow run --repository Samples --workspace austinApartments.fmw --tag Queue1 --time-to-live 120
# Submit a job to a specific queue and set a time to live in the queue
fmeflow run --repository Samples --workspace austinApartments.fmw --tag Queue1 --time-to-live 120

# Submit a job and pass in a few published parameters
fmeflow run --repository Samples --workspace austinDownload.fmw --published-parameter-list THEMES=railroad,airports --published-parameter COORDSYS=TX83-CF
# Submit a job and pass in a few published parameters
fmeflow run --repository Samples --workspace austinDownload.fmw --published-parameter-list THEMES=railroad,airports --published-parameter COORDSYS=TX83-CF

# Submit a job, wait for it to complete, and customize the output
fmeflow run --repository Samples --workspace austinApartments.fmw --wait --output="custom-columns=Time Requested:.timeRequested,Time Started:.timeStarted,Time Finished:.timeFinished"
# Submit a job, wait for it to complete, and customize the output
fmeflow run --repository Samples --workspace austinApartments.fmw --wait --output="custom-columns=Time Requested:.timeRequested,Time Started:.timeStarted,Time Finished:.timeFinished"

# Upload a local file to use as the source data for the translation
fmeflow run --repository Samples --workspace austinApartments.fmw --file Landmarks-edited.sqlite --wait`,
# Upload a local file to use as the source data for the translation
fmeflow run --repository Samples --workspace austinApartments.fmw --file Landmarks-edited.sqlite --wait`,
Args: NoArgs,
RunE: runRun(&f),
}
Expand Down
25 changes: 12 additions & 13 deletions cmd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,24 +338,23 @@ func newWorkspaceCmd() *cobra.Command {
Short: "List workspaces.",
Long: `Lists workspaces that exist on the FME Server. Filter by repository, specify a name to retrieve a specific workspace, or specify a filter string to narrow down by name or title.`,
Example: `
Examples:
# List all workspaces on the FME Server
fmeflow workspaces
# List all workspaces on the FME Server
fmeflow workspaces

# List all workspaces in Samples repository
fmeflow workspaces --repository Samples
# List all workspaces in Samples repository
fmeflow workspaces --repository Samples

# List all workspaces in the Samples repository and output it in json
fmeflow workspaces --repository Samples --json
# List all workspaces in the Samples repository and output it in json
fmeflow workspaces --repository Samples --json

# List all workspaces in the Samples repository with custom columns showing the last publish date and number of times run
fmeflow workspaces --repository Samples --output="custom-columns=NAME:.name,PUBLISH DATE:.lastPublishDate,TOTAL RUNS:.totalRuns"
# List all workspaces in the Samples repository with custom columns showing the last publish date and number of times run
fmeflow workspaces --repository Samples --output="custom-columns=NAME:.name,PUBLISH DATE:.lastPublishDate,TOTAL RUNS:.totalRuns"

# Get information on a single workspace
fmeflow workspaces --repository Samples --name austinApartments.fmw
# Get information on a single workspace
fmeflow workspaces --repository Samples --name austinApartments.fmw

# Get the name, source format, and destination format for this workspace
fmeflow workspaces --repository Samples --name austinApartments.fmw --output=custom-columns=NAME:.name,SOURCE:.datasets.source[*].format,DEST:.datasets.destination[*].format`,
# Get the name, source format, and destination format for this workspace
fmeflow workspaces --repository Samples --name austinApartments.fmw --output=custom-columns=NAME:.name,SOURCE:.datasets.source[*].format,DEST:.datasets.destination[*].format`,
Args: NoArgs,
PreRunE: func(cmd *cobra.Command, args []string) error {
// get build to decide if we should use v3 or v4
Expand Down
2 changes: 1 addition & 1 deletion docs/custom-columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ For a slightly more complicated example, specifying a specific workspace gives m
}
```

The JSON about a single workspace includes information on source and destination datasets, that are stored in a JSON list. In JSONPath, lists are accessed using `[]`, with a specific index being specified as a number such as `[0]`, or all results from that list being denoted as `[*]`. For examples, if we want to get all the source formats for this workspace, we would use the JSonPath query `.datasets.source[*].format`. A full example:
The JSON about a single workspace includes information on source and destination datasets, that are stored in a JSON list. In JSONPath, lists are accessed using `[]`, with a specific index being specified as a number such as `[0]`, or all results from that list being denoted as `[*]`. For example, if we want to get all the source formats for this workspace, we would use the JSonPath query `.datasets.source[*].format`. A full example:

```
> fmeflow workspaces --repository Samples --name "austinApartments.fmw" --output custom-columns="NAME:.name,SOURCE:.datasets.source[*].format,DEST:datasets.destination[*].format"
Expand Down
19 changes: 14 additions & 5 deletions docs/fmeflow_connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Lists connections on FME Flow

### Synopsis

Lists connections on FME Flow. Pass in a name to retrieve information on a single project.
Lists connections on FME Flow. Pass in a name to retrieve information on a single connection.

```
fmeflow connections [flags]
Expand All @@ -14,11 +14,20 @@ fmeflow connections [flags]

```

# List all projects
fmeflow projects
# List all connections
fmeflow connections

# List all projects owned by the user admin
fmeflow projects --owner admin
# Get a single connection with the name "myConnection"
fmeflow connections --name myConnection

# List all connections of type "Google Drive"
fmeflow connections --type "Google Drive"

# List all database connections
fmeflow connections --category database

# List the PostgreSQL connections with custom columns showing the name and host of the database connections
fmeflow connections --category "database" --type "PostgreSQL" --output=custom-columns="NAME:.name,HOST:.parameters.HOST"
```

### Options
Expand Down
Loading
Loading