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 ¶
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).
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.
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 UpdateOpts ¶
type UpdateOpts struct { Name string `json:"name,omitempty"` Description *string `json:"description,omitempty"` CIDR string `json:"cidr,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 ¶
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.
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"` 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 List ¶
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) NextPageURL ¶
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.