subnets

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 7 Imported by: 3

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, 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

Delete deletes a single subnet by its id.

Types

type ListOpts added in v1.1.0

type ListOpts struct {
	Detailed bool `param:"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(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

Get returns a single subnet by its id.

func List

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL