Skip to content

Commit

Permalink
Merge pull request #484 from zhang-hua/list_key_endpoint
Browse files Browse the repository at this point in the history
Change api endpoint for listing service keys
  • Loading branch information
Simon Leung committed Jun 25, 2015
2 parents 6d7bb6f + 79066e2 commit 56ed52a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cf/api/service_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func (c CloudControllerServiceKeyRepository) CreateServiceKey(instanceGuid strin
}

func (c CloudControllerServiceKeyRepository) ListServiceKeys(instanceGuid string) ([]models.ServiceKey, error) {
path := fmt.Sprintf("/v2/service_keys?q=service_instance_guid:%s", instanceGuid)
path := fmt.Sprintf("/v2/service_instances/%s/service_keys", instanceGuid)

return c.listServiceKeys(path)
}

func (c CloudControllerServiceKeyRepository) GetServiceKey(instanceId string, keyName string) (models.ServiceKey, error) {
path := fmt.Sprintf("/v2/service_keys?q=%s", url.QueryEscape("service_instance_guid:"+instanceId+";name:"+keyName))
func (c CloudControllerServiceKeyRepository) GetServiceKey(instanceGuid string, keyName string) (models.ServiceKey, error) {
path := fmt.Sprintf("/v2/service_instances/%s/service_keys?q=%s", instanceGuid, url.QueryEscape("name:"+keyName))

serviceKeys, err := c.listServiceKeys(path)
if err != nil || len(serviceKeys) == 0 {
Expand Down
8 changes: 4 additions & 4 deletions cf/api/service_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var _ = Describe("Service Keys Repo", func() {
It("returns empty result when no service key is found", func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_keys?q=service_instance_guid:fake-instance-guid",
Path: "/v2/service_instances/fake-instance-guid/service_keys",
Response: emptyServiceKeysResponse,
}))

Expand All @@ -134,7 +134,7 @@ var _ = Describe("Service Keys Repo", func() {
It("returns correctly when service keys are found", func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_keys?q=service_instance_guid:fake-instance-guid",
Path: "/v2/service_instances/fake-instance-guid/service_keys",
Response: serviceKeysResponse,
}))

Expand Down Expand Up @@ -175,7 +175,7 @@ var _ = Describe("Service Keys Repo", func() {
It("returns service key detail", func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_keys?q=service_instance_guid:fake-instance-guid;name:fake-service-key-name",
Path: "/v2/service_instances/fake-instance-guid/service_keys?q=name:fake-service-key-name",
Response: serviceKeyDetailResponse,
}))

Expand All @@ -200,7 +200,7 @@ var _ = Describe("Service Keys Repo", func() {
It("returns empty result when the service key is not found", func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_keys?q=service_instance_guid:fake-instance-guid;name:non-exist-key-name",
Path: "/v2/service_instances/fake-instance-guid/service_keys?q=name:non-exist-key-name",
Response: emptyServiceKeysResponse,
}))

Expand Down

0 comments on commit 56ed52a

Please sign in to comment.