Sha256: 22007c074d6e0d36111114ddf05d9d9384d495734327583c17f1cbb4c31ae19d
Contents?: true
Size: 1.8 KB
Versions: 4
Compression:
Stored size: 1.8 KB
Contents
require 'pact_broker/api/resources/base_resource' require 'pact_broker/api/resources/environment' module PactBroker module Api module Resources class Environment < BaseResource def content_types_provided [["application/hal+json", :to_json]] end def content_types_accepted [["application/json", :from_json]] end def allowed_methods ["GET", "PUT", "DELETE", "OPTIONS"] end def resource_exists? !!environment end def malformed_request? if request.put? && environment invalid_json? || validation_errors_for_schema?(schema, params.merge(uuid: uuid)) else false end end def from_json if environment @environment = update_environment response.body = to_json else response.code = 404 end end def policy_name :'deployments::environment' end def to_json decorator_class(:environment_decorator).new(environment).to_json(decorator_options) end def parsed_environment @parsed_environment ||= decorator_class(:environment_decorator).new(PactBroker::Deployments::Environment.new).from_json(request_body) end def environment @environment ||= environment_service.find(uuid) end def delete_resource environment_service.delete(uuid) true end def uuid identifier_from_path[:environment_uuid] end def update_environment environment_service.update(uuid, parsed_environment) end def schema PactBroker::Api::Contracts::EnvironmentSchema end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems