usages

package
v4.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package usages manages and retrieves usage in the Enterprise Cloud Dedicated Hypervisor Service.

Example to List Usages

listOpts := usages.ListOpts{
	From:        "2019-10-10T00:00:00Z",
	To:          "2019-10-15T00:00:00Z",
	LicenseType: "dedicated-hypervisor.guest-image.vcenter-server-6-0-standard",
}

allPages, err := usages.List(dhClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allUsages, err := usages.ExtractUsages(allPages)
if err != nil {
	panic(err)
}

for _, usage := range allUsages {
	fmt.Printf("%+v\n", usage)
}

Example to Get Usage Histories

getHistoriesOpts := usages.GetHistoriesOpts{
	From: "2019-10-10T00:00:00Z",
	To:   "2019-10-15T00:00:00Z",
}

usageID := "9ada4c06-a2a4-46d5-b969-72ac12433a79"
histories, err := usages.GetHistories(client, usageID, getHistoriesOpts).ExtractHistories()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List retrieves a list of Usages.

Types

type GetHistoriesOpts

type GetHistoriesOpts struct {
	From string `q:"from"`
	To   string `q:"to"`
}

GetHistoriesOpts provides options to filter the GetHistories results.

func (GetHistoriesOpts) ToResourceListQuery

func (opts GetHistoriesOpts) ToResourceListQuery() (string, error)

ToResourceListQuery formats a GetHistoriesOpts into a query string.

type GetHistoriesResult

type GetHistoriesResult struct {
	// contains filtered or unexported fields
}

GetHistoriesResult is the response from a Get operation. Call its Extract method to interpret it as usage histories.

func GetHistories

func GetHistories(client *eclcloud.ServiceClient, usageID string, opts ListOptsBuilder) (r GetHistoriesResult)

GetHistories retrieves details of usage histories.

func (GetHistoriesResult) ExtractHistories

func (r GetHistoriesResult) ExtractHistories() (*UsageHistories, error)

ExtractHistories interprets any commonResult as usage histories.

type History

type History struct {
	Time  time.Time `json:"-"`
	Value string    `json:"value"`
}

func (*History) UnmarshalJSON

func (h *History) UnmarshalJSON(b []byte) error

type ListOpts

type ListOpts struct {
	From        string `q:"from"`
	To          string `q:"to"`
	LicenseType string `q:"license_type"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToResourceListQuery

func (opts ListOpts) ToResourceListQuery() (string, error)

ToResourceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToResourceListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request

type Usage

type Usage struct {
	ID            string `json:"id"`
	Type          string `json:"type"`
	Value         string `json:"value"`
	Unit          string `json:"unit"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	HasLicenseKey bool   `json:"has_license_key"`
	ResourceID    string `json:"resource_id"`
}

Usage represents guest image usage information.

func ExtractUsages

func ExtractUsages(r pagination.Page) ([]Usage, error)

ExtractUsages returns a slice of Usages contained in a single page of results.

type UsageHistories

type UsageHistories struct {
	Unit        string    `json:"unit"`
	ResourceID  string    `json:"resource_id"`
	LicenseType string    `json:"license_type"`
	Histories   []History `json:"histories"`
}

type UsagePage

type UsagePage struct {
	pagination.LinkedPageBase
}

UsagePage is a single page of Usage results.

func (UsagePage) IsEmpty

func (r UsagePage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of Usages contains any results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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