// ToObjectGetQuery formats a GetOpts into a query string. func (opts GetOpts) ToObjectGetQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToResourceEventListQuery formats a ListResourceEventsOpts into a query string. func (opts ListResourceEventsOpts) ToResourceEventListQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToMeterStatisticsQuery formats a StatisticsOpts into a query string. func (opts MeterStatisticsOpts) ToMeterStatisticsQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToPortListQuery formats a ListOpts into a query string. func (opts ListOpts) ToPortListQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToContainerListParams formats a ListOpts into a query string and boolean // representing whether to list complete information for each container. func (opts ListOpts) ToContainerListParams() (bool, string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return false, "", err } return false, q.String(), nil }
// ToRolesListAssignmentsQuery formats a ListAssignmentsOpts into a query string. func (opts ListAssignmentsOpts) ToRolesListAssignmentsQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToMeterShowQuery formats a ShowOpts into a query string. func (opts ShowOpts) ToShowQuery() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// ToObjectListParams formats a ListOpts into a query string and boolean // representing whether to list complete information for each object. func (opts ListOpts) ToObjectListParams() (bool, string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return false, "", err } return opts.Full, q.String(), nil }
// ToCDNAssetDeleteParams formats a DeleteOpts into a query string. func (opts DeleteOpts) ToCDNAssetDeleteParams() (string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return "", err } return q.String(), nil }
// GetDataByPoints retrieve metric data by resolution, for the specified tenant associated with RackspaceMetrics. func GetDataByResolution(c *gophercloud.ServiceClient, metric string, opts QueryParams) GetResult { var res GetResult url := getURLForResolution(c, metric) query, _ := gophercloud.BuildQueryString(opts) url += query.String() _, res.Err = c.Get(url, &res.Body, nil) return res }
// List returns a Pager which allows you to iterate over a collection of // routers. It accepts a ListOpts struct, which allows you to filter and sort // the returned collection for greater efficiency. // // Default policy settings return only those routers that are owned by the // tenant who submits the request, unless an admin user submits the request. func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { q, err := gophercloud.BuildQueryString(&opts) if err != nil { return pagination.Pager{Err: err} } u := rootURL(c) + q.String() return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page { return RouterPage{pagination.LinkedPageBase{PageResult: r}} }) }
// ToObjectDownloadParams formats a DownloadOpts into a query string and map of // headers. func (opts DownloadOpts) ToObjectDownloadParams() (map[string]string, string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return nil, "", err } h, err := gophercloud.BuildHeaders(opts) if err != nil { return nil, q.String(), err } return h, q.String(), nil }
// List enumerates the services available to a specific user. func List(client *gophercloud.ServiceClient, opts ListOpts) pagination.Pager { u := listURL(client) q, err := gophercloud.BuildQueryString(opts) if err != nil { return pagination.Pager{Err: err} } u += q.String() createPage := func(r pagination.PageResult) pagination.Page { return ServicePage{pagination.LinkedPageBase{PageResult: r}} } return pagination.NewPager(client, u, createPage) }
// SearchMetric retrieves a list of available metrics for the specified tenant associated with RackspaceMetrics. func SearchMetric(c *gophercloud.ServiceClient, opts QueryParams) ([]Metric, error) { var res GetResult url := getSearchURL(c) query, _ := gophercloud.BuildQueryString(opts) url += query.String() _, res.Err = c.Get(url, &res.Body, nil) b := res.Body.(interface{}) var metrics []Metric err := mapstructure.Decode(b, &metrics) return metrics, err }
//GetEvents retrieves a list of events for the specified tenant associated with RackspaceMetrics. func GetEvents(c *gophercloud.ServiceClient, opts QueryParams) ([]Event, error) { var res GetResult url := getEventURL(c) query, _ := gophercloud.BuildQueryString(opts) url += query.String() _, res.Err = c.Get(url, &res.Body, nil) b := res.Body.(interface{}) var events []Event err := mapstructure.Decode(b, &events) return events, err }
// ToObjectCreateParams formats a CreateOpts into a query string and map of // headers. func (opts CreateOpts) ToObjectCreateParams() (map[string]string, string, error) { q, err := gophercloud.BuildQueryString(opts) if err != nil { return nil, "", err } h, err := gophercloud.BuildHeaders(opts) if err != nil { return nil, q.String(), err } for k, v := range opts.Metadata { h["X-Object-Meta-"+k] = v } return h, q.String(), nil }
// List enumerates the Tenants to which the current token has access. func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager { createPage := func(r pagination.PageResult) pagination.Page { return TenantPage{pagination.LinkedPageBase{PageResult: r}} } url := listURL(client) if opts != nil { q, err := gophercloud.BuildQueryString(opts) if err != nil { return pagination.Pager{Err: err} } url += q.String() } return pagination.NewPager(client, url, createPage) }
// GetDataForListByResolution retrieve data against a list of metrics and specified resolution, for the specified tenant associated with RackspaceMetrics. func GetDataForListByResolution(c *gophercloud.ServiceClient, opts QueryParams, metrics ...string) (MetricListData, error) { var res GetResult reqBody := make([]interface{}, len(metrics)) for i, v := range metrics { reqBody[i] = v } url := getURLForListAndResolution(c) query, _ := gophercloud.BuildQueryString(opts) url += query.String() _, res.Err = c.Post(url, reqBody, &res.Body, &gophercloud.RequestOpts{ OkCodes: []int{200}, }) b := res.Body.(interface{}) var metricList MetricListData err := mapstructure.Decode(b, &metricList) return metricList, err }