cmd

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateServiceKey

func CreateServiceKey(ctx context.Context, cmd *cobra.Command) error

func Execute

func Execute()

func GetServiceKey

func GetServiceKey(ctx context.Context, cmd *cobra.Command, keyID string) error

func ListServiceKeys

func ListServiceKeys(ctx context.Context, cmd *cobra.Command) error

func Login

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

Login is a wrapper function that calls loginFunc. This makes it easier to mock the login functionality in tests.

func UpdateServiceKey

func UpdateServiceKey(ctx context.Context, cmd *cobra.Command) error

Types

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"`
	// contains filtered or unexported fields
}

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
}

func ToMCROutput

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

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 {
	GetMCRErr                          error
	GetMCRResult                       *megaport.MCR
	ListMCRsErr                        error
	ListMCRsResult                     []*megaport.MCR
	BuyMCRErr                          error
	BuyMCRResult                       *megaport.BuyMCRResponse
	CapturedBuyMCRRequest              *megaport.BuyMCRRequest
	ValidateMCROrderErr                error
	ModifyMCRErr                       error
	ModifyMCRResult                    *megaport.ModifyMCRResponse
	CapturedModifyMCRRequest           *megaport.ModifyMCRRequest
	DeleteMCRErr                       error
	DeleteMCRResult                    *megaport.DeleteMCRResponse
	CapturedDeleteMCRUID               string
	RestoreMCRErr                      error
	RestoreMCRResult                   *megaport.RestoreMCRResponse
	CapturedRestoreMCRUID              string
	ListMCRResourceTagsErr             error
	ListMCRResourceTagsResult          map[string]string
	CapturedListMCRResourceTagsUID     string
	UpdateMCRResourceTagsErr           error
	CapturedUpdateMCRResourceTagsUID   string
	CapturedUpdateMCRResourceTagsTags  map[string]string
	CreatePrefixFilterListErr          error
	CreatePrefixFilterListResult       *megaport.CreateMCRPrefixFilterListResponse
	CapturedCreatePrefixFilterListReq  *megaport.CreateMCRPrefixFilterListRequest
	ListMCRPrefixFilterListsErr        error
	ListMCRPrefixFilterListsResult     []*megaport.PrefixFilterList
	CapturedListMCRPrefixFilterListsID string
	GetMCRPrefixFilterListErr          error
	GetMCRPrefixFilterListResult       *megaport.MCRPrefixFilterList
	CapturedGetMCRPrefixFilterListID   string
	CapturedGetMCRPrefixFilterListNum  int
	ModifyMCRPrefixFilterListErr       error
	ModifyMCRPrefixFilterListResult    *megaport.ModifyMCRPrefixFilterListResponse
	CapturedModifyPrefixFilterListID   string
	CapturedModifyPrefixFilterListNum  int
	CapturedModifyPrefixFilterListReq  *megaport.MCRPrefixFilterList
	DeleteMCRPrefixFilterListErr       error
	DeleteMCRPrefixFilterListResult    *megaport.DeleteMCRPrefixFilterListResponse
	CapturedDeletePrefixFilterListID   string
	CapturedDeletePrefixFilterListNum  int
}

func (*MockMCRService) BuyMCR

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, mcrId 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) ListMCRs

func (m *MockMCRService) ListMCRs(ctx context.Context) ([]*megaport.MCR, error)

func (*MockMCRService) ModifyMCR

func (*MockMCRService) ModifyMCRPrefixFilterList

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

func (*MockMCRService) RestoreMCR

func (m *MockMCRService) RestoreMCR(ctx context.Context, mcrId 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 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 PartnerOutput

type PartnerOutput struct {
	ProductName   string `json:"product_name"`
	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 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