Sha256: 5af7a78c866cecd7e910e52f4a01449f00ffbd94eb65883929377529ef4d5e12
Contents?: true
Size: 1.8 KB
Versions: 8
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
8 entries across 8 versions & 1 rubygems