routers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

Create accepts a CreateOpts struct and creates a new router using the values provided.

func Delete

func Delete(c *edgecloud.ServiceClient, routerID string) (r tasks.Result)

Delete accepts a unique ID and deletes the router associated with it.

func ExtractRouterIDFromTask

func ExtractRouterIDFromTask(task *tasks.Task) (string, error)

func ExtractRoutersInto

func ExtractRoutersInto(r pagination.Page, v interface{}) error

func List

List returns a Pager which allows you to iterate over a collection of routers.

Types

type AttachOpts

type AttachOpts struct {
	SubnetID string `json:"subnet_id" required:"true"`
}

type CreateOpts

type CreateOpts struct {
	Name                string              `json:"name" required:"true"`
	ExternalGatewayInfo GatewayInfo         `json:"external_gateway_info,omitempty"`
	Interfaces          []Interface         `json:"interfaces,omitempty"`
	Routes              []subnets.HostRoute `json:"routes,omitempty"`
}

CreateOpts represents options used to create a router.

func (CreateOpts) ToRouterCreateMap

func (opts CreateOpts) ToRouterCreateMap() (map[string]interface{}, error)

ToRouterCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToRouterCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type ExtFixedIPs

type ExtFixedIPs struct {
	IPAddress string `json:"ip_address"`
	SubnetID  string `json:"subnet_id"`
}

ExternalFixedIP is the IP address and subnet ID of the external gateway of a router.

type ExtGatewayInfo

type ExtGatewayInfo struct {
	EnableSNat       bool          `json:"enable_snat"`
	ExternalFixedIPs []ExtFixedIPs `json:"external_fixed_ips"`
	NetworkID        string        `json:"network_id"`
}

GatewayInfo represents the information of an external gateway for any particular network router.

type GatewayInfo

type GatewayInfo struct {
	Type       types.GatewayType `json:"type,omitempty" validate:"omitempty,enum"`
	EnableSNat *bool             `json:"enable_snat"`
	NetworkID  string            `json:"network_id,omitempty" validate:"rfe=Type:manual,omitempty,uuid4"`
}

GatewayInfo represents the information of an external gateway for any particular network router.

func (*GatewayInfo) Validate

func (opts *GatewayInfo) Validate() error

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a get operation. Call its Extract method to interpret it as a router.

func Attach

func Attach(c *edgecloud.ServiceClient, routerID string, subnetID string) (r GetResult)

Attach subnet to router.

func Detach

func Detach(c *edgecloud.ServiceClient, routerID string, subnetID string) (r GetResult)

Detach subnet to router.

func Get

func Get(c *edgecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific router based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Router, error)

Extract is a function that accepts a result and extracts a router resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type Interface

type Interface struct {
	Type     types.InterfaceType `json:"type,omitempty" validate:"enum,required_with=SubnetID,omitempty"`
	SubnetID string              `json:"subnet_id,omitempty" validate:"rfe=Type:subnet,required_with=Type,omitempty,uuid4"`
}

Interface represents a list of interfaces to attach to router immediately after creation.

func (*Interface) Validate

func (opts *Interface) Validate() error

type ListOpts

type ListOpts struct {
	ID        string `q:"id"`
	Name      string `q:"name"`
	Status    string `q:"status"`
	ProjectID string `q:"project_id"`
	Limit     int    `q:"limit"`
}

ListOpts allows the filtering and sorting List API response.

func (ListOpts) ToRouterListQuery

func (opts ListOpts) ToRouterListQuery() (string, error)

ToRouterListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToRouterListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Router

type Router struct {
	ID                  string                 `json:"id"`
	Name                string                 `json:"name"`
	Status              string                 `json:"status"`
	ExternalGatewayInfo ExtGatewayInfo         `json:"external_gateway_info"`
	Routes              []subnets.HostRoute    `json:"routes"`
	Interfaces          []instances.Interface  `json:"interfaces"`
	TaskID              string                 `json:"task_id"`
	CreatorTaskID       string                 `json:"creator_task_id"`
	ProjectID           int                    `json:"project_id"`
	RegionID            int                    `json:"region_id"`
	CreatedAt           edgecloud.JSONRFC3339Z `json:"created_at"`
	UpdatedAt           edgecloud.JSONRFC3339Z `json:"updated_at"`
}

Router represents a router structure.

func ExtractRouters

func ExtractRouters(r pagination.Page) ([]Router, error)

ExtractRouter accepts a Page struct, specifically a RouterPage struct, and extracts the elements into a slice of Router structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(c *edgecloud.ServiceClient, opts ListOptsBuilder) ([]Router, error)

ListAll returns all routers.

type RouterPage

type RouterPage struct {
	pagination.LinkedPageBase
}

RouterPage is the page returned by a pager when traversing over a collection of routers.

func (RouterPage) IsEmpty

func (r RouterPage) IsEmpty() (bool, error)

IsEmpty checks whether a RouterPage struct is empty.

func (RouterPage) NextPageURL

func (r RouterPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of routers has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type RouterTaskResult

type RouterTaskResult struct {
	Routers []string `json:"routers"`
}

type UpdateOpts

type UpdateOpts struct {
	Name                string              `json:"name,omitempty"`
	ExternalGatewayInfo GatewayInfo         `json:"external_gateway_info,omitempty"`
	Routes              []subnets.HostRoute `json:"routes"`
}

UpdateOpts represents options used to update a router.

func (UpdateOpts) ToRouterUpdateMap

func (opts UpdateOpts) ToRouterUpdateMap() (map[string]interface{}, error)

ToRouterUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToRouterUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a router.

func Update

func Update(c *edgecloud.ServiceClient, routerID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates an existing router using the values provided. For more information, see the Create function.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Router, error)

Extract is a function that accepts a result and extracts a router resource.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

Directories

Path Synopsis
routers unit tests
routers unit tests

Jump to

Keyboard shortcuts

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