cmd

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2025 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuyLAGPort added in v0.1.7

func BuyLAGPort(cmd *cobra.Command, args []string) error

func BuyMCR added in v0.1.7

func BuyMCR(cmd *cobra.Command, args []string) error

func BuyMVE added in v0.1.8

func BuyMVE(cmd *cobra.Command, args []string) error

BuyMVE handles the purchase of a new Megaport Virtual Edge device

func BuyPort added in v0.1.7

func BuyPort(cmd *cobra.Command, args []string) error

func BuyVXC added in v0.2.2

func BuyVXC(cmd *cobra.Command, args []string) error

func CheckPortVLANAvailability added in v0.1.7

func CheckPortVLANAvailability(cmd *cobra.Command, args []string) error

func CreateMCRPrefixFilterList added in v0.1.9

func CreateMCRPrefixFilterList(cmd *cobra.Command, args []string) error

func CreateServiceKey

func CreateServiceKey(cmd *cobra.Command, args []string) error

func DeleteMCR added in v0.1.7

func DeleteMCR(cmd *cobra.Command, args []string) error

func DeleteMCRPrefixFilterList added in v0.1.9

func DeleteMCRPrefixFilterList(cmd *cobra.Command, args []string) error

func DeleteMVE added in v0.2.1

func DeleteMVE(cmd *cobra.Command, args []string) error

func DeletePort added in v0.1.7

func DeletePort(cmd *cobra.Command, args []string) error

func DeleteVXC added in v0.2.5

func DeleteVXC(cmd *cobra.Command, args []string) error

func Execute

func Execute()

func FindPartners added in v0.2.6

func FindPartners(cmd *cobra.Command, args []string) error

FindPartners implements the interactive search functionality for partner ports.

func GetLocation added in v0.1.9

func GetLocation(cmd *cobra.Command, args []string) error

func GetMCR added in v0.1.7

func GetMCR(cmd *cobra.Command, args []string) error

func GetMCRPrefixFilterList added in v0.1.9

func GetMCRPrefixFilterList(cmd *cobra.Command, args []string) error

func GetMVE added in v0.1.7

func GetMVE(cmd *cobra.Command, args []string) error

func GetPort added in v0.1.7

func GetPort(cmd *cobra.Command, args []string) error

func GetServiceKey

func GetServiceKey(cmd *cobra.Command, args []string) error

func GetVXC added in v0.1.7

func GetVXC(cmd *cobra.Command, args []string) error

func ListAvailableMVESizes added in v0.2.0

func ListAvailableMVESizes(cmd *cobra.Command, args []string) error

func ListLocations added in v0.1.9

func ListLocations(cmd *cobra.Command, args []string) error

func ListMCRPrefixFilterLists added in v0.1.9

func ListMCRPrefixFilterLists(cmd *cobra.Command, args []string) error

func ListMVEImages added in v0.2.0

func ListMVEImages(cmd *cobra.Command, args []string) error

func ListPartners added in v0.1.7

func ListPartners(cmd *cobra.Command, args []string) error

func ListPorts added in v0.1.7

func ListPorts(cmd *cobra.Command, args []string) error

func ListServiceKeys

func ListServiceKeys(cmd *cobra.Command, args []string) error

func LockPort added in v0.1.7

func LockPort(cmd *cobra.Command, args []string) error

func Login

func Login(ctx context.Context) (*megaport.Client, error)

func RestoreMCR added in v0.1.7

func RestoreMCR(cmd *cobra.Command, args []string) error

func RestorePort added in v0.1.7

func RestorePort(cmd *cobra.Command, args []string) error

func RunCompletion added in v0.1.9

func RunCompletion(cmd *cobra.Command, args []string) error

func UnlockPort added in v0.1.7

func UnlockPort(cmd *cobra.Command, args []string) error

func UpdateMCR added in v0.2.1

func UpdateMCR(cmd *cobra.Command, args []string) error

func UpdateMCRPrefixFilterList added in v0.1.9

func UpdateMCRPrefixFilterList(cmd *cobra.Command, args []string) error

func UpdateMVE added in v0.2.1

func UpdateMVE(cmd *cobra.Command, args []string) error

func UpdatePort added in v0.1.7

func UpdatePort(cmd *cobra.Command, args []string) error

func UpdateServiceKey

func UpdateServiceKey(cmd *cobra.Command, args []string) error

func UpdateVXC added in v0.2.5

func UpdateVXC(cmd *cobra.Command, args []string) error

UpdateVXC updates an existing VXC with the provided configuration

