Documentation ¶
Overview ¶
Package archivepolicies provides the ability to retrieve archive policies through the Gnocchi API.
Example of Listing archive policies
allPages, err := archivepolicies.List(gnocchiClient).AllPages() if err != nil { panic(err) } allArchivePolicies, err := archivepolicies.ExtractArchivePolicies(allPages) if err != nil { panic(err) } for _, archivePolicy := range allArchivePolicies { fmt.Printf("%+v\n", archivePolicy) }
Example of Getting an archive policy
archivePolicyName = "my_policy" archivePolicy, err := archivepolicies.Get(gnocchiClient, archivePolicyName).Extract() if err != nil { panic(err) }
Example of Creating an archive policy
createOpts := archivepolicies.CreateOpts{ BackWindow: 31, AggregationMethods: []string{ "sum", "mean", "count", }, Definition: []archivepolicies.ArchivePolicyDefinitionOpts{ { Granularity: "1:00:00", TimeSpan: "90 days, 0:00:00", }, { Granularity: "1 day, 0:00:00", TimeSpan: "100 days, 0:00:00", }, }, Name: "test_policy", } archivePolicy, err := archivepolicies.Create(gnocchiClient, createOpts).Extract() if err != nil { panic(err) }
Example of Updating an archive policy
updateOpts := archivepolicies.UpdateOpts{ Definition: []archivepolicies.ArchivePolicyDefinitionOpts{ { Granularity: "12:00:00", TimeSpan: "30 days, 0:00:00", }, { Granularity: "1 day, 0:00:00", TimeSpan: "90 days, 0:00:00", }, }, } archivePolicy, err := archivepolicies.Update(gnocchiClient, "test_policy", updateOpts).Extract() if err != nil { panic(err) }
Example of Deleting a Gnocchi archive policy
err := archivepolicies.Delete(gnocchiClient, "test_policy").ExtractErr() if err != nil { panic(err) }
Index ¶
- func List(client *gophercloud.ServiceClient) pagination.Pager
- type ArchivePolicy
- type ArchivePolicyDefinition
- type ArchivePolicyDefinitionOpts
- type ArchivePolicyPage
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient) pagination.Pager
List makes a request against the Gnocchi API to list archive policies.
Types ¶
type ArchivePolicy ¶
type ArchivePolicy struct { // AggregationMethods is a list of functions used to aggregate // multiple measures into an aggregate. AggregationMethods []string `json:"aggregation_methods"` // BackWindow configures number of coarsest periods to keep. // It allows to process measures that are older // than the last timestamp period boundary. BackWindow int `json:"back_window"` // Definition is a list of parameters that configures // archive policy precision and timespan. Definition []ArchivePolicyDefinition `json:"definition"` // Name is a name of an archive policy. Name string `json:"name"` }
ArchivePolicy represents a Gnocchi archive policy. Archive policy is an aggregate storage policy attached to a metric. It determines how long aggregates will be kept in a metric and how they will be aggregated.
func ExtractArchivePolicies ¶
func ExtractArchivePolicies(r pagination.Page) ([]ArchivePolicy, error)
ExtractArchivePolicies interprets the results of a single page from a List() call, producing a slice of ArchivePolicy structs.
type ArchivePolicyDefinition ¶
type ArchivePolicyDefinition struct { // Granularity is the level of precision that must be kept when aggregating data. Granularity string `json:"granularity"` // Points is a given aggregates or samples in the lifespan of a time series. // Time series is a list of aggregates ordered by time. Points int `json:"points"` // TimeSpan is the time period for which a metric keeps its aggregates. TimeSpan string `json:"timespan"` }
ArchivePolicyDefinition represents definition of how metrics will be saved with the selected archive policy. It configures precision and timespan.
type ArchivePolicyDefinitionOpts ¶
type ArchivePolicyDefinitionOpts struct { // Granularity is the level of precision that must be kept when aggregating data. Granularity string `json:"granularity"` // Points is a given aggregates or samples in the lifespan of a time series. // Time series is a list of aggregates ordered by time. // It can be omitted to allow Gnocchi server to calculate it automatically. Points *int `json:"points,omitempty"` // TimeSpan is the time period for which a metric keeps its aggregates. TimeSpan string `json:"timespan"` }
ArchivePolicyDefinitionOpts represents definition of how metrics of new or updated Archive Policy will be saved with the selected archive policy. It configures precision and timespan.
type ArchivePolicyPage ¶
type ArchivePolicyPage struct {
pagination.SinglePageBase
}
ArchivePolicyPage abstracts the raw results of making a List() request against the Gnocchi API.
As Gnocchi API may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractArchivePolicies call.
func (ArchivePolicyPage) IsEmpty ¶
func (r ArchivePolicyPage) IsEmpty() (bool, error)
IsEmpty returns true if an ArchivePolicyPage contains no archive policies.
type CreateOpts ¶
type CreateOpts struct { // AggregationMethods is a list of functions used to aggregate // multiple measures into an aggregate. AggregationMethods []string `json:"aggregation_methods,omitempty"` // BackWindow configures number of coarsest periods to keep. // It allows to process measures that are older // than the last timestamp period boundary. BackWindow int `json:"back_window,omitempty"` // Definition is a list of parameters that configures // archive policy precision and timespan. Definition []ArchivePolicyDefinitionOpts `json:"definition"` // Name is a name of an archive policy. Name string `json:"name"` }
CreateOpts specifies parameters of a new Archive Policy.
func (CreateOpts) ToArchivePolicyCreateMap ¶
func (opts CreateOpts) ToArchivePolicyCreateMap() (map[string]interface{}, error)
ToArchivePolicyCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Gnocchi archive policy.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new Gnocchi archive policy on the server.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() (*ArchivePolicy, error)
Extract is a function that accepts a result and extracts a Gnocchi archive policy.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(c *gophercloud.ServiceClient, archivePolicyName string) (r DeleteResult)
Delete accepts a Gnocchi archive policy by its name.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation. Call its Extract method to interpret it as an ArchivePolicy.
func Get ¶
func Get(c *gophercloud.ServiceClient, archivePolicyName string) (r GetResult)
Get retrieves a specific Gnocchi archive policy based on its name.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*ArchivePolicy, error)
Extract is a function that accepts a result and extracts a Gnocchi archive policy.
type UpdateOpts ¶
type UpdateOpts struct { // Definition is a list of parameters that configures // archive policy precision and timespan. Definition []ArchivePolicyDefinitionOpts `json:"definition"` }
UpdateOpts represents options used to update an archive policy.
func (UpdateOpts) ToArchivePolicyUpdateMap ¶
func (opts UpdateOpts) ToArchivePolicyUpdateMap() (map[string]interface{}, error)
ToArchivePolicyUpdateMap constructs a request body from UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Gnocchi archive policy.
func Update ¶
func Update(client *gophercloud.ServiceClient, archivePolicyName string, opts UpdateOptsBuilder) (r UpdateResult)
Update accepts a UpdateOpts and updates an existing Gnocchi archive policy using the values provided.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*ArchivePolicy, error)
Extract is a function that accepts a result and extracts a Gnocchi archive policy.