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 ¶
- func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
- type License
- func Create(ctx context.Context, client *selvpcclient.ServiceClient, projectID string, ...) ([]*License, *selvpcclient.ResponseResult, error)
- func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*License, *selvpcclient.ResponseResult, error)
- func List(ctx context.Context, client *selvpcclient.ServiceClient, opts ListOpts) ([]*License, *selvpcclient.ResponseResult, error)
- type LicenseOpt
- type LicenseOpts
- type ListOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
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 ¶
func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*License, *selvpcclient.ResponseResult, error)
Get returns a single license by its id.
func List ¶
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.