Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit d00110d

Browse files
authored
v3(services): delete route binding fixes (cloudfoundry#1878)
- docs were missing - failure was not reported on last_operation [#174191028](https://www.pivotaltracker.com/story/show/174191028)
1 parent 434e922 commit d00110d

5 files changed

Lines changed: 57 additions & 1 deletion

File tree

app/actions/service_route_binding_delete.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def delete(binding, async_allowed:)
2424
binding.notify_diego
2525

2626
DeleteComplete
27+
rescue => e
28+
binding.save_with_new_operation({}, {
29+
type: 'delete',
30+
state: 'failed',
31+
description: e.message,
32+
})
33+
34+
raise e
2735
end
2836

2937
private

docs/v3/source/includes/experimental_resources/service_credential_bindings/_delete.md renamed to docs/v3/source/includes/experimental_resources/service_credential_bindings/_delete.md.erb

File renamed without changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
### Delete a service route binding
2+
3+
```
4+
Example Request
5+
```
6+
7+
```shell
8+
curl "https://api.example.org/v3/service_route_bindings/[guid]" \
9+
-X DELETE \
10+
-H "Authorization: bearer [token]"
11+
```
12+
13+
```
14+
Example Response for User-provided Service Instances
15+
```
16+
17+
```http
18+
HTTP/1.1 204 No Content
19+
```
20+
21+
```
22+
Example Response for Managed Service Instance
23+
```
24+
25+
```http
26+
HTTP/1.1 202 Accepted
27+
Content-Type: application/json
28+
Location: https://api.example.org/v3/jobs/af5c57f6-8769-41fa-a499-2c84ed896788
29+
```
30+
31+
This endpoint deletes a service route binding. When deleting route bindings originating from user provided
32+
service instances, the delete operation does not require interactions with service brokers, therefore the API will
33+
respond synchronously to the delete request. Consequently, deleting route bindings from managed service instances
34+
responds with a job which can be used to track the progress of the delete operation.
35+
36+
#### Definition
37+
`DELETE /v3/service_route_bindings/:guid`
38+
39+
#### Permitted Roles
40+
|
41+
--- | ---
42+
Admin |
43+
Space Developer |

docs/v3/source/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ includes:
368368
- experimental_resources/service_route_bindings/create
369369
- experimental_resources/service_route_bindings/list
370370
- experimental_resources/service_route_bindings/get
371+
- experimental_resources/service_route_bindings/delete
371372
- experimental_resources/service_instances/header
372373
- experimental_resources/service_instances/create
373374
- experimental_resources/service_instances/get

spec/unit/actions/service_route_binding_delete_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,17 @@ module V3
122122
dbl
123123
end
124124

125-
it 'fails with an appropriate error' do
125+
it 'fails with an appropriate error and stores the message in the binding' do
126126
expect {
127127
action.delete(route_binding, async_allowed: async_allowed)
128128
}.to raise_error(
129129
described_class::UnprocessableDelete,
130130
"Service broker failed to delete service binding for instance #{service_instance.name}: awful thing",
131131
)
132+
133+
expect(route_binding.last_operation.type).to eq('delete')
134+
expect(route_binding.last_operation.state).to eq('failed')
135+
expect(route_binding.last_operation.description).to eq("Service broker failed to delete service binding for instance #{service_instance.name}: awful thing")
132136
end
133137
end
134138
end

0 commit comments

Comments
 (0)