Back to godoc.org

Package floatingips

v1.12.0
Latest Go to latest

The latest major version is .

Published: Aug 12, 2020 | License: Apache-2.0 | Module: github.com/selectel/go-selvpcclient

Overview

Package floatingips provides the ability to retrieve and manage floating ips through the Resell v2 API.

Example of getting a single floating ip referenced by its id

floatingIP, _, err := floatingips.Get(context, resellClient, fipID)
if err != nil {
  log.Fatal(err)
}
fmt.Println(floatingIP)

Example of getting all floating ips

allFloatingIPs, _, err := floatingips.List(ctx, resellClient, floatingips.ListOpts{})
if err != nil {
  log.Fatal(err)
}
for _, floatingIP := range floatingips {
  fmt.Println(floatingIP)
}

Example of creating floating ips in a project

newFloatingIPsOpts := floatingips.FloatingIPOpts{
  FloatingIPs: []floatingips.FloatingIPOpt{
    {
      Region:   "ru-2",
      Quantity: 2,
    },
  },
}
projectID := "49338ac045f448e294b25d013f890317"
newFloatingIPs, _, err := floatingips.Create(ctx, resellClient, projectID, newFloatingIPsOpts)
if err != nil {
  log.Fatal(err)
}
for _, newFloatingIP := range newFloatingIPs {
  fmt.Println(newFloatingIPs)
}

Example of deleting a single floating ip

_, err = floatingips.Delete(ctx, resellClient, "412a04ba-4cb2-4823-abd1-fcd48952b882")
if err != nil {
  log.Fatal(err)
}

Index

func Delete

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

Delete deletes a single floating ip by its id.

type FloatingIP

type FloatingIP struct {
	// FloatingIPAddress represents IP address.
	FloatingIPAddress string `json:"floating_ip_address"`

	// ID is a unique id of the floating ip.
	ID string `json:"id"`

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

	// PortID contains a Networking service uuid of the port to which floating ip is associated to.
	PortID string `json:"port_id"`

	// FixedIPAddress contains an IP address of the port to which floating ip is
	// associated to.
	FixedIPAddress string `json:"fixed_ip_address"`

	// Region represents an Identity service region of where the floating ip resides.
	Region string `json:"region"`

	// Status represents a current status of the floating ip.
	Status string `json:"status"`

	// Servers contains info about servers to which floating ip is associated to.
	Servers []servers.Server `json:"servers"`
}

FloatingIP represents a single Resell Floating IP.

func Create

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

Create requests a creation of the floating ip in the specified project.

func Get

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

Get returns a single floating ip by its id.

func List

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

List gets a list of floating ips in the current domain.

type FloatingIPOpt

type FloatingIPOpt struct {
	// Region represents an Identity service region of where the floating ips should reside.
	Region string `json:"region"`

	// Quantity represents how many floating ips do we need to create in a single request.
	Quantity int `json:"quantity"`
}

FloatingIPOpt represents options for the single floating ip.

type FloatingIPOpts

type FloatingIPOpts struct {
	// FloatingIPs represents options for all floating ips.
	FloatingIPs []FloatingIPOpt `json:"floatingips"`
}

FloatingIPOpts represents options for the floating ips Create request.

type ListOpts

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

ListOpts represents options for the floating ips List request.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier