Skip to content

Commit

Permalink
docs: add loadbalancer-beta docs
Browse files Browse the repository at this point in the history
Signed-off-by: Marques Johansson <[email protected]>
  • Loading branch information
displague committed Dec 14, 2023
1 parent 3745f6a commit d962bed
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 189 deletions.
1 change: 1 addition & 0 deletions docs/metal.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Command line interface for Equinix Metal
* [metal init](metal_init.md) - Create a configuration file.
* [metal interconnections](metal_interconnections.md) - interconnections operations: create, get, update, delete
* [metal ip](metal_ip.md) - IP address, reservations, and assignment operations: assign, unassign, remove, available, request and get.
* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete.
* [metal metros](metal_metros.md) - Metro operations: get.
* [metal operating-systems](metal_operating-systems.md) - Operating system operations: get.
* [metal organization](metal_organization.md) - Organization operations: create, get, update, payment-methods, and delete.
Expand Down
36 changes: 36 additions & 0 deletions docs/metal_loadbalancer-beta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## metal loadbalancer-beta

LoadBalancer BETA operations: create, get, update, and delete.

### Synopsis

Information and management for LoadBalancers is on https://deploy.equinix.com/developers/docs/metal/networking/load-balancers/.

### Options

```
-h, --help help for loadbalancer-beta
```

### Options inherited from parent commands

```
--config string Path to JSON or YAML configuration file
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters.
--http-header strings Headers to add to requests (in format key=value)
--include strings Comma separated Href references to expand in results, may be dotted three levels deep
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp).
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources.
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources.
--token string Metal API Token (METAL_AUTH_TOKEN)
```

### SEE ALSO

* [metal](metal.md) - Command line interface for Equinix Metal
* [metal loadbalancer-beta create](metal_loadbalancer-beta_create.md) - Creates a loadbalancer.
* [metal loadbalancer-beta delete](metal_loadbalancer-beta_delete.md) - Deletes a loadbalancer.
* [metal loadbalancer-beta get](metal_loadbalancer-beta_get.md) - Retrieves all the project loadbalancers or the details of a specified loadbalancer.

52 changes: 52 additions & 0 deletions docs/metal_loadbalancer-beta_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## metal loadbalancer-beta create

Creates a loadbalancer.

### Synopsis

Creates a loadbalancer with the specified name.

```
metal loadbalancer-beta create -n <loadbalancer_name> -l <location_id_or_metro> [-p <project_UUID>] [--provider <provider_id>] [--port <port_UUID>] [flags]
```

### Examples

```
# Creates a new loadbalancer named dev-loadbal in the Dallas metro:
metal loadbalancer create --name dev-loadbal -l da
# Creates a new loadbalancer named prod-loadbal in the DC metro:
metal loadbalancer create -n prod-loadbal -l dc
```

### Options

```
-h, --help help for create
-l, --location string The location's ID. This flag is required.
-n, --name string Name of the loadbalancer
--port strings The port(s) UUID
-p, --project-id string The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.
-r, --provider string The provider ID. (default "loadpvd-gOB_-byp5ebFo7A3LHv2B")
```

### Options inherited from parent commands

```
--config string Path to JSON or YAML configuration file
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters.
--http-header strings Headers to add to requests (in format key=value)
--include strings Comma separated Href references to expand in results, may be dotted three levels deep
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp).
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources.
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources.
--token string Metal API Token (METAL_AUTH_TOKEN)
```

### SEE ALSO

* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete.

51 changes: 51 additions & 0 deletions docs/metal_loadbalancer-beta_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## metal loadbalancer-beta delete

Deletes a loadbalancer.

### Synopsis

Deletes the specified loadbalancer with a confirmation prompt. To skip the confirmation use --force.

```
metal loadbalancer-beta delete --id <loadbalancer_UUID> [--force] [flags]
```

### Examples

```
# Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375:
metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375
>
✔ Are you sure you want to delete loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375: y
# Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375, skipping confirmation:
metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375 -f
```

### Options

```
-f, --force Force removal of the loadbalancer
-h, --help help for delete
-i, --id string The loadbalancer's ID. This flag is required.
```

### Options inherited from parent commands

```
--config string Path to JSON or YAML configuration file
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters.
--http-header strings Headers to add to requests (in format key=value)
--include strings Comma separated Href references to expand in results, may be dotted three levels deep
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp).
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources.
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources.
--token string Metal API Token (METAL_AUTH_TOKEN)
```

### SEE ALSO

* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete.

53 changes: 53 additions & 0 deletions docs/metal_loadbalancer-beta_get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## metal loadbalancer-beta get

Retrieves all the project loadbalancers or the details of a specified loadbalancer.

### Synopsis

Retrieves all the project loadbalancers or the details of a specified loadbalancer. You can specify which loadbalancer by UUID or name.

```
metal loadbalancer-beta get [-i <loadbalancer_UUID> | -n <loadbalancer_name>] [flags]
```

### Examples

```
# Retrieve all loadbalancers:
metal loadbalancer get
# Retrieve a specific loadbalancer by UUID:
metal loadbalancer get -i 2008f885-1aac-406b-8d99-e6963fd21333
# Retrieve a specific loadbalancer by name:
metal loadbalancer get -n dev-cluster03
```

### Options

```
-h, --help help for get
-i, --id string The loadbalancer's UUID, which can be specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.
-n, --loadbalancer string The name of the loadbalancer.
-p, --project-id string The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.
```

### Options inherited from parent commands

