File: requests.go

package info (click to toggle)
golang-github-gophercloud-utils 0.0~git20231010.80377ec-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: sh: 20; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package status

import (
	"github.com/gophercloud/gophercloud"
)

// GetOptsBuilder allows to add additional parameters to the Get request.
type GetOptsBuilder interface {
	ToStatusGetQuery() (string, error)
}

// GetOpts allows to provide additional options to the Gnocchi status Get request.
type GetOpts struct {
	// Details allows to get status with all attributes.
	Details *bool `q:"details"`
}

// ToStatusGetQuery formats a GetOpts into a query string.
func (opts GetOpts) ToStatusGetQuery() (string, error) {
	q, err := gophercloud.BuildQueryString(opts)
	return q.String(), err
}

// Get retrieves the overall status of the Gnocchi installation.
func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) (r GetResult) {
	url := getURL(c)
	if opts != nil {
		query, err := opts.ToStatusGetQuery()
		if err != nil {
			r.Err = err
			return
		}
		url += query
	}
	_, r.Err = c.Get(url, &r.Body, nil)
	return
}