-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Metal Interconnections
- Loading branch information
1 parent
af4d427
commit 378fcc0
Showing
12 changed files
with
630 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## metal interconnections | ||
|
||
interconnections operations: create, get. | ||
|
||
### Synopsis | ||
|
||
Get information on Metro locations. For more information on https://deploy.equinix.com/developers/docs/metal/interconnections. | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for interconnections | ||
``` | ||
|
||
### 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 interconnections create](metal_interconnections_create.md) - Creates an interconnection. | ||
* [metal interconnections delete](metal_interconnections_delete.md) - Deletes a connection. | ||
* [metal interconnections get](metal_interconnections_get.md) - Retrieves interconnections for the current user, an organization, a project or the details of a specific interconnection. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
## metal interconnections create | ||
|
||
Creates an interconnection. | ||
|
||
### Synopsis | ||
|
||
Creates a new interconnection as per the organization ID or project ID | ||
|
||
``` | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy> ] [-t <type> ] [-p <project_id> ] | [-O <organization_id> ] [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Creates a new interconnection named "it-interconnection": | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "dedicated" ] [-p <project_id>] | [-O <organization_id>] | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "shared" ] [-p <project_id>] | [-O <organization_id>] -T <service_token_type> | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "shared" ] [-p <project_id>] | [-O <organization_id>] -T <service_token_type> -v <vrfs> | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for create | ||
-m, --metro string metro in the interconnection | ||
-n, --name string Name of the interconnection | ||
-O, --organizationID string Org ID | ||
-p, --projectID string project ID | ||
-r, --redundancy string Website URL of the organization. | ||
-T, --serviceTokentype string service token type for interconnection either fabric OR Metal builds | ||
-t, --type string type of of interconnection. | ||
-v, --vrfs strings Return only the specified vrfs. | ||
``` | ||
|
||
### 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 interconnections](metal_interconnections.md) - interconnections operations: create, get. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## metal interconnections delete | ||
|
||
Deletes a connection. | ||
|
||
### Synopsis | ||
|
||
Deletes the specified connection. | ||
|
||
``` | ||
metal interconnections delete -i <connection_id> [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Deletes the specified connection: | ||
metal interconnections delete -i 7ec86e23-8dcf-48ed-bd9b-c25c20958277 | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for delete | ||
-i, --id string The UUID of the connection. | ||
``` | ||
|
||
### 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 interconnections](metal_interconnections.md) - interconnections operations: create, get. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## metal interconnections get | ||
|
||
Retrieves interconnections for the current user, an organization, a project or the details of a specific interconnection. | ||
|
||
### Synopsis | ||
|
||
Retrieves interconnections for the current user, an organization, a project or the details of a specific interconnection. | ||
|
||
``` | ||
metal interconnections get [flags] | ||
``` | ||
|
||
### Examples | ||
|
||
``` | ||
# Retrieve all interconnections of a current user:: | ||
# Retrieve the details of a specific interconnection: | ||
metal interconnections get -i e9a969b3-8911-4667-9d99-57cd3dd4ef6f | ||
# Retrieve all the interconnection of an organization: | ||
metal interconnections get -O c079178c-9557-48f2-9ce7-cfb927b81928 | ||
# Retrieve all interconnection of a project: | ||
metal interconnections get -p 1867ee8f-6a11-470a-9505-952d6a324040 | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-i, --conn-id string UUID of the interconnection | ||
-h, --help help for get | ||
-O, --organization-id string UUID of the organization | ||
-p, --project-id string Project ID (METAL_PROJECT_ID) | ||
``` | ||
|
||
### 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 interconnections](metal_interconnections.md) - interconnections operations: create, get. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright © 2018 Jasmin Gacic <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package interconnections | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
metal "github.com/equinix-labs/metal-go/metal/v1" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func (c *Client) Create() *cobra.Command { | ||
var name, metro, redundancy, connType, projectID, organizationID string | ||
var serviceTokenType string | ||
var vrfs []string | ||
|
||
createInterconnectionsCmd := &cobra.Command{ | ||
Use: `create -n <name> [-m <metro>] [-r <redundancy> ] [-t <type> ] [-p <project_id> ] | [-O <organization_id> ]`, | ||
Short: "Creates an interconnection.", | ||
Long: "Creates a new interconnection as per the organization ID or project ID ", | ||
Example: ` # Creates a new interconnection named "it-interconnection": | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "dedicated" ] [-p <project_id>] | [-O <organization_id>] | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "shared" ] [-p <project_id>] | [-O <organization_id>] -T <service_token_type> | ||
metal interconnections create -n <name> [-m <metro>] [-r <redundancy>] [-t "shared" ] [-p <project_id>] | [-O <organization_id>] -T <service_token_type> -v <vrfs>`, | ||
|
||
RunE: func(cmd *cobra.Command, args []string) error { | ||
cmd.SilenceUsage = true | ||
var interconn *metal.Interconnection | ||
var proErr error | ||
var orgErr error | ||
|
||
interconnectionCreateInput := metal.NewInterconnectionCreateInput(metro, name, redundancy, connType) | ||
if connType == "shared" { | ||
interconnectionCreateInput.SetServiceTokenType(serviceTokenType) | ||
} | ||
|
||
if len(vrfs) > 0 { | ||
interconnectionCreateInput.SetVrfs(vrfs) | ||
} | ||
|
||
if projectID != "" { | ||
interconn, _, proErr = c.Service.CreateProjectInterconnection(context.Background(), projectID).InterconnectionCreateInput(*interconnectionCreateInput).Include(nil).Exclude(nil).Execute() | ||
if proErr != nil { | ||
return fmt.Errorf("could not create interconnections: %w", proErr) | ||
} | ||
} else { | ||
interconn, _, orgErr = c.Service.CreateOrganizationInterconnection(context.Background(), organizationID).InterconnectionCreateInput(*interconnectionCreateInput).Include(nil).Exclude(nil).Execute() | ||
if orgErr != nil { | ||
return fmt.Errorf("could not create interconnections: %w", orgErr) | ||
} | ||
} | ||
|
||
data := make([][]string, 1) | ||
|
||
data[0] = []string{interconn.GetId(), interconn.GetName(), interconn.GetType(), interconn.GetCreatedAt().String()} | ||
header := []string{"ID", "Name", "Type", "Created"} | ||
|
||
return c.Out.Output(interconn, header, &data) | ||
}, | ||
} | ||
|
||
createInterconnectionsCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the interconnection") | ||
createInterconnectionsCmd.Flags().StringVarP(&metro, "metro", "m", "", "metro in the interconnection") | ||
createInterconnectionsCmd.Flags().StringVarP(&redundancy, "redundancy", "r", "", "Website URL of the organization.") | ||
createInterconnectionsCmd.Flags().StringVarP(&connType, "type", "t", "", "type of of interconnection.") | ||
createInterconnectionsCmd.Flags().StringVarP(&connType, "serviceTokentype", "T", "", "service token type for interconnection either fabric OR Metal builds") | ||
createInterconnectionsCmd.Flags().StringSliceVarP(&vrfs, "vrfs", "v", []string{}, "Return only the specified vrfs.") | ||
createInterconnectionsCmd.Flags().StringVarP(&connType, "projectID", "p", "", "project ID") | ||
createInterconnectionsCmd.Flags().StringVarP(&connType, "organizationID", "O", "", "Org ID") | ||
|
||
_ = createInterconnectionsCmd.MarkFlagRequired("name") | ||
_ = createInterconnectionsCmd.MarkFlagRequired("metro") | ||
_ = createInterconnectionsCmd.MarkFlagRequired("redundancy") | ||
_ = createInterconnectionsCmd.MarkFlagRequired("type") | ||
return createInterconnectionsCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright © 2023 Jasmin Gacic <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package interconnections | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func (c *Client) Delete() *cobra.Command { | ||
var connectionID string | ||
|
||
deleteConnectionCmd := &cobra.Command{ | ||
Use: `delete -i <connection_id> `, | ||
Short: "Deletes a connection.", | ||
Long: "Deletes the specified connection.", | ||
Example: ` # Deletes the specified connection: | ||
metal interconnections delete -i 7ec86e23-8dcf-48ed-bd9b-c25c20958277`, | ||
|
||
RunE: func(cmd *cobra.Command, args []string) error { | ||
cmd.SilenceUsage = true | ||
_, _, err := c.Service.DeleteInterconnection(context.Background(), connectionID).Execute() | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println("connection deletion initiated. Please check 'metal interconnections get -i", connectionID, "' for status") | ||
return nil | ||
}, | ||
} | ||
|
||
deleteConnectionCmd.Flags().StringVarP(&connectionID, "id", "i", "", "The UUID of the connection.") | ||
|
||
return deleteConnectionCmd | ||
} |
Oops, something went wrong.