subnets

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

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

func Delete

func Delete(c *gcorecloud.ServiceClient, subnetID string) (r tasks.Result)

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

func ExtractSubnetIDFromTask

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

func ExtractSubnetsInto

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

func IDFromName

func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)

IDFromName is a convenience function that returns a subnet ID, given its name.

func List

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

Types

type CreateOpts

type CreateOpts struct {
	Name                   string            `json:"name" required:"true"`
	EnableDHCP             bool              `json:"enable_dhcp,omitempty"`
	CIDR                   gcorecloud.CIDR   `json:"cidr" required:"true"`
	NetworkID              string            `json:"network_id" required:"true"`
	ConnectToNetworkRouter bool              `json:"connect_to_network_router"`
	DNSNameservers         []net.IP          `json:"dns_nameservers,omitempty"`
	HostRoutes             []HostRoute       `json:"host_routes,omitempty"`
	GatewayIP              *net.IP           `json:"gateway_ip"`
	IPVersion              int               `json:"ip_version,omitempty"`
	Metadata               map[string]string `json:"metadata,omitempty"`
}

CreateOpts represents options used to create a subnet. GatewayIP must be null in json because an empty key creates a gateway in the neutron API.

func (CreateOpts) ToSubnetCreateMap

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

ToSubnetCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

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

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

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

func Get

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

Get retrieves a specific subnet based on its unique ID.

func (GetResult) Extract

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

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

func (GetResult) ExtractInto

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

type HostRoute

type HostRoute struct {
	Destination gcorecloud.CIDR `json:"destination"`
	NextHop     net.IP          `json:"nexthop"`
}

HostRoute represents a route that should be used by devices with IPs from a subnet (not including local subnet route).

type ListOpts

type ListOpts struct {
	MetadataK  string            `q:"metadata_k" validate:"omitempty"`
	MetadataKV map[string]string `q:"metadata_kv" validate:"omitempty"`
	NetworkID  string            `q:"network_id"`
}

ListOpts allows the filtering and sorting List API response.

func (ListOpts) ToSubnetListQuery

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

ToSubnetListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type Subnet

type Subnet struct {
	ID             string                  `json:"id"`
	Name           string                  `json:"name"`
	IPVersion      int                     `json:"ip_version"`
	EnableDHCP     bool                    `json:"enable_dhcp"`
	CIDR           gcorecloud.CIDR         `json:"cidr"`
	CreatedAt      gcorecloud.JSONRFC3339Z `json:"created_at"`
	UpdatedAt      gcorecloud.JSONRFC3339Z `json:"updated_at"`
	NetworkID      string                  `json:"network_id"`
	TaskID         string                  `json:"task_id"`
	CreatorTaskID  string                  `json:"creator_task_id"`
	Region         string                  `json:"region"`
	ProjectID      int                     `json:"project_id"`
	RegionID       int                     `json:"region_id"`
	AvailableIps   *big.Int                `json:"available_ips"`
	TotalIps       *big.Int                `json:"total_ips"`
	HasRouter      bool                    `json:"has_router"`
	DNSNameservers []net.IP                `json:"dns_nameservers"`
	HostRoutes     []HostRoute             `json:"host_routes"`
	GatewayIP      net.IP                  `json:"gateway_ip"`
	Metadata       []metadata.Metadata     `json:"metadata"`
}

Subnet represents a subnet structure.

func ExtractSubnets

func ExtractSubnets(r pagination.Page) ([]Subnet, error)

ExtractSubnet accepts a Page struct, specifically a SubnetPage struct, and extracts the elements into a slice of Subnet structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(c *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Subnet, error)

ListAll returns all SGs

type SubnetPage

type SubnetPage struct {
	pagination.LinkedPageBase
}

SubnetPage is the page returned by a pager when traversing over a collection of subnets.

func (SubnetPage) IsEmpty

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

IsEmpty checks whether a SubnetPage struct is empty.

func (SubnetPage) NextPageURL

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

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

type SubnetTaskResult struct {
	Subnets []string `json:"subnets"`
}

type UpdateOpts

type UpdateOpts struct {
	Name           string      `json:"name,omitempty"`
	DNSNameservers []net.IP    `json:"dns_nameservers"`
	HostRoutes     []HostRoute `json:"host_routes"`
	EnableDHCP     bool        `json:"enable_dhcp"`
	GatewayIP      *net.IP     `json:"gateway_ip"`
}

UpdateOpts represents options used to update a subnet. GatewayIP must be null in json because an empty key creates a gateway in the neutron API.

func (UpdateOpts) ToSubnetUpdateMap

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

ToSubnetUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToSubnetUpdateMap() (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 Subnet.

func Update

func Update(c *gcorecloud.ServiceClient, subnetID string, opts UpdateOptsBuilder) (r UpdateResult)

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

func (UpdateResult) Extract

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

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

func (UpdateResult) ExtractInto

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

Directories

Path Synopsis
subnets unit tests
subnets unit tests

Jump to

Keyboard shortcuts

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