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

Orchestration stack subcollection #14273

Merged
merged 1 commit into from
Mar 14, 2017
Merged
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
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