blob: 5f3d8ffe2ab28642abe0bff10aae9bfa39031572 [file] [log] [blame]
Joe Topjian71b85bd2017-03-09 18:55:36 -07001package zones
2
3import (
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02004 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02005 "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
Joe Topjian71b85bd2017-03-09 18:55:36 -07006)
7
8type ListOptsBuilder interface {
9 ToZoneListQuery() (string, error)
10}
11
12// ListOpts allows the filtering and sorting of paginated collections through
13// the API. Filtering is achieved by passing in struct field values that map to
14// the server attributes you want to see returned. Marker and Limit are used
15// for pagination.
16// https://developer.openstack.org/api-ref/dns/
17type ListOpts struct {
18 // Integer value for the limit of values to return.
19 Limit int `q:"limit"`
20
21 // UUID of the zone at which you want to set a marker.
22 Marker string `q:"marker"`
23
24 Description string `q:"description"`
25 Email string `q:"email"`
26 Name string `q:"name"`
27 SortDir string `q:"sort_dir"`
28 SortKey string `q:"sort_key"`
29 Status string `q:"status"`
30 TTL int `q:"ttl"`
31 Type string `q:"type"`
32}
33
34func (opts ListOpts) ToZoneListQuery() (string, error) {
35 q, err := gophercloud.BuildQueryString(opts)
36 return q.String(), err
37}
38
39func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
40 url := listURL(client)
41 if opts != nil {
42 query, err := opts.ToZoneListQuery()
43 if err != nil {
44 return pagination.Pager{Err: err}
45 }
46 url += query
47 }
48 return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
49 return ZonePage{pagination.LinkedPageBase{PageResult: r}}
50 })
51}
52
53// Get returns additional information about a zone, given its ID.
54func Get(client *gophercloud.ServiceClient, zoneID string) (r GetResult) {
55 _, r.Err = client.Get(zoneURL(client, zoneID), &r.Body, nil)
56 return
57}