availablenetworks

package
v0.4.23 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package network contains functionality for working GCLoud 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 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 gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt *gcorecloud.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 *gcorecloud.ServiceClient) ([]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