Skip to content

Commit

Permalink
Merge pull request #14273 from jntullo/enhancement/orchestration_stac…
Browse files Browse the repository at this point in the history
…k_subcollection

Orchestration stack subcollection
  • Loading branch information
abellotti authored Mar 14, 2017
2 parents a94622d + 26ea8ef commit 30b9c06
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class ServicesController < BaseController
include Subcollections::ServiceDialogs
include Subcollections::Tags
include Subcollections::Vms
include Subcollections::OrchestrationStacks

def create_resource(_type, _id, data)
validate_service_data(data)
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/api/subcollections/orchestration_stacks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Api
module Subcollections
module OrchestrationStacks
def orchestration_stacks_query_resource(object)
object.orchestration_stacks
end
end
end
end
15 changes: 15 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,20 @@
:post:
- :name: mark_as_seen
- :name: delete
:orchestration_stacks:
:description: Orchestration Stacks
:options:
- :subcollection
:verbs: *g
:klass: OrchestrationStack
:subcollection_actions:
:get:
- :name: read
:identifier: orchestration_stack_view
:subresource_actions:
:get:
- :name: read
:identifier: orchestration_stack_view
:orchestration_templates:
:description: Orchestration Template
:identifier: orchestration_templates_accord
Expand Down Expand Up @@ -1830,6 +1844,7 @@
- :tags
- :service_dialogs
- :vms
- :orchestration_stacks
:collection_actions:
:get:
- :name: read
Expand Down
42 changes: 42 additions & 0 deletions spec/requests/api/services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,4 +625,46 @@ def expect_svc_with_vms
end
end
end

describe 'Orchestration Stack subcollection' do
let(:os) { FactoryGirl.create(:orchestration_stack) }

before do
svc.add_resource!(os, :name => ResourceAction::PROVISION)
end

it 'can query orchestration stacks as a subcollection' do
api_basic_authorize subcollection_action_identifier(:services, :orchestration_stacks, :read, :get)

run_get("#{services_url(svc.id)}/orchestration_stacks", :expand => 'resources')

expected = {
'resources' => [
a_hash_including('id' => os.id)
]
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end

it 'can query a specific orchestration stack' do
api_basic_authorize subcollection_action_identifier(:services, :orchestration_stacks, :read, :get)

run_get("#{services_url(svc.id)}/orchestration_stacks/#{os.id}")

expected = {
'id' => os.id
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end

it 'will not return orchestration stacks without an appropriate role' do
api_basic_authorize

run_get("#{services_url(svc.id)}/orchestration_stacks")

expect(response).to have_http_status(:forbidden)
end
end
end

0 comments on commit 30b9c06

Please sign in to comment.