vpcs

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Overview

Package vpcs enables management and retrieval of Vpcs VPC service.

Example to List Vpcs

listOpts := vpcs.ListOpts{}
allVpcs, err := vpcs.List(vpcClient, listOpts)
if err != nil {
	panic(err)
}

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

Example to Create a Vpc

createOpts := vpcs.CreateOpts{
	Name:         "vpc_1",
	CIDR:         "192.168.0.0/24"

}

vpc, err := vpcs.Create(vpcClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Update a Vpc

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

updateOpts := vpcs.UpdateOpts{
	Name:         "vpc_2",
	CIDR:         "192.168.0.0/23"
}

vpc, err := vpcs.Update(vpcClient, vpcID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Vpc

vpcID := "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
err := vpcs.Delete(vpcClient, vpcID).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,omitempty"`
	Description string `json:"description,omitempty"`
	CIDR        string `json:"cidr,omitempty"`
}

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

func (CreateOpts) ToVpcCreateMap

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

ToVpcCreateMap builds a create request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToVpcCreateMap() (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 Vpc.

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

You can optionally specify an external gateway for a vpc using the GatewayInfo struct. The external gateway for the vpc must be plugged into an external network (it is external if its `vpc:external' field is set to true).

func (CreateResult) Extract

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

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

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 vpc 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 Vpc.

func Get

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

Get retrieves a particular vpc based on its unique ID.

func (GetResult) Extract

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

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

type ListOpts

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

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

	// Specifies the range of available subnets in the VPC.
	CIDR string `json:"cidr"`

	// Status indicates whether a vpc is currently operational.
	Status string `json:"status"`
}

type Route

type Route struct {
	NextHop         string `json:"nexthop"`
	DestinationCIDR string `json:"destination"`
}

Route is a possible route in a vpc.

type UpdateOpts

type UpdateOpts struct {
	Name             string  `json:"name,omitempty"`
	Description      *string `json:"description,omitempty"`
	CIDR             string  `json:"cidr,omitempty"`
	EnableSharedSnat *bool   `json:"enable_shared_snat,omitempty"`
}

UpdateOpts contains the values used when updating a vpc.

func (UpdateOpts) ToVpcUpdateMap

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

ToVpcUpdateMap builds an update body based on UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToVpcUpdateMap() (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 Vpc.

func Update

func Update(c *golangsdk.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update allows vpcs to be updated. You can update the name, administrative state, and the external gateway. For more information about how to set the external gateway for a vpc, see Create. This operation does not enable the update of vpc interfaces. To do this, use the AddInterface and RemoveInterface functions.

func (UpdateResult) Extract

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

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

type Vpc

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

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

	// Specifies the range of available subnets in the VPC.
	CIDR string `json:"cidr"`

	// Provides supplementary information about the VPC.
	Description string `json:"description"`

	// Status indicates whether a vpc is currently operational.
	Status string `json:"status"`

	// Routes are a collection of static routes that the vpc will host.
	Routes []Route `json:"routes"`

	// Provides information about shared snat
	EnableSharedSnat bool `json:"enable_shared_snat"`
}

Vpc represents a Neutron vpc. A vpc is a logical entity that forwards packets across internal subnets and NATs (network address translation) them on external networks through an appropriate gateway.

A vpc has an interface for each subnet with which it is associated. By default, the IP address of such interface is the subnet's gateway IP. Also, whenever a vpc is associated with a subnet, a port for that vpc interface is added to the subnet's network.

func ExtractVpcs

func ExtractVpcs(r pagination.Page) ([]Vpc, error)

ExtractVpcs accepts a Page struct, specifically a VpcPage struct, and extracts the elements into a slice of Vpc structs. In other words, a generic collection is mapped into a relevant slice.

func FilterVPCs

func FilterVPCs(vpcs []Vpc, opts ListOpts) ([]Vpc, error)

func List

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

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

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

type VpcPage

type VpcPage struct {
	pagination.LinkedPageBase
}

VpcPage is the page returned by a pager when traversing over a collection of vpcs.

func (VpcPage) IsEmpty

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

IsEmpty checks whether a VpcPage struct is empty.

func (VpcPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of vpcs 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
vpcs unit tests
vpcs unit tests

Jump to

Keyboard shortcuts

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