subnets

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: 3 Imported by: 0

Documentation

Overview

Package Subnets enables management and retrieval of Subnets

Example to List Vpcs

listOpts := subnets.ListOpts{}
allSubnets, err := subnets.List(subnetClient, listOpts)
if err != nil {
	panic(err)
}

for _, subnet := range allSubnets {
	fmt.Printf("%+v\n", subnet)
}

Example to Create a Vpc

createOpts := subnets.CreateOpts{
	Name:          "test_subnets",
	CIDR:          "192.168.0.0/16"
	GatewayIP:	   "192.168.0.1"
	PRIMARY_DNS:   "8.8.8.8"
	SECONDARY_DNS: "8.8.4.4"
	AvailabilityZone:"eu-de-02"
	VPC_ID:"3b9740a0-b44d-48f0-84ee-42eb166e54f7"

}
vpc, err := subnets.Create(subnetClient, createOpts).Extract()

if err != nil {
	panic(err)
}

Example to Update a Vpc

subnetID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

updateOpts := subnets.UpdateOpts{
	Name:          "testsubnet",
}

subnet, err := subnets.Update(subnetClient, subnetID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Vpc

subnetID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"

err := subnets.Delete(subnetClient, subnetID).ExtractErr()

if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOpts

type CreateOpts struct {
	Name             string         `json:"name" required:"true"`
	CIDR             string         `json:"cidr" required:"true"`
	VPC_ID           string         `json:"vpc_id" required:"true"`
	GatewayIP        string         `json:"gateway_ip" required:"true"`
	EnableIPv6       *bool          `json:"ipv6_enable,omitempty"`
	EnableDHCP       bool           `json:"dhcp_enable" no_default:"y"`
	PRIMARY_DNS      string         `json:"primary_dns,omitempty"`
	SECONDARY_DNS    string         `json:"secondary_dns,omitempty"`
	DnsList          []string       `json:"dnsList,omitempty"`
	AvailabilityZone string         `json:"availability_zone,omitempty"`
	Description      string         `json:"description,omitempty"`
	ExtraDhcpOpts    []ExtraDhcpOpt `json:"extra_dhcp_opts,omitempty"`
}

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

func (CreateOpts) ToSubnetCreateMap

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

ToSubnetCreateMap builds a create 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 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 Subnet.

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 subnets. When it is created, the subnets does not have an internal interface - it is not associated to any subnet.

func (CreateResult) Extract

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

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

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, vpcid string, id string) (r DeleteResult)

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

type ExtraDhcp

type ExtraDhcp struct {
	OptName  string `json:"opt_name"`
	OptValue string `json:"opt_value"`
}

type ExtraDhcpOpt

type ExtraDhcpOpt struct {
	OptName  string  `json:"opt_name" required:"true"`
	OptValue *string `json:"opt_value"`
}

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 *golangsdk.ServiceClient, id string) (r GetResult)

Get retrieves a particular subnets 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.

type ListOpts

type ListOpts struct {
	// ID is the unique identifier for the subnet.
	ID string `json:"id"`

	// Name is the human readable name for the subnet. It does not have to be
	// unique.
	Name string `json:"name"`

	//Specifies the network segment on which the subnet resides.
	CIDR string `json:"cidr"`

	// Status indicates whether or not a subnet is currently operational.
	Status string `json:"status"`

	//Specifies the gateway of the subnet.
	GatewayIP string `json:"gateway_ip"`

	//Specifies the IP address of DNS server 1 on the subnet.
	PRIMARY_DNS string `json:"primary_dns"`

	//Specifies the IP address of DNS server 2 on the subnet.
	SECONDARY_DNS string `json:"secondary_dns"`

	//Identifies the availability zone (AZ) to which the subnet belongs.
	AvailabilityZone string `json:"availability_zone"`

	//Specifies the ID of the VPC to which the subnet belongs.
	VPC_ID string `q:"vpc_id"`

	//Specifies tags subnets must match (returning those matching all tags).
	Tags string `q:"tags"`

	//Specifies tags subnets must match (returning those matching at least one of the tags).
	TagsAny string `q:"tags-any"`

	//Specifies tags subnets mustn't match (returning those missing all tags).
	NotTags string `q:"not-tags"`

	//Specifies tags subnets mustn't match (returning those missing at least one of the tags).
	NotTagsAny string `q:"not-tags-any"`
}

