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 ¶
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 ¶
func (*History) UnmarshalJSON ¶
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 ¶
ToResourceListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
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 UsagePage ¶
type UsagePage struct {
pagination.LinkedPageBase
}
UsagePage is a single page of Usage results.