licenses

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: 4

Documentation

Overview

Package licenses provides the ability to retrieve and manage licenses through the Resell v2 API.

Example of getting a single license referenced by its id

license, _, err := licenses.Get(context, resellClient, licenseID)
if err != nil {
  log.Fatal(err)
}
fmt.Println(license)

Example of getting all licenses

allLicenses, _, err := licenses.List(ctx, resellClient, licenses.ListOpts{})
if err != nil {
  log.Fatal(err)
}
for _, license := range allLicenses {
  fmt.Println(license)
}

Example of creating licenses in a project

newLicensesOptions := licenses.LicenseOpts{
  Licenses: []licenses.LicenseOpt{
    {
      Region:   "ru-2",
      Quantity: 2,
      Type: "license_windows_2016_standard",
    },
  },
}
projectID := "49338ac045f448e294b25d013f890317"
newLicenses, _, err := licenses.Create(ctx, resellClient, projectID, newLicensesOptions)
if err != nil {
  log.Fatal(err)
}
for _, newLicense := range newLicenses {
  fmt.Printf("%v\n", newLicense)
}

Example of deleting a single license

_, err = licenses.Delete(ctx, resellClient, "5232d5f3-4950-454b-bd41-78c5295622cd")
if err != nil {
  log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

Delete deletes a single license by its id.

Types

type License

type License struct {
	// ID is a unique id of the license.
	ID int `json:"id"`

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

	// Region represents a region of where the license resides.
	Region string `json:"region"`

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

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

	// Type represent a license type.
	Type string `json:"type"`

	// 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"`

	// PortID represents id of the associated ports in the Networking service.
	PortID string `json:"port_id"`
}

License represents a single Resell License.

func Create

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

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

func Get

Get returns a single license by its id.

func List

List gets a list of licenses in the current domain.

type LicenseOpt

type LicenseOpt struct {
	// Region represents a region of where the licenses should reside.
	Region string `json:"region"`

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

	// Type represents needed type of the license.
	Type string `json:"type"`
}

LicenseOpt represents options for the single license.

type LicenseOpts

type LicenseOpts struct {
	// Licenses represents options for all licenses.
	Licenses []LicenseOpt `json:"licenses"`
}

LicenseOpts represents options for the licenses Create request.

type ListOpts added in v1.1.0

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

ListOpts represents options for the licenses List request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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