-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deployed versions): add endpoint to list deployed versions for a…
…n environment
- Loading branch information
Showing
4 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
lib/pact_broker/api/resources/deployed_versions_for_environment.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'pact_broker/api/resources/base_resource' | ||
require 'pact_broker/api/decorators/versions_decorator' | ||
|
||
module PactBroker | ||
module Api | ||
module Resources | ||
class DeployedVersionsForEnvironment < BaseResource | ||
def content_types_accepted | ||
[["application/json", :from_json]] | ||
end | ||
|
||
def content_types_provided | ||
[["application/hal+json", :to_json]] | ||
end | ||
|
||
def allowed_methods | ||
["GET", "OPTIONS"] | ||
end | ||
|
||
def resource_exists? | ||
!!environment | ||
end | ||
|
||
def to_json | ||
decorator_class(:deployed_versions_decorator).new(deployed_versions).to_json(decorator_options(title: title)) | ||
end | ||
|
||
def policy_name | ||
:'versions::versions' | ||
end | ||
|
||
private | ||
|
||
attr_reader :deployed_versions | ||
|
||
def environment | ||
@environment ||= environment_service.find(environment_uuid) | ||
end | ||
|
||
def deployed_versions | ||
@deployed_versions ||= deployed_version_service.find_deployed_versions_for_environment(environment) | ||
end | ||
|
||
def environment_uuid | ||
identifier_from_path[:environment_uuid] | ||
end | ||
|
||
def title | ||
"Deployed versions for #{environment.display_name}" | ||
end | ||
end | ||
end | ||
end | ||
end |
1 change: 0 additions & 1 deletion
1
lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters