availablenetworks

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MPL-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package network contains functionality for working EdgeCloud networks API resources

Example to List Network

allPages, err := availablenetworks.List(networkClient).AllPages()
if err != nil {
	panic(err)
}

allNetworks, err := availablenetworks.ExtractNetworks(allPages)
if err != nil {
	panic(err)
}

for _, network := range allNetworks {
	fmt.Printf("%+v", network)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractNetworksInto

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

Types

type ListOpts

type ListOpts struct {
	NetworkID   string `q:"network_id"`
	NetworkType string `q:"network_type"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToAvailableNetworkListQuery

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

ToAvailableNetworkListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type Network

type Network struct {
	Name      string                  `json:"name"`
	ID        string                  `json:"id"`
	Subnets   []subnets.Subnet        `json:"subnets"`
	MTU       int                     `json:"mtu"`
	Type      string                  `json:"type"`
	CreatedAt edgecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt *edgecloud.JSONRFC3339Z `json:"updated_at"`
	External  bool                    `json:"external"`
	Default   bool                    `json:"default"`
	Shared    bool                    `json:"shared"`
	TaskID    *string                 `json:"task_id"`
	ProjectID int                     `json:"project_id"`
	RegionID  int                     `json:"region_id"`
	Region    string                  `json:"region"`
}

Network represents a network structure.

func ExtractNetworks

func ExtractNetworks(r pagination.Page) ([]Network, error)

ExtractNetwork accepts a Page struct, specifically a NetworkPage struct, and extracts the elements into a slice of Network structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(client *edgecloud.ServiceClient, opts ListOptsBuilder) ([]Network, error)

ListAll is a convenience function that returns all networks.

type NetworkPage

type NetworkPage struct {
	pagination.LinkedPageBase
}

NetworkPage is the page returned by a pager when traversing over a collection of networks.

func (NetworkPage) IsEmpty

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

IsEmpty checks whether a NetworkPage struct is empty.

func (NetworkPage) NextPageURL

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

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

Directories

Path Synopsis
networks unit tests
networks unit tests

Jump to

Keyboard shortcuts

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