```
--config string Path to JSON or YAML configuration file
--exclude strings Comma separated Href references to collapse in results, may be dotted three levels deep
--filter stringArray Filter 'get' actions with name value pairs. Filter is not supported by all resources and is implemented as request query parameters.
--http-header strings Headers to add to requests (in format key=value)
--include strings Comma separated Href references to expand in results, may be dotted three levels deep
-o, --output string Output format (*table, json, yaml). env output formats are (*sh, terraform, capp).
--search string Search keyword for use in 'get' actions. Search is not supported by all resources.
--sort-by string Sort fields for use in 'get' actions. Sort is not supported by all resources.
--sort-dir string Sort field direction for use in 'get' actions. Sort is not supported by all resources.
--token string Metal API Token (METAL_AUTH_TOKEN)
```

### SEE ALSO

* [metal loadbalancer-beta](metal_loadbalancer-beta.md) - LoadBalancer BETA operations: create, get, update, and delete.

16 changes: 8 additions & 8 deletions internal/loadbalancers/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func (c *Client) Create() *cobra.Command {

// loadbalancerCreateCmd represents the loadbalancerCreate command
createLoadBalancerCmd := &cobra.Command{
Use: `create -n <loadbalancer_name> [-O <organization_UUID>] [-m <payment_method_UUID>]`,
Use: `create -n <loadbalancer_name> -l <location_id_or_metro> [-p <project_UUID>] [--provider <provider_id>] [--port <port_UUID>]`,
Short: "Creates a loadbalancer.",
Long: "Creates a loadbalancer with the specified name. If no organization is specified, the loadbalancer is created in the current user's default organization. If no payment method is specified the organization's default payment method is used.",
Example: ` # Creates a new loadbalancer named dev-cluster02:
metal loadbalancer create --name dev-cluster02
Long: "Creates a loadbalancer with the specified name.",
Example: ` # Creates a new loadbalancer named dev-loadbal in the Dallas metro:
metal loadbalancer create --name dev-loadbal -l da
# Creates a new loadbalancer named dev-cluster03 in the specified organization with a payment method:
metal loadbalancer create -n dev-cluster03 -O 814b09ca-0d0c-4656-9de0-4ce65c6faf70 -m ab1fbdaa-8b25-4c3e-8360-e283852e3747`,
# Creates a new loadbalancer named prod-loadbal in the DC metro:
metal loadbalancer create -n prod-loadbal -l dc`,

RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
Expand Down Expand Up @@ -81,9 +81,9 @@ func (c *Client) Create() *cobra.Command {

createLoadBalancerCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the loadbalancer")
createLoadBalancerCmd.Flags().StringVarP(&projectID, "project-id", "p", "", "The project's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PROJECT_ID environment variable.")
createLoadBalancerCmd.Flags().StringVarP(&locationId, "location", "l", "", "The location's ID.")
createLoadBalancerCmd.Flags().StringVarP(&locationId, "location", "l", "", "The location's ID. This flag is required.")
createLoadBalancerCmd.Flags().StringVarP(&providerId, "provider", "r", ProviderID, "The provider ID.")
createLoadBalancerCmd.Flags().StringSliceVar(&portIds, "port", []string{}, "The port's UUID. This flag is required, unless specified in the config created by metal init or set as METAL_PORT_ID environment variable.")
createLoadBalancerCmd.Flags().StringSliceVar(&portIds, "port", []string{}, "The port(s) UUID")

// TODO(displague) Not sure if this is needed
_ = createLoadBalancerCmd.MarkFlagRequired("location")
Expand Down
19 changes: 11 additions & 8 deletions internal/loadbalancers/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ package loadbalancers
import (
"context"
"fmt"
"strings"

"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
)

func (c *Client) Delete() *cobra.Command {
var (
force bool
loadbalancerID string
confirmation string
)
deleteLoadBalancer := func(id string) error {
_, err := c.loadBalancerService.DeleteLoadBalancer(context.Background(), id).Execute()
Expand All @@ -45,7 +46,7 @@ func (c *Client) Delete() *cobra.Command {
deleteLoadBalancerCmd := &cobra.Command{
Use: `delete --id <loadbalancer_UUID> [--force]`,
Short: "Deletes a loadbalancer.",
Long: "Deletes the specified loadbalancer with a confirmation prompt. To skip the confirmation use --force. You can't delete a loadbalancer that has active resources. You have to deprovision all servers and other infrastructure from a loadbalancer in order to delete it.",
Long: "Deletes the specified loadbalancer with a confirmation prompt. To skip the confirmation use --force.",
Example: ` # Deletes loadbalancer 50693ba9-e4e4-4d8a-9eb2-4840b11e9375:
metal loadbalancer delete -i 50693ba9-e4e4-4d8a-9eb2-4840b11e9375
>
Expand All @@ -57,16 +58,18 @@ func (c *Client) Delete() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
if !force {
prompt := promptui.Prompt{
Label: fmt.Sprintf("Are you sure you want to delete loadbalancer %s: ", loadbalancerID),
IsConfirm: true,
}

_, err := prompt.Run()
fmt.Printf("Are you sure you want to delete Metal Loadbalancer %s [Y/N]: ", loadbalancerID)
_, err := fmt.Scanln(&confirmation)
if err != nil {
return nil
}
}
confirmation = strings.TrimSpace(strings.ToLower(confirmation))
if confirmation != "yes" && confirmation != "y" {
fmt.Println("Metal Loadbalancer deletion cancelled.")
return nil
}

if err := deleteLoadBalancer(loadbalancerID); err != nil {
return fmt.Errorf("Could not delete LoadBalancer: %w", err)
}
Expand Down
Loading

0 comments on commit d962bed

Please sign in to comment.