Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(identity): add get endpoint by ID #2749

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions acceptance/openstack/identity/v3/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ func TestEndpointsList(t *testing.T) {
th.AssertEquals(t, found, true)
}

func TestEndpointsGet(t *testing.T) {
clients.RequireAdmin(t)

client, err := clients.NewIdentityV3Client()
th.AssertNoErr(t, err)

allPages, err := endpoints.List(client, nil).AllPages()
th.AssertNoErr(t, err)

allEndpoints, err := endpoints.ExtractEndpoints(allPages)
th.AssertNoErr(t, err)

endpoint := allEndpoints[0]
e, err := endpoints.Get(client, endpoint.ID).Extract()
if err != nil {
t.Fatalf("Unable to get endpoint: %v", err)
}

tools.PrintResource(t, p)

th.AssertEquals(t, e.Name, e.Name)

}

func TestEndpointsNavigateCatalog(t *testing.T) {
clients.RequireAdmin(t)

Expand Down
7 changes: 7 additions & 0 deletions openstack/identity/v3/endpoints/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa
})
}

// Get retrieves details on a single endpoint, by ID.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
resp, err := client.Get(endpointURL(client, id), &r.Body, nil)
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}

// UpdateOptsBuilder allows extensions to add parameters to the Update request.
type UpdateOptsBuilder interface {
ToEndpointUpdateMap() (map[string]interface{}, error)
Expand Down
6 changes: 6 additions & 0 deletions openstack/identity/v3/endpoints/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func (r commonResult) Extract() (*Endpoint, error) {
return s.Endpoint, err
}

// GetResult is the response from a Get operation. Call its Extract method
// to interpret it as an Endpoint.
type GetResult struct {
commonResult
}

// CreateResult is the response from a Create operation. Call its Extract
// method to interpret it as an Endpoint.
type CreateResult struct {
Expand Down
Loading