func WrapRunE added in v0.1.9

func WrapRunE(runE func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string) error

WrapRunE wraps a RunE function to set SilenceUsage to true if an error occurs and formats the error message.

Types

type CommandData added in v0.2.9

type CommandData struct {
	Name               string
	Description        string
	LongDescription    string
	Usage              string
	Example            string
	HasParent          bool
	ParentCommandPath  string
	ParentCommandName  string
	ParentFilePath     string
	Aliases            []string
	Flags              []FlagInfo
	LocalFlags         []FlagInfo
	PersistentFlags    []FlagInfo
	HasSubCommands     bool
	SubCommands        []string
	IsAvailableCommand bool
	FilepathPrefix     string // Add this new field
}

type CommandInfo added in v0.2.9

type CommandInfo struct {
	Name        string
	Description string
	Path        string
}

type FlagInfo added in v0.2.9

type FlagInfo struct {
	Name        string
	Shorthand   string
	Default     string
	Description string
	Required    bool
}

type IndexData added in v0.2.9

type IndexData struct {
	Commands    []CommandInfo
	GeneratedAt string
	Version     string
}

type LocationOutput

type LocationOutput struct {
	ID        int     `json:"id"`
	Name      string  `json:"name"`
	Country   string  `json:"country"`
	Metro     string  `json:"metro"`
	SiteCode  string  `json:"site_code"`
	Market    string  `json:"market"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Status    string  `json:"status"`
}

LocationOutput represents the desired fields for JSON output.

func ToLocationOutput

func ToLocationOutput(l *megaport.Location) LocationOutput

ToLocationOutput converts a Location to a LocationOutput.

type MCROutput

type MCROutput struct {
	UID                string `json:"uid"`
	Name               string `json:"name"`
	LocationID         int    `json:"location_id"`
	ProvisioningStatus string `json:"provisioning_status"`
	// contains filtered or unexported fields
}

MCROutput represents the desired fields for JSON output of MCR details.

func ToMCROutput

func ToMCROutput(mcr *megaport.MCR) (MCROutput, error)

ToMCROutput converts a *megaport.MCR to our MCROutput struct.

type MVEOutput

type MVEOutput struct {
	UID        string `json:"uid"`
	Name       string `json:"name"`
	LocationID int    `json:"location_id"`
}

MVEOutput represents the desired fields for JSON output.

func ToMVEOutput

func ToMVEOutput(m *megaport.MVE) (MVEOutput, error)

ToMVEOutput converts an MVE to an MVEOutput.

type MockMCRService

type MockMCRService struct {
	BuyMCRResult                             *megaport.BuyMCRResponse
	BuyMCRErr                                error
	CapturedBuyMCRRequest                    *megaport.BuyMCRRequest
	ValidateMCROrderErr                      error
	GetMCRResult                             *megaport.MCR
	GetMCRErr                                error
	DeleteMCRResult                          *megaport.DeleteMCRResponse
	DeleteMCRErr                             error
	CapturedDeleteMCRUID                     string
	RestoreMCRResult                         *megaport.RestoreMCRResponse
	RestoreMCRErr                            error
	CapturedRestoreMCRUID                    string
	CreateMCRPrefixFilterListResult          *megaport.CreateMCRPrefixFilterListResponse
	CreateMCRPrefixFilterListErr             error
	CapturedCreateMCRPrefixFilterListRequest *megaport.CreateMCRPrefixFilterListRequest
	CapturedCreatePrefixFilterListRequest    *megaport.CreateMCRPrefixFilterListRequest

	CreateMCRPrefixFilterListResponse *megaport.CreateMCRPrefixFilterListResponse
	CreateMCRPrefixFilterListError    error
	CapturedCreatePrefixFilterList    *megaport.CreateMCRPrefixFilterListRequest

	ListMCRPrefixFilterListsResult           []*megaport.PrefixFilterList
	ListMCRPrefixFilterListsErr              error
	GetMCRPrefixFilterListResult             *megaport.MCRPrefixFilterList
	GetMCRPrefixFilterListErr                error
	ModifyMCRPrefixFilterListResult          *megaport.ModifyMCRPrefixFilterListResponse
	ModifyMCRPrefixFilterListErr             error
	CapturedModifyMCRPrefixFilterListRequest *megaport.MCRPrefixFilterList
	DeleteMCRPrefixFilterListResult          *megaport.DeleteMCRPrefixFilterListResponse
	DeleteMCRPrefixFilterListErr             error
	ModifyMCRResult                          *megaport.ModifyMCRResponse
	ModifyMCRErr                             error
	CapturedModifyMCRRequest                 *megaport.ModifyMCRRequest
	ListMCRResourceTagsResult                map[string]string
	ListMCRResourceTagsErr                   error
	UpdateMCRResourceTagsErr                 error
	CapturedUpdateMCRResourceTagsRequest     map[string]string
	GetMCRPrefixFilterListsResult            []*megaport.PrefixFilterList
	GetMCRPrefixFilterListsErr               error
	CapturedModifyPrefixFilterListMCRID      string
	CapturedModifyPrefixFilterListID         int
	CapturedModifyPrefixFilterList           *megaport.MCRPrefixFilterList
}

func (*MockMCRService) BuyMCR

func (*MockMCRService) CreatePrefixFilterList

CreatePrefixFilterList mocks the CreatePrefixFilterList method

func (*MockMCRService) DeleteMCR

func (*MockMCRService) DeleteMCRPrefixFilterList

func (m *MockMCRService) DeleteMCRPrefixFilterList(ctx context.Context, mcrID string, prefixFilterListID int) (*megaport.DeleteMCRPrefixFilterListResponse, error)

func (*MockMCRService) GetMCR

func (m *MockMCRService) GetMCR(ctx context.Context, mcrUID string) (*megaport.MCR, error)

func (*MockMCRService) GetMCRPrefixFilterList

func (m *MockMCRService) GetMCRPrefixFilterList(ctx context.Context, mcrID string, prefixFilterListID int) (*megaport.MCRPrefixFilterList, error)

func (*MockMCRService) GetMCRPrefixFilterLists

func (m *MockMCRService) GetMCRPrefixFilterLists(ctx context.Context, mcrID string) ([]*megaport.PrefixFilterList, error)

func (*MockMCRService) ListMCRPrefixFilterLists

func (m *MockMCRService) ListMCRPrefixFilterLists(ctx context.Context, mcrID string) ([]*megaport.PrefixFilterList, error)

func (*MockMCRService) ListMCRResourceTags

func (m *MockMCRService) ListMCRResourceTags(ctx context.Context, mcrID string) (map[string]string, error)

func (*MockMCRService) ModifyMCR

ModifyMCR mocks the ModifyMCR method of the MCR service

func (*MockMCRService) ModifyMCRPrefixFilterList

func (m *MockMCRService) ModifyMCRPrefixFilterList(ctx context.Context, mcrID string, prefixFilterListID int, prefixFilterList *megaport.MCRPrefixFilterList) (*megaport.ModifyMCRPrefixFilterListResponse, error)

ModifyMCRPrefixFilterList mocks the ModifyMCRPrefixFilterList method

func (*MockMCRService) RestoreMCR

func (m *MockMCRService) RestoreMCR(ctx context.Context, mcrUID string) (*megaport.RestoreMCRResponse, error)

func (*MockMCRService) UpdateMCRResourceTags

func (m *MockMCRService) UpdateMCRResourceTags(ctx context.Context, mcrID string, tags map[string]string) error

func (*MockMCRService) ValidateMCROrder

func (m *MockMCRService) ValidateMCROrder(ctx context.Context, req *megaport.BuyMCRRequest) error

type MockMVEService added in v0.1.8

type MockMVEService struct {
	mock.Mock
	BuyMVEError                       error
	BuyMVEResult                      *megaport.BuyMVEResponse
	CapturedBuyMVERequest             *megaport.BuyMVERequest
	ValidateMVEOrderError             error
	GetMVEError                       error
	GetMVEResult                      *megaport.MVE
	ModifyMVEError                    error
	ModifyMVEResult                   *megaport.ModifyMVEResponse
	CapturedModifyMVERequest          *megaport.ModifyMVERequest
	DeleteMVEError                    error
	DeleteMVEResult                   *megaport.DeleteMVEResponse
	CapturedDeleteMVERequest          *megaport.DeleteMVERequest
	ListMVEImagesError                error
	ListMVEImagesResult               []*megaport.MVEImage
	ListAvailableMVESizesError        error
	ListAvailableMVESizesResult       []*megaport.MVESize
	ListMVEResourceTagsError          error
	ListMVEResourceTagsResult         map[string]string
	CapturedListMVEResourceTagsUID    string
	UpdateMVEResourceTagsError        error
	CapturedUpdateMVEResourceTagsUID  string
	CapturedUpdateMVEResourceTagsTags map[string]string
}

func (*MockMVEService) BuyMVE added in v0.1.8

func (*MockMVEService) DeleteMVE added in v0.1.8

func (*MockMVEService) GetMVE added in v0.1.8

func (m *MockMVEService) GetMVE(ctx context.Context, mveId string) (*megaport.MVE, error)

func (*MockMVEService) ListAvailableMVESizes added in v0.1.8

func (m *MockMVEService) ListAvailableMVESizes(ctx context.Context) ([]*megaport.MVESize, error)

func (*MockMVEService) ListMVEImages added in v0.1.8

func (m *MockMVEService) ListMVEImages(ctx context.Context) ([]*megaport.MVEImage, error)

func (*MockMVEService) ListMVEResourceTags added in v0.1.8

func (m *MockMVEService) ListMVEResourceTags(ctx context.Context, mveID string) (map[string]string, error)

func (*MockMVEService) ModifyMVE added in v0.1.8

func (*MockMVEService) Reset added in v0.2.3

func (m *MockMVEService) Reset()

func (*MockMVEService) UpdateMVEResourceTags added in v0.1.8

func (m *MockMVEService) UpdateMVEResourceTags(ctx context.Context, mveID string, tags map[string]string) error

func (*MockMVEService) ValidateMVEOrder added in v0.1.8

func (m *MockMVEService) ValidateMVEOrder(ctx context.Context, req *megaport.BuyMVERequest) error

type MockPortService

type MockPortService struct {
	// Optional fields to customize behavior
	GetPortErr                      error
	GetPortResult                   *megaport.Port
	ListPortsErr                    error
	ListPortsResult                 []*megaport.Port
	BuyPortErr                      error
	BuyPortResult                   *megaport.BuyPortResponse
	CapturedRequest                 *megaport.BuyPortRequest
	CheckPortVLANAvailabilityErr    error
	CheckPortVLANAvailabilityResult bool
	CapturedVLANRequest             struct {
		PortID string
		VLANID int
	}
	DeletePortErr         error
	DeletePortResult      *megaport.DeletePortResponse
	CapturedDeletePortUID string

	ListPortResourceTagsErr    error
	ListPortResourceTagsResult map[string]string
	CapturedResourceTagPortUID string

	ValidatePortOrderErr      error
	ModifyPortErr             error
	ModifyPortResult          *megaport.ModifyPortResponse
	CapturedModifyPortRequest *megaport.ModifyPortRequest
	RestorePortErr            error
	RestorePortResult         *megaport.RestorePortResponse
	CapturedRestorePortUID    string
	LockPortErr               error
	LockPortResult            *megaport.LockPortResponse
	CapturedLockPortUID       string
	UnlockPortErr             error
	UnlockPortResult          *megaport.UnlockPortResponse
	CapturedUnlockPortUID     string
	UpdatePortResourceTagsErr error
	CapturedUpdateTagsRequest struct {
		PortID string
		Tags   map[string]string
	}
	UpdatePortErr    error
	UpdatePortResult *megaport.ModifyPortResponse
}

MockPortService implements the required Port service methods for testing

func (*MockPortService) BuyPort

func (*MockPortService) CheckPortVLANAvailability

func (m *MockPortService) CheckPortVLANAvailability(ctx context.Context, portID string, vlanID int) (bool, error)

func (*MockPortService) DeletePort

func (*MockPortService) GetPort

func (m *MockPortService) GetPort(ctx context.Context, portID string) (*megaport.Port, error)

func (*MockPortService) ListPortResourceTags

func (m *MockPortService) ListPortResourceTags(ctx context.Context, portID string) (map[string]string, error)

func (*MockPortService) ListPorts

func (m *MockPortService) ListPorts(ctx context.Context) ([]*megaport.Port, error)

func (*MockPortService) LockPort

func (m *MockPortService) LockPort(ctx context.Context, portId string) (*megaport.LockPortResponse, error)

func (*MockPortService) ModifyPort

func (*MockPortService) RestorePort

func (m *MockPortService) RestorePort(ctx context.Context, portId string) (*megaport.RestorePortResponse, error)

func (*MockPortService) UnlockPort

func (m *MockPortService) UnlockPort(ctx context.Context, portId string) (*megaport.UnlockPortResponse, error)

func (*MockPortService) UpdatePortResourceTags

func (m *MockPortService) UpdatePortResourceTags(ctx context.Context, portID string, tags map[string]string) error

func (*MockPortService) ValidatePortOrder

func (m *MockPortService) ValidatePortOrder(ctx context.Context, req *megaport.BuyPortRequest) error

type MockServiceKeyService added in v0.1.8

type MockServiceKeyService struct {
	CreateServiceKeyError           error
	CreateServiceKeyResult          *megaport.CreateServiceKeyResponse
	CapturedCreateServiceKeyRequest *megaport.CreateServiceKeyRequest

	ListServiceKeysError           error
	ListServiceKeysResult          *megaport.ListServiceKeysResponse
	CapturedListServiceKeysRequest *megaport.ListServiceKeysRequest

	UpdateServiceKeyError           error
	UpdateServiceKeyResult          *megaport.UpdateServiceKeyResponse
	CapturedUpdateServiceKeyRequest *megaport.UpdateServiceKeyRequest

	GetServiceKeyError         error
	GetServiceKeyResult        *megaport.ServiceKey
	CapturedGetServiceKeyKeyID string
}

func (*MockServiceKeyService) CreateServiceKey added in v0.1.8

func (*MockServiceKeyService) GetServiceKey added in v0.1.8

func (m *MockServiceKeyService) GetServiceKey(ctx context.Context, keyId string) (*megaport.ServiceKey, error)

func (*MockServiceKeyService) ListServiceKeys added in v0.1.8

func (*MockServiceKeyService) UpdateServiceKey added in v0.1.8

type OutputFields added in v0.2.9

type OutputFields interface {
	any
}

OutputFields is a marker interface for output-formattable types

type PartnerOutput

type PartnerOutput struct {
	ProductName   string `json:"product_name"`
	UID           string `json:"uid"`
	ConnectType   string `json:"connect_type"`
	CompanyName   string `json:"company_name"`
	LocationId    int    `json:"location_id"`
	DiversityZone string `json:"diversity_zone"`
	VXCPermitted  bool   `json:"vxc_permitted"`
	// contains filtered or unexported fields
}

PartnerOutput represents the desired fields for JSON output.

func ToPartnerOutput

func ToPartnerOutput(p *megaport.PartnerMegaport) PartnerOutput

ToPartnerOutput converts a PartnerMegaport to a PartnerOutput.

type PortOutput

type PortOutput struct {
	UID                string `json:"uid"`
	Name               string `json:"name"`
	LocationID         int    `json:"location_id"`
	PortSpeed          int    `json:"port_speed"`
	ProvisioningStatus string `json:"provisioning_status"`
}

PortOutput represents the desired fields for JSON output.

func ToPortOutput

func ToPortOutput(port *megaport.Port) (PortOutput, error)

ToPortOutput converts a *megaport.Port to our PortOutput struct.

type PrefixFilterListEntryOutput added in v0.1.9

type PrefixFilterListEntryOutput struct {
	Action string `json:"action"`
	Prefix string `json:"prefix"`
	Ge     int    `json:"ge,omitempty"`
	Le     int    `json:"le,omitempty"`
}

type PrefixFilterListOutput added in v0.1.9

type PrefixFilterListOutput struct {
	ID            int                           `json:"id"`
	Description   string                        `json:"description"`
	AddressFamily string                        `json:"address_family"`
	Entries       []PrefixFilterListEntryOutput `json:"entries"`
}

PrefixFilterListOutput represents the desired fields for JSON output.

func ToPrefixFilterListOutput added in v0.1.9

func ToPrefixFilterListOutput(prefixFilterList *megaport.MCRPrefixFilterList) (PrefixFilterListOutput, error)

ToPrefixFilterListOutput converts a *megaport.MCRPrefixFilterList to our PrefixFilterListOutput struct.

type ServiceKeyOutput

type ServiceKeyOutput struct {
	KeyUID      string `json:"key_uid"`
	ProductName string `json:"product_name"`
	ProductUID  string `json:"product_uid"`
	Description string `json:"description"`
	CreateDate  string `json:"create_date"`
	// contains filtered or unexported fields
}

ServiceKeyOutput represents the desired fields for output

func ToServiceKeyOutput

func ToServiceKeyOutput(sk *megaport.ServiceKey) (ServiceKeyOutput, error)

ToServiceKeyOutput converts a ServiceKey to ServiceKeyOutput

type VXCOutput

type VXCOutput struct {
	UID     string `json:"uid"`
	Name    string `json:"name"`
	AEndUID string `json:"a_end_uid"`
	BEndUID string `json:"b_end_uid"`
	// contains filtered or unexported fields
}

VXCOutput represents the desired fields for JSON output.

func ToVXCOutput

func ToVXCOutput(v *megaport.VXC) (VXCOutput, error)

ToVXCOutput converts a VXC to a VXCOutput.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL