Skip to content

Commit

Permalink
Allow for update of connector status
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Doherty committed Mar 5, 2021
1 parent 4772c41 commit 231d086
Show file tree
Hide file tree
Showing 37 changed files with 160 additions and 34 deletions.
71 changes: 71 additions & 0 deletions cmd/update.go
Original file line number Diff line number Diff line change
@@ -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 <name> --state <pause|resume|restart>",
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 <name> --state <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")
}
3 changes: 2 additions & 1 deletion docs/commands/meroxa.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_add_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ meroxa connect --from <resource-name> --to <resource-name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_create_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ meroxa create connector [<custom-connector-name>] --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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_create_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_create_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ meroxa create pipeline <name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_describe_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_describe_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa describe endpoint <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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_describe_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa describe resource <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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_resource-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_list_transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_logs_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa logs connector <name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_open.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_open_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_remove_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa remove connector <name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_remove_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa remove endpoint <name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_remove_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa remove pipeline <name> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_remove_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ meroxa remove resource <name> [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
27 changes: 27 additions & 0 deletions docs/commands/meroxa_update.md
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions docs/commands/meroxa_update_connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## meroxa update connector

Update connector state

```
meroxa update connector <name> --state <pause|resume|restart> [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
2 changes: 1 addition & 1 deletion docs/commands/meroxa_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 231d086

Please sign in to comment.