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

package vrrpsubnets

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

Package vrrpsubnets provides the ability to retrieve and manage VRRP subnets through the Resell v2 API.

Example of getting a single VRRP subnet referenced by its id

vrrpsubnet, _, err := vrrpsubnets.Get(context, resellClient, vrrpSubnetID)
if err != nil {
  log.Fatal(err)
}
fmt.Println(vrrpsubnet)

Example of getting all VRRP subnets

allVRRPSubnets, _, err := vrrpsubnets.List(ctx, resellClient, vrrpsubnets.ListOpts{})
if err != nil {
  log.Fatal(err)
}
for _, vrrpSubnet := range allVRRPSubnets {
  fmt.Println(vrrpSubnet)
}

Example of creating VRRP subnets

createOpts := vrrpsubnets.VRRPSubnetOpts{
  VRRPSubnets: []vrrpsubnets.VRRPSubnetOpt{
    {
      Quantity: 1,
      Regions: vrrpsubnets.VRRPRegionOpt{
        Master: "ru-2",
        Slave:  "ru-1",
      },
      Type:         "ipv4",
      PrefixLength: 29,
    },
  },
}
newVRRPSubnets, _, err := vrrpsubnets.Create(ctx, resellClient, projectID, createOpts)
if err != nil {
  log.Fatal(err)
}
for _, newVRRPSubnet := range newVRRPSubnets {
  fmt.Printf("%v\n", newVRRPSubnet)
}

Example of deleting a single VRRP subnet

_, err = vrrpsubnets.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 VRRP subnet by its id.

type ListOpts Uses

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

ListOpts represents options for the VRRP subnets List request.

type VRRPRegionOpt Uses

type VRRPRegionOpt struct {
    // Master represent region that contains a master VRRP router.
    Master string `json:"master"`

    // Slave represent region that contains a slave VRRP router.
    Slave string `json:"slave"`
}

VRRPRegionOpt represents region options for the single VRRP subnet.

type VRRPSubnet Uses

type VRRPSubnet struct {
    // ID is a unique id of a VRRP subnet.
    ID  int `json:"id"`

    // Status shows if VRRP subnet is used.
    Status string `json:"status"`

    // Servers contains info about servers to which VRRP subnet is associated to.
    Servers []servers.Server `json:"servers"`

    // MasterRegion is a reference to a region that contains a master VRRP router.
    MasterRegion string `json:"master_region"`

    // MasterRegion is a reference to a region that contains a slave VRRP router.
    SlaveRegion string `json:"slave_region"`

    // CIDR is a VRRP subnet prefix in CIDR notation.
    CIDR string `json:"cidr"`

    // Subnets contains standard subnets in every region that VRRP subnet is
    // attached to.
    Subnets []subnets.Subnet `json:"subnets"`

    // ProjectID represents an associated Identity service project.
    ProjectID string `json:"project_id"`
}

VRRPSubnet represents a single Resell VRRP subnet.

func Create Uses

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

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

func Get Uses

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

Get returns a single VRRP subnet by its id.

func List Uses

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

List gets a list of VRRP subnets in the current domain.

type VRRPSubnetOpt Uses

type VRRPSubnetOpt struct {
    // Quantity represents how many subnets do we need to create.
    Quantity int `json:"quantity"`

    // RegionOpt represents region options for the VRRP subnet.
    Regions VRRPRegionOpt `json:"regions"`

    // Type represents ip version type.
    Type selvpcclient.IPVersion `json:"type"`

    // PrefixLength represents length of the subnet prefix.
    PrefixLength int `json:"prefix_length"`
}

VRRPSubnetOpt represents options for the single VRRP subnet.

type VRRPSubnetOpts Uses

type VRRPSubnetOpts struct {
    // VRRPSubnets represents options for all VRRP subnets.
    VRRPSubnets []VRRPSubnetOpt `json:"vrrp_subnets"`
}

VRRPSubnetOpts represents options for the VRRP subnets Create request.

Directories

PathSynopsis
testing

Package vrrpsubnets imports 8 packages (graph) and is imported by 1 packages. Updated 2018-11-29. Refresh now. Tools for package owners.