routes

package
v0.0.0-...-63319d1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package routes enables management and retrieval of Routes Route service.

Example to List Routes

listroute:=routes.ListOpts{VPC_ID:"93e94d8e-31a6-4c22-bdf7-8b23c7b67329"}
out,err:=routes.List(client,listroute)
fmt.Println(out[0].RouteID)

Example to Create a Route

route:=routes.CreateOpts{
	Type:"peering",
	NextHop:"d2dea4ba-e988-4e9c-8162-652e74b2560c",
	Destination:"192.168.0.0/16",
	VPC_ID:"3127e30b-5f8e-42d1-a3cc-fdadf412c5bf"}
outroute,err:=routes.Create(client,route).Extract()
fmt.Println(outroute)

Example to Delete a Route

out:=routes.Delete(client,"39a07dcb-f30e-41c1-97ac-182c8f0d43c1")
	fmt.Println(out)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns a Pager which allows you to iterate over a collection of vpc routes resources. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.

Types

type CreateOpts

type CreateOpts struct {
	Type        string `json:"type,omitempty" required:"true"`
	NextHop     string `json:"nexthop,omitempty" required:"true"`
	Destination string `json:"destination,omitempty" required:"true"`
	Tenant_Id   string `json:"tenant_id,omitempty"`
	VPC_ID      string `json:"vpc_id,omitempty" required:"true"`
}

CreateOpts contains all the values needed to create a new routes. There are no required values.

func (CreateOpts) ToRouteCreateMap

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

ToRouteCreateMap builds a create request body from CreateOpts.

type CreateOptsBuilder

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

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

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Route.

func Create

func Create(c *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create accepts a CreateOpts struct and uses the values to create a new logical routes. When it is created, the routes does not have an internal interface - it is not associated to any routes.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Route, error)

Extract is a function that accepts a result and extracts a Route.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(c *golangsdk.ServiceClient, id string) (r DeleteResult)

Delete will permanently delete a particular route based on its unique ID.

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 Route.

func Get

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

Get retrieves a particular route based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a Route.

type ListOpts

type ListOpts struct {
	// Specifies the route type.
	Type string `q:"type"`

	//Specifies the destination IP address or CIDR block.
	Destination string `q:"destination"`

	// Specifies the VPC for which a route is to be added.
	VPC_ID string `q:"vpc_id"`

	//Specifies the tenant ID. Only the administrator can specify the tenant ID of other tenants.
	Tenant_Id string `q:"tenant_id"`

	//Specifies the route ID.
	RouteID string `q:"id"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the attributes you want to see returned.

func (ListOpts) ToRouteListQuery

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

ToRouteListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

type Route

type Route struct {
	// Specifies the route type.
	Type string `json:"type"`

	// Specifies the next hop. If the route type is peering, enter the VPC peering connection ID.
	NextHop string `json:"nexthop"`

	//Specifies the destination IP address or CIDR block.
	Destination string `json:"destination"`

	// Specifies the VPC for which a route is to be added.
	VPC_ID string `json:"vpc_id"`

	//Specifies the tenant ID. Only the administrator can specify the tenant ID of other tenants.
	Tenant_Id string `json:"tenant_id"`

	//Specifies the route ID.
	RouteID string `json:"id"`
}

func ExtractRoutes

func ExtractRoutes(r pagination.Page) ([]Route, error)

ExtractRoutes accepts a Page struct, specifically a RoutePage struct, and extracts the elements into a slice of Roue structs. In other words, a generic collection is mapped into a relevant slice.

type RoutePage

type RoutePage struct {
	pagination.LinkedPageBase
}

RoutePage is the page returned by a pager when traversing over a collection of routes.

func (RoutePage) IsEmpty

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

IsEmpty checks whether a RoutePage struct is empty.

func (RoutePage) NextPageURL

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

NextPageURL is invoked when a paginated collection of routes 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.

Jump to

Keyboard shortcuts

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