Documentation ¶
Overview ¶
Package subnets provides the ability to retrieve and manage subnets through the Resell v2 API.
Example of getting a single subnet referenced by its id
subnet, _, err := subnets.Get(context, client, subnetID) if err != nil { log.Fatal(err) } fmt.Println(subnet)
Example of getting all subnets
allSubnets, _, err := subnets.List(client, subnets.ListOpts{}) if err != nil { log.Fatal(err) } for _, subnet := range allSubnet { fmt.Println(subnet) }
Example of creating subnets
createOpts := subnets.SubnetOpts{ Subnets: []subnets.SubnetOpt{ { Region: "ru-3", Type: selvpcclient.IPv4, PrefixLength: 29, Quantity: 1, }, }, } newSubnets, _, err := subnets.Create(client, projectID, createOpts) if err != nil { log.Fatal(err) } for _, newSubnet := range newSubnets { fmt.Printf("%v\n", newSubnet) }
Example of deleting a single subnet
_, err = subnets.Delete(client, subnetID) if err != nil { log.Fatal(err) }
Index ¶
- func Delete(client *selvpcclient.Client, id string) (*clientservices.ResponseResult, error)
- type ListOpts
- type Subnet
- func Create(client *selvpcclient.Client, projectID string, createOpts SubnetOpts) ([]*Subnet, *clientservices.ResponseResult, error)
- func Get(client *selvpcclient.Client, id string) (*Subnet, *clientservices.ResponseResult, error)
- func List(client *selvpcclient.Client, opts ListOpts) ([]*Subnet, *clientservices.ResponseResult, error)
- type SubnetOpt
- type SubnetOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(client *selvpcclient.Client, id string) (*clientservices.ResponseResult, error)
Delete deletes a single subnet by its id.
Types ¶
type ListOpts ¶
type ListOpts struct {
Detailed bool `url:"detailed"`
}
ListOpts represents options for the licenses List request.
type Subnet ¶
type Subnet struct { // ID is a unique id of a subnet. ID int `json:"id"` // Status shows if subnet is used. Status string `json:"status"` // Servers contains info about servers to which subnet is associated to. Servers []servers.Server `json:"servers"` // Region represents a region of where the subnet resides. Region string `json:"region"` // CIDR is a subnet prefix in CIDR notation. CIDR string `json:"cidr"` // NetworkID represents id of the associated network in the Networking service. NetworkID string `json:"network_id"` // SubnetID represents id of the associated subnet in the Networking service. SubnetID string `json:"subnet_id"` // ProjectID represents an associated Identity service project. ProjectID string `json:"project_id"` // VLANID represents id of the associated VLAN in the Networking service. VLANID int `json:"vlan_id"` // VTEPIPAddress represents an ip address of the associated VTEP in the Networking service. VTEPIPAddress string `json:"vtep_ip_address"` }
Subnet represents a single Resell subnet.
func Create ¶
func Create(client *selvpcclient.Client, projectID string, createOpts SubnetOpts) ([]*Subnet, *clientservices.ResponseResult, error)
Create requests a creation of the subnets in the specified project.
func Get ¶
func Get(client *selvpcclient.Client, id string) (*Subnet, *clientservices.ResponseResult, error)
Get returns a single subnet by its id.
func List ¶
func List(client *selvpcclient.Client, opts ListOpts) ([]*Subnet, *clientservices.ResponseResult, error)
List gets a list of subnets in the current domain.
type SubnetOpt ¶
type SubnetOpt struct { // Region represents a region of where the subnet should reside. Region string `json:"region"` // Quantity represents how many subnets do we need to create. Quantity int `json:"quantity"` // Type represents ip version type. Type selvpcclient.IPVersion `json:"type"` // PrefixLength represents length of the subnet prefix. PrefixLength int `json:"prefix_length"` }
SubnetOpt represents options for the single subnet.
type SubnetOpts ¶
type SubnetOpts struct { // Subnets represents options for all subnets. Subnets []SubnetOpt `json:"subnets"` }
SubnetOpts represents options for the subnets Create request.