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"` DnsList []string `json:"dnsList,omitempty"` GatewayIP string `json:"gateway_ip" required:"true"` EnableDHCP bool `json:"dhcp_enable" no_default:"y"` PRIMARY_DNS string `json:"primary_dns,omitempty"` SECONDARY_DNS string `json:"secondary_dns,omitempty"` AvailabilityZone string `json:"availability_zone,omitempty"` VPC_ID string `json:"vpc_id" required:"true"` 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 ¶
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.
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 ExtraDhcpOpt ¶
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.
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 `json:"vpc_id"` }
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"` //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 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 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.
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"` 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.