From 231d0868b1ee2c4b96cc99d41ad0528056b71049 Mon Sep 17 00:00:00 2001 From: Diana Doherty Date: Wed, 3 Mar 2021 18:00:58 -0500 Subject: [PATCH] Allow for update of connector status --- cmd/update.go | 71 +++++++++++++++++++++ docs/commands/meroxa.md | 3 +- docs/commands/meroxa_add.md | 2 +- docs/commands/meroxa_add_resource.md | 2 +- docs/commands/meroxa_api.md | 2 +- docs/commands/meroxa_billing.md | 2 +- docs/commands/meroxa_completion.md | 2 +- docs/commands/meroxa_connect.md | 2 +- docs/commands/meroxa_create.md | 2 +- docs/commands/meroxa_create_connector.md | 2 +- docs/commands/meroxa_create_endpoint.md | 2 +- docs/commands/meroxa_create_pipeline.md | 2 +- docs/commands/meroxa_describe.md | 2 +- docs/commands/meroxa_describe_connector.md | 2 +- docs/commands/meroxa_describe_endpoint.md | 2 +- docs/commands/meroxa_describe_resource.md | 2 +- docs/commands/meroxa_list.md | 2 +- docs/commands/meroxa_list_connectors.md | 2 +- docs/commands/meroxa_list_endpoint.md | 2 +- docs/commands/meroxa_list_pipelines.md | 2 +- docs/commands/meroxa_list_resource-types.md | 2 +- docs/commands/meroxa_list_resources.md | 2 +- docs/commands/meroxa_list_transforms.md | 2 +- docs/commands/meroxa_login.md | 2 +- docs/commands/meroxa_logout.md | 2 +- docs/commands/meroxa_logs.md | 2 +- docs/commands/meroxa_logs_connector.md | 2 +- docs/commands/meroxa_open.md | 2 +- docs/commands/meroxa_open_billing.md | 2 +- docs/commands/meroxa_remove.md | 2 +- docs/commands/meroxa_remove_connector.md | 2 +- docs/commands/meroxa_remove_endpoint.md | 2 +- docs/commands/meroxa_remove_pipeline.md | 2 +- docs/commands/meroxa_remove_resource.md | 2 +- docs/commands/meroxa_update.md | 27 ++++++++ docs/commands/meroxa_update_connector.md | 27 ++++++++ docs/commands/meroxa_version.md | 2 +- 37 files changed, 160 insertions(+), 34 deletions(-) create mode 100644 cmd/update.go create mode 100644 docs/commands/meroxa_update.md create mode 100644 docs/commands/meroxa_update_connector.md diff --git a/cmd/update.go b/cmd/update.go new file mode 100644 index 000000000..3af567ca8 --- /dev/null +++ b/cmd/update.go @@ -0,0 +1,71 @@ +package cmd + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/meroxa/cli/display" + "github.com/spf13/cobra" +) + +var ( + state string // connector state +) + +// updateCmd represents the update command +var updateCmd = &cobra.Command{ + Use: "update", + Short: "Update a component", + Long: `Update a component of the Meroxa platform, including connectors`, +} + +var updateConnectorCmd = &cobra.Command{ + Use: "connector --state ", + Short: "Update connector state", + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("requires connector name\n\nUsage:\n meroxa update connector --state ") + } + + // Connector Name + conName := args[0] + + c, err := client() + if err != nil { + return err + } + + ctx := context.Background() + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + // call meroxa-go to update connector status with name + if !flagRootOutputJSON { + fmt.Printf("Updating %s connector...\n", conName) + } + + con, err := c.UpdateConnectorStatus(ctx, conName, state) + if err != nil { + return err + } + + if flagRootOutputJSON { + display.JSONPrint(con) + } else { + fmt.Printf("Connector %s successfully updated!\n", con.Name) + } + + return nil + }, +} + +func init() { + RootCmd.AddCommand(updateCmd) + + // Subcommands + updateCmd.AddCommand(updateConnectorCmd) + updateConnectorCmd.Flags().StringVarP(&state, "state", "", "", "connector state") + updateConnectorCmd.MarkFlagRequired("state") +} diff --git a/docs/commands/meroxa.md b/docs/commands/meroxa.md index 7afa65541..d27189b4f 100644 --- a/docs/commands/meroxa.md +++ b/docs/commands/meroxa.md @@ -35,6 +35,7 @@ meroxa list resource-types * [meroxa logs](meroxa_logs.md) - Print logs for a component * [meroxa open](meroxa_open.md) - Open in a web browser * [meroxa remove](meroxa_remove.md) - Remove a component +* [meroxa update](meroxa_update.md) - Update a component * [meroxa version](meroxa_version.md) - Display the Meroxa CLI version -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_add.md b/docs/commands/meroxa_add.md index 967676016..a3c22d945 100644 --- a/docs/commands/meroxa_add.md +++ b/docs/commands/meroxa_add.md @@ -20,4 +20,4 @@ Add a resource to your Meroxa resource catalog * [meroxa](meroxa.md) - The Meroxa CLI * [meroxa add resource](meroxa_add_resource.md) - Add a resource to your Meroxa resource catalog -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_add_resource.md b/docs/commands/meroxa_add_resource.md index 09335f6b9..80753e740 100644 --- a/docs/commands/meroxa_add_resource.md +++ b/docs/commands/meroxa_add_resource.md @@ -42,4 +42,4 @@ meroxa add resource slack --type url -u $WEBHOOK_URL * [meroxa add](meroxa_add.md) - Add a resource to your Meroxa resource catalog -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_api.md b/docs/commands/meroxa_api.md index af9d590f0..1b731e17a 100644 --- a/docs/commands/meroxa_api.md +++ b/docs/commands/meroxa_api.md @@ -31,4 +31,4 @@ meroxa api POST /v1/endpoints '{"protocol": "HTTP", "stream": "resource-2-499379 * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_billing.md b/docs/commands/meroxa_billing.md index 91a88a70e..423d6e8ff 100644 --- a/docs/commands/meroxa_billing.md +++ b/docs/commands/meroxa_billing.md @@ -23,4 +23,4 @@ meroxa billing [flags] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_completion.md b/docs/commands/meroxa_completion.md index 6629038bd..e43f94e50 100644 --- a/docs/commands/meroxa_completion.md +++ b/docs/commands/meroxa_completion.md @@ -57,4 +57,4 @@ meroxa completion [bash|zsh|fish|powershell] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_connect.md b/docs/commands/meroxa_connect.md index 5dce4ce6c..b86f1e2ac 100644 --- a/docs/commands/meroxa_connect.md +++ b/docs/commands/meroxa_connect.md @@ -42,4 +42,4 @@ meroxa connect --from --to [flags] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_create.md b/docs/commands/meroxa_create.md index a74918c55..bddde50f5 100644 --- a/docs/commands/meroxa_create.md +++ b/docs/commands/meroxa_create.md @@ -27,4 +27,4 @@ including connectors. * [meroxa create endpoint](meroxa_create_endpoint.md) - Create an endpoint * [meroxa create pipeline](meroxa_create_pipeline.md) - Create a pipeline -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_create_connector.md b/docs/commands/meroxa_create_connector.md index a2c252f2d..e13b17125 100644 --- a/docs/commands/meroxa_create_connector.md +++ b/docs/commands/meroxa_create_connector.md @@ -38,4 +38,4 @@ meroxa create connector [] --to pg2redshift --input order * [meroxa create](meroxa_create.md) - Create Meroxa pipeline components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_create_endpoint.md b/docs/commands/meroxa_create_endpoint.md index 554a76f70..c67bac928 100644 --- a/docs/commands/meroxa_create_endpoint.md +++ b/docs/commands/meroxa_create_endpoint.md @@ -36,4 +36,4 @@ meroxa create endpoint my-endpoint --protocol http --stream my-stream * [meroxa create](meroxa_create.md) - Create Meroxa pipeline components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_create_pipeline.md b/docs/commands/meroxa_create_pipeline.md index 5c24476d8..0498e7a5c 100644 --- a/docs/commands/meroxa_create_pipeline.md +++ b/docs/commands/meroxa_create_pipeline.md @@ -24,4 +24,4 @@ meroxa create pipeline [flags] * [meroxa create](meroxa_create.md) - Create Meroxa pipeline components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_describe.md b/docs/commands/meroxa_describe.md index 09a2182e2..c7ee0d23b 100644 --- a/docs/commands/meroxa_describe.md +++ b/docs/commands/meroxa_describe.md @@ -26,4 +26,4 @@ Describe a component of the Meroxa data platform, including resources and connec * [meroxa describe endpoint](meroxa_describe_endpoint.md) - Describe Endpoint * [meroxa describe resource](meroxa_describe_resource.md) - Describe resource -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_describe_connector.md b/docs/commands/meroxa_describe_connector.md index 82e016d54..a62cf54c4 100644 --- a/docs/commands/meroxa_describe_connector.md +++ b/docs/commands/meroxa_describe_connector.md @@ -23,4 +23,4 @@ meroxa describe connector [name] [flags] * [meroxa describe](meroxa_describe.md) - Describe a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_describe_endpoint.md b/docs/commands/meroxa_describe_endpoint.md index 4ea182c02..3f576a4fb 100644 --- a/docs/commands/meroxa_describe_endpoint.md +++ b/docs/commands/meroxa_describe_endpoint.md @@ -23,4 +23,4 @@ meroxa describe endpoint [flags] * [meroxa describe](meroxa_describe.md) - Describe a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_describe_resource.md b/docs/commands/meroxa_describe_resource.md index 1bf309cba..4711148ec 100644 --- a/docs/commands/meroxa_describe_resource.md +++ b/docs/commands/meroxa_describe_resource.md @@ -23,4 +23,4 @@ meroxa describe resource [flags] * [meroxa describe](meroxa_describe.md) - Describe a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list.md b/docs/commands/meroxa_list.md index ed73b8ee4..bdf9e4fdb 100644 --- a/docs/commands/meroxa_list.md +++ b/docs/commands/meroxa_list.md @@ -30,4 +30,4 @@ List the components of the Meroxa platform, including pipelines, * [meroxa list resources](meroxa_list_resources.md) - List resources * [meroxa list transforms](meroxa_list_transforms.md) - List transforms -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_connectors.md b/docs/commands/meroxa_list_connectors.md index f3a0946aa..fd68d303a 100644 --- a/docs/commands/meroxa_list_connectors.md +++ b/docs/commands/meroxa_list_connectors.md @@ -23,4 +23,4 @@ meroxa list connectors [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_endpoint.md b/docs/commands/meroxa_list_endpoint.md index b76ee176d..67f564f95 100644 --- a/docs/commands/meroxa_list_endpoint.md +++ b/docs/commands/meroxa_list_endpoint.md @@ -23,4 +23,4 @@ meroxa list endpoint [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_pipelines.md b/docs/commands/meroxa_list_pipelines.md index 342d2594b..ec3df20b3 100644 --- a/docs/commands/meroxa_list_pipelines.md +++ b/docs/commands/meroxa_list_pipelines.md @@ -23,4 +23,4 @@ meroxa list pipelines [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_resource-types.md b/docs/commands/meroxa_list_resource-types.md index 4377cd330..afca56768 100644 --- a/docs/commands/meroxa_list_resource-types.md +++ b/docs/commands/meroxa_list_resource-types.md @@ -23,4 +23,4 @@ meroxa list resource-types [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_resources.md b/docs/commands/meroxa_list_resources.md index 299e0fd4a..eb374e74b 100644 --- a/docs/commands/meroxa_list_resources.md +++ b/docs/commands/meroxa_list_resources.md @@ -23,4 +23,4 @@ meroxa list resources [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_list_transforms.md b/docs/commands/meroxa_list_transforms.md index 8b1850cc4..476da5a37 100644 --- a/docs/commands/meroxa_list_transforms.md +++ b/docs/commands/meroxa_list_transforms.md @@ -23,4 +23,4 @@ meroxa list transforms [flags] * [meroxa list](meroxa_list.md) - List components -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_login.md b/docs/commands/meroxa_login.md index ac0339394..6d8b5d219 100644 --- a/docs/commands/meroxa_login.md +++ b/docs/commands/meroxa_login.md @@ -23,4 +23,4 @@ meroxa login [flags] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_logout.md b/docs/commands/meroxa_logout.md index 13d3b11ce..21afcf00a 100644 --- a/docs/commands/meroxa_logout.md +++ b/docs/commands/meroxa_logout.md @@ -23,4 +23,4 @@ meroxa logout [flags] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_logs.md b/docs/commands/meroxa_logs.md index 9e9c0724e..59c6afe5d 100644 --- a/docs/commands/meroxa_logs.md +++ b/docs/commands/meroxa_logs.md @@ -20,4 +20,4 @@ Print logs for a component * [meroxa](meroxa.md) - The Meroxa CLI * [meroxa logs connector](meroxa_logs_connector.md) - Print logs for a connector -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_logs_connector.md b/docs/commands/meroxa_logs_connector.md index e4ba33b84..6dd70a09f 100644 --- a/docs/commands/meroxa_logs_connector.md +++ b/docs/commands/meroxa_logs_connector.md @@ -23,4 +23,4 @@ meroxa logs connector [flags] * [meroxa logs](meroxa_logs.md) - Print logs for a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_open.md b/docs/commands/meroxa_open.md index f4c994a38..199165374 100644 --- a/docs/commands/meroxa_open.md +++ b/docs/commands/meroxa_open.md @@ -20,4 +20,4 @@ Open in a web browser * [meroxa](meroxa.md) - The Meroxa CLI * [meroxa open billing](meroxa_open_billing.md) - Open your billing page in a web browser -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_open_billing.md b/docs/commands/meroxa_open_billing.md index e311eb45c..a36111a5e 100644 --- a/docs/commands/meroxa_open_billing.md +++ b/docs/commands/meroxa_open_billing.md @@ -23,4 +23,4 @@ meroxa open billing [flags] * [meroxa open](meroxa_open.md) - Open in a web browser -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_remove.md b/docs/commands/meroxa_remove.md index aa3758bf5..ef4f88945 100644 --- a/docs/commands/meroxa_remove.md +++ b/docs/commands/meroxa_remove.md @@ -28,4 +28,4 @@ Deprovision a component of the Meroxa platform, including pipelines, * [meroxa remove pipeline](meroxa_remove_pipeline.md) - Remove pipeline * [meroxa remove resource](meroxa_remove_resource.md) - Remove resource -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_remove_connector.md b/docs/commands/meroxa_remove_connector.md index 14091335a..4278eecc1 100644 --- a/docs/commands/meroxa_remove_connector.md +++ b/docs/commands/meroxa_remove_connector.md @@ -23,4 +23,4 @@ meroxa remove connector [flags] * [meroxa remove](meroxa_remove.md) - Remove a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_remove_endpoint.md b/docs/commands/meroxa_remove_endpoint.md index 8b7d29297..fccccd136 100644 --- a/docs/commands/meroxa_remove_endpoint.md +++ b/docs/commands/meroxa_remove_endpoint.md @@ -23,4 +23,4 @@ meroxa remove endpoint [flags] * [meroxa remove](meroxa_remove.md) - Remove a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_remove_pipeline.md b/docs/commands/meroxa_remove_pipeline.md index 9a78ed378..1e5120ac1 100644 --- a/docs/commands/meroxa_remove_pipeline.md +++ b/docs/commands/meroxa_remove_pipeline.md @@ -23,4 +23,4 @@ meroxa remove pipeline [flags] * [meroxa remove](meroxa_remove.md) - Remove a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_remove_resource.md b/docs/commands/meroxa_remove_resource.md index 42860260f..006646e78 100644 --- a/docs/commands/meroxa_remove_resource.md +++ b/docs/commands/meroxa_remove_resource.md @@ -23,4 +23,4 @@ meroxa remove resource [flags] * [meroxa remove](meroxa_remove.md) - Remove a component -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_update.md b/docs/commands/meroxa_update.md new file mode 100644 index 000000000..4395132e3 --- /dev/null +++ b/docs/commands/meroxa_update.md @@ -0,0 +1,27 @@ +## meroxa update + +Update a component + +### Synopsis + +Update a component of the Meroxa platform, including connectors + +### Options + +``` + -h, --help help for update +``` + +### Options inherited from parent commands + +``` + --config string config file (default is $HOME/meroxa.env) + --json output json +``` + +### SEE ALSO + +* [meroxa](meroxa.md) - The Meroxa CLI +* [meroxa update connector](meroxa_update_connector.md) - Update connector state + +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_update_connector.md b/docs/commands/meroxa_update_connector.md new file mode 100644 index 000000000..98a5d311d --- /dev/null +++ b/docs/commands/meroxa_update_connector.md @@ -0,0 +1,27 @@ +## meroxa update connector + +Update connector state + +``` +meroxa update connector --state [flags] +``` + +### Options + +``` + -h, --help help for connector + --state string connector state +``` + +### Options inherited from parent commands + +``` + --config string config file (default is $HOME/meroxa.env) + --json output json +``` + +### SEE ALSO + +* [meroxa update](meroxa_update.md) - Update a component + +###### Auto generated by spf13/cobra on 5-Mar-2021 diff --git a/docs/commands/meroxa_version.md b/docs/commands/meroxa_version.md index 3a7e4eadd..51e6562a0 100644 --- a/docs/commands/meroxa_version.md +++ b/docs/commands/meroxa_version.md @@ -23,4 +23,4 @@ meroxa version [flags] * [meroxa](meroxa.md) - The Meroxa CLI -###### Auto generated by spf13/cobra on 4-Mar-2021 +###### Auto generated by spf13/cobra on 5-Mar-2021