go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/subnets Index | Files | Directories

package subnets

import "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/subnets"

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, resellClient, subnetID)
if err != nil {
  log.Fatal(err)
}
fmt.Println(subnet)

Example of getting all subnets

allSubnets, _, err := subnets.List(ctx, resellClient, 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(ctx, resellClient, 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(ctx, resellClient, subnetID)
if err != nil {
  log.Fatal(err)
}

Index

Package Files

doc.go requests.go requests_opts.go schemas.go

func Delete Uses

func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)

Delete deletes a single subnet by its id.

type ListOpts Uses

type ListOpts struct {
    Detailed bool `param:"detailed"`
}

ListOpts represents options for the licenses List request.

type Subnet Uses

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 Uses

func Create(ctx context.Context, client *selvpcclient.ServiceClient, projectID string, createOpts SubnetOpts) ([]*Subnet, *selvpcclient.ResponseResult, error)

Create requests a creation of the subnets in the specified project.

func Get Uses

func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*Subnet, *selvpcclient.ResponseResult, error)

Get returns a single subnet by its id.

func List Uses

func List(ctx context.Context, client *selvpcclient.ServiceClient, opts ListOpts) ([]*Subnet, *selvpcclient.ResponseResult, error)

List gets a list of subnets in the current domain.

type SubnetOpt Uses

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 Uses

type SubnetOpts struct {
    // Subnets represents options for all subnets.
    Subnets []SubnetOpt `json:"subnets"`
}

SubnetOpts represents options for the subnets Create request.

Directories

PathSynopsis
testing

Package subnets imports 7 packages (graph) and is imported by 3 packages. Updated 2019-02-05. Refresh now. Tools for package owners.