func (ListOpts) ToSubnetListQuery

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

ToSubnetListQuery formats a ListOpts into a query string

type Subnet

type Subnet struct {
	// ID is the unique identifier for the subnet.
	ID string `json:"id"`

	// Name is the human readable name for the subnet. It does not have to be unique.
	Name string `json:"name"`

	// Description is supplementary information about the subnet.
	// The value is a string of no more than 255 characters and cannot contain angle brackets (< or >).
	Description string `json:"description"`

	// Specifies the network segment on which the subnet resides.
	CIDR string `json:"cidr"`

	// Specifies the IP address list of DNS servers on the subnet.
	DnsList []string `json:"dnsList"`

	// Status indicates whether or not a subnet is currently operational.
	Status string `json:"status"`

	//Specifies the gateway of the subnet.
	GatewayIP string `json:"gateway_ip"`

	//Specifies whether the IPv6 function is enabled for the subnet.
	EnableIPv6 bool `json:"ipv6_enable"`

	//Specifies the IPv6 subnet CIDR block.
	IPv6CIDR string `json:"cidr_v6"`

	//Specifies the IPv6 subnet gateway.
	IPv6Gateway string `json:"gateway_ip_v6"`

	//Specifies whether the DHCP function is enabled for the subnet.
	EnableDHCP bool `json:"dhcp_enable"`

	//Specifies the IP address of DNS server 1 on the subnet.
	PRIMARY_DNS string `json:"primary_dns"`

	//Specifies the IP address of DNS server 2 on the subnet.
	SECONDARY_DNS string `json:"secondary_dns"`

	//Identifies the availability zone (AZ) to which the subnet belongs.
	AvailabilityZone string `json:"availability_zone"`

	//Specifies the ID of the VPC to which the subnet belongs.
	VPC_ID string `json:"vpc_id"`

	//Specifies the subnet ID.
	SubnetId string `json:"neutron_subnet_id"`

	//Specifies the subnet ID of the IPv6 subnet.
	IPv6SubnetId string `json:"neutron_subnet_id_v6"`

	//Specifies the extra dhcp opts.
	ExtraDhcpOpts []ExtraDhcp `json:"extra_dhcp_opts"`
}

func ExtractSubnets

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

ExtractSubnets 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 FilterSubnets

func FilterSubnets(subnets []Subnet, opts ListOpts) ([]Subnet, error)

func List

func List(c *golangsdk.ServiceClient, opts ListOpts) ([]Subnet, error)

List returns collection of subnets. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Default policy settings return only those subnets that are owned by the tenant who submits the request, unless an admin user submits the request.

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 UpdateOpts

type UpdateOpts struct {
	Name          string         `json:"name,omitempty"`
	Description   *string        `json:"description,omitempty"`
	EnableIPv6    *bool          `json:"ipv6_enable,omitempty"`
	EnableDHCP    bool           `json:"dhcp_enable"`
	PRIMARY_DNS   string         `json:"primary_dns,omitempty"`
	SECONDARY_DNS string         `json:"secondary_dns,omitempty"`
	DnsList       *[]string      `json:"dnsList,omitempty"`
	ExtraDhcpOpts []ExtraDhcpOpt `json:"extra_dhcp_opts,omitempty"`
}

UpdateOpts contains the values used when updating a subnets.

func (UpdateOpts) ToSubnetUpdateMap

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

ToSubnetUpdateMap builds an update body based on UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	//ToSubnetUpdateMap() (map[string]interface{}, error)
	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 *golangsdk.ServiceClient, vpcid string, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update allows subnets to be updated. You can update the name, administrative state, and the external gateway.

func (UpdateResult) Extract

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

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

Jump to

Keyboard shortcuts

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