Sha256: db9e7d02f56956dccc7682acae7b03cd23ede2fb8140f85bd6fdef51bb9ed1ca
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 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 put_can_create? false end def resource_exists? !!environment end def malformed_request? super || (request.put? && environment && validation_errors_for_schema?(schema, params.merge(uuid: uuid))) end def from_json if environment @environment = replace_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 replace_environment environment_service.replace(uuid, parsed_environment) end def schema api_contract_class(:environment_schema) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems