-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint to list currently supported versions for an enviro…
…nment
- Loading branch information
Showing
11 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
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
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
70 changes: 70 additions & 0 deletions
70
lib/pact_broker/api/resources/currently_supported_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,70 @@ | ||
require "pact_broker/api/resources/base_resource" | ||
require "pact_broker/api/decorators/versions_decorator" | ||
require "pact_broker/string_refinements" | ||
|
||
module PactBroker | ||
module Api | ||
module Resources | ||
class CurrentlySupportedVersionsForEnvironment < BaseResource | ||
using PactBroker::StringRefinements | ||
|
||
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(decorator_name).new(released_versions).to_json(decorator_options(title: title)) | ||
end | ||
|
||
def policy_name | ||
:'deployments::environment' | ||
end | ||
|
||
def policy_record | ||
environment | ||
end | ||
|
||
def decorator_name | ||
:released_versions_decorator | ||
end | ||
|
||
private | ||
|
||
def environment | ||
@environment ||= environment_service.find(environment_uuid) | ||
end | ||
|
||
def released_versions | ||
@released_versions ||= released_version_service.find_currently_supported_versions_for_environment(environment, query_params) | ||
end | ||
|
||
def environment_uuid | ||
identifier_from_path[:environment_uuid] | ||
end | ||
|
||
def query_params | ||
{ | ||
pacticipant_name: request.query["pacticipant"], | ||
pacticipant_version_number: request.query["version"] | ||
}.compact | ||
end | ||
|
||
def title | ||
"Currently supported versions in #{environment.display_name}" | ||
end | ||
end | ||
end | ||
end | ||
end |
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
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