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

package licenses

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

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 {

Example of getting all licenses

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

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


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 license by its id.

type License Uses

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 Uses

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 Uses

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

Get returns a single license by its id.

func List Uses

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

List gets a list of licenses in the current domain.

type LicenseOpt Uses

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 Uses

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

LicenseOpts represents options for the licenses Create request.

type ListOpts Uses

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

ListOpts represents options for the licenses List request.



Package licenses imports 7 packages (graph) and is imported by 1 packages. Updated 2020-03-31. Refresh now. Tools for package owners.