Documentation ¶
Overview ¶
Package networks contains functionality for working with Neutron network resources. A network is an isolated virtual layer-2 broadcast domain that is typically reserved for the tenant who created it (unless you configure the network to be shared). Tenants can create multiple networks until the thresholds per-tenant quota is reached.
In the v2.0 Networking API, the network is the main entity. Ports and subnets are always associated with a network.
Example to List Networks
listOpts := networks.ListOpts{ TenantID: "a99e9b4e620e4db09a2dfb6e42a01e66", } allPages, err := networks.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allNetworks, err := networks.ExtractNetworks(allPages) if err != nil { panic(err) } for _, network := range allNetworks { fmt.Printf("%+v", network) }
Example to Create a Network
iTrue := true createOpts := networks.CreateOpts{ Name: "network_1", AdminStateUp: &iTrue, } network, err := networks.Create(networkClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Network
networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" updateOpts := networks.UpdateOpts{ Name: "new_name", } network, err := networks.Update(networkClient, networkID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Network
networkID := "484cda0e-106f-4f4b-bb3f-d413710bbe78" err := networks.Delete(networkClient, networkID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func ExtractVpcsInto(r pagination.Page, v interface{}) error
- func IDFromName(client *gophercloud.ServiceClient, name string) (string, error)
- func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Router
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type Vpc
- type VpcPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractVpcsInto ¶
func ExtractVpcsInto(r pagination.Page, v interface{}) error
func IDFromName ¶
func IDFromName(client *gophercloud.ServiceClient, name string) (string, error)
IDFromName is a convenience function that returns a vpc's ID, given its name.
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List returns a Pager which allows you to iterate over a collection of vpcs. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.
Types ¶
type CreateOpts ¶
type CreateOpts struct { Vpc string `json:"vpc,omitempty"` Name string `json:"name,omitempty"` TenantID string `json:"tenant_id,omitempty"` Description string `json:"description,omitempty"` Cidr string `json:"cidr,omitempty"` IsDefault *bool `json:"is_default,omitempty"` }
CreateOpts represents options used to create a vpc.
func (CreateOpts) ToVpcCreateMap ¶
func (opts CreateOpts) ToVpcCreateMap() (map[string]interface{}, error)
ToVpcCreateMap builds a 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 *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and creates a new vpc using the values provided. This operation does not actually require a request body, i.e. the CreateOpts struct argument can be empty.
The tenant ID that is contained in the URI is the tenant that creates the vpc. An admin user, however, has the option of specifying another tenant ID in the CreateOpts struct.
func (CreateResult) Extract ¶
Extract is a function that accepts a result and extracts a vpc resource.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
type DeleteResult ¶
type DeleteResult struct {
gophercloud.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 *gophercloud.ServiceClient, vpcID string) (r DeleteResult)
Delete accepts a unique ID and deletes the vpc associated with it.
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 *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific vpc based on its unique ID.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
type ListOpts ¶
type ListOpts struct { Status string `q:"status"` Name string `q:"name"` TenantID string `q:"tenant_id"` ID string `q:"id"` SortKey string `q:"sort_key"` SortDir string `q:"sort_dir"` Cidr string `q:"cidr"` Description string `q:"description"` IsDefault *bool `q:"is_default"` Fields []string `q:"fields"` }
ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the vpc attributes you want to see returned. SortKey allows you to sort by a particular vpc attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToNetworkListQuery ¶
ToVpcListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type UpdateOpts ¶
type UpdateOpts struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Cidr string `json:"cidr,omitempty"` }
UpdateOpts represents options used to update a vpc.
func (UpdateOpts) ToVpcUpdateMap ¶
func (opts UpdateOpts) ToVpcUpdateMap() (map[string]interface{}, error)
ToVpcUpdateMap builds a request body from 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 *gophercloud.ServiceClient, vpcID string, opts UpdateOptsBuilder) (r UpdateResult)
Update accepts a UpdateOpts struct and updates an existing vpc using the values provided. For more information, see the Create function.
func (UpdateResult) Extract ¶
Extract is a function that accepts a result and extracts a vpc resource.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(v interface{}) error
type Vpc ¶
type Vpc struct { // UUID for the vpc ID string `json:"id"` // Human-readable name for the vpc. Might not be unique. Name string `json:"name"` // Indicates whether vpc is currently operational. Possible values include // `ACTIVE', `DOWN', `BUILD', or `ERROR'. Plug-ins might define additional // values. Status string `json:"status"` // network_ids associated with this vpc. NetworkIds []string `json:"network_ids"` // routers associated with this vpc. Routers []Router `json:"routers"` // TenantID is the project owner of the vpc. TenantID string `json:"tenant_id"` // description for the vpc Description string `json:"description"` // createTime for the vpc CreatedAt string `json:"created_at"` // updateTime for the vpc UpdatedAt string `json:"updated_at"` // is_default for the vpc IsDefault bool `json:"is_default"` // cidr for the vpc Cidr string `json:"cidr"` }
vpc represents, well, a vpc.
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.
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.