Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea6e376

Browse filesBrowse files
committed
feat(identity): add get endpoint by ID
1 parent ecad1a2 commit ea6e376
Copy full SHA for ea6e376

File tree

3 files changed

+36
-0
lines changed
Filter options

3 files changed

+36
-0
lines changed

‎acceptance/openstack/identity/v3/endpoint_test.go

Copy file name to clipboardExpand all lines: acceptance/openstack/identity/v3/endpoint_test.go
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ func TestEndpointsList(t *testing.T) {
3939
th.AssertEquals(t, found, true)
4040
}
4141

42+
func TestEndpointsGet(t *testing.T) {
43+
clients.RequireAdmin(t)
44+
45+
client, err := clients.NewIdentityV3Client()
46+
th.AssertNoErr(t, err)
47+
48+
allPages, err := endpoints.List(client, nil).AllPages()
49+
th.AssertNoErr(t, err)
50+
51+
allEndpoints, err := endpoints.ExtractEndpoints(allPages)
52+
th.AssertNoErr(t, err)
53+
54+
endpoint := allEndpoints[0]
55+
e, err := endpoints.Get(client, endpoint.ID).Extract()
56+
if err != nil {
57+
t.Fatalf("Unable to get endpoint: %v", err)
58+
}
59+
60+
tools.PrintResource(t, e)
61+
62+
th.AssertEquals(t, e.Name, e.Name)
63+
}
64+
4265
func TestEndpointsNavigateCatalog(t *testing.T) {
4366
clients.RequireAdmin(t)
4467

‎openstack/identity/v3/endpoints/requests.go

Copy file name to clipboardExpand all lines: openstack/identity/v3/endpoints/requests.go
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa
8888
})
8989
}
9090

91+
// Get retrieves details on a single endpoint, by ID.
92+
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
93+
resp, err := client.Get(endpointURL(client, id), &r.Body, nil)
94+
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
95+
return
96+
}
97+
9198
// UpdateOptsBuilder allows extensions to add parameters to the Update request.
9299
type UpdateOptsBuilder interface {
93100
ToEndpointUpdateMap() (map[string]interface{}, error)

‎openstack/identity/v3/endpoints/results.go

Copy file name to clipboardExpand all lines: openstack/identity/v3/endpoints/results.go
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ func (r commonResult) Extract() (*Endpoint, error) {
1919
return s.Endpoint, err
2020
}
2121

22+
// GetResult is the response from a Get operation. Call its Extract method
23+
// to interpret it as an Endpoint.
24+
type GetResult struct {
25+
commonResult
26+
}
27+
2228
// CreateResult is the response from a Create operation. Call its Extract
2329
// method to interpret it as an Endpoint.
2430
type CreateResult struct {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.