/
requests.go
33 lines (28 loc) · 1.26 KB
/
requests.go
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
package projectendpoints
import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/pagination"
)
type CreateOptsBuilder interface {
ToEndpointCreateMap() (map[string]interface{}, error)
}
// Create inserts a new Endpoint association to a project.
func Create(client *gophercloud.ServiceClient, projectID, endpointID string) (r CreateResult) {
resp, err := client.Put(createURL(client, projectID, endpointID), nil, nil, &gophercloud.RequestOpts{OkCodes: []int{204}})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
// List enumerates endpoints in a paginated collection, optionally filtered
// by ListOpts criteria.
func List(client *gophercloud.ServiceClient, projectID string) pagination.Pager {
u := listURL(client, projectID)
return pagination.NewPager(client, u, func(r pagination.PageResult) pagination.Page {
return EndpointPage{pagination.LinkedPageBase{PageResult: r}}
})
}
// Delete removes an endpoint from the service catalog.
func Delete(client *gophercloud.ServiceClient, projectID string, endpointID string) (r DeleteResult) {
resp, err := client.Delete(deleteURL(client, projectID, endpointID), &gophercloud.RequestOpts{OkCodes: []int{204}})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}