Sha256: 80add70bc50f813e60e91a70ed89f3c9c6e41a1e2bad2ed2fb7099ecb6d8f3a6

Contents?: true

Size: 1.61 KB

Versions: 20

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require_relative '../../../puppet/indirector/rest'
require_relative '../../../puppet/file_bucket/file'

module Puppet::FileBucketFile
  class Rest < Puppet::Indirector::REST
    desc "This is a REST based mechanism to send/retrieve file to/from the filebucket"

    def head(request)
      session = Puppet.lookup(:http_session)
      api = session.route_to(:puppet)
      api.head_filebucket_file(
        request.key,
        environment: request.environment.to_s,
        bucket_path: request.options[:bucket_path]
      )
    rescue Puppet::HTTP::ResponseError => e
      return nil if e.response.code == 404

      raise convert_to_http_error(e.response)
    end

    def find(request)
      session = Puppet.lookup(:http_session)
      api = session.route_to(:puppet)
      _, filebucket_file = api.get_filebucket_file(
        request.key,
        environment: request.environment.to_s,
        bucket_path: request.options[:bucket_path],
        diff_with: request.options[:diff_with],
        list_all: request.options[:list_all],
        fromdate: request.options[:fromdate],
        todate: request.options[:todate]
      )
      filebucket_file
    rescue Puppet::HTTP::ResponseError => e
      raise convert_to_http_error(e.response)
    end

    def save(request)
      session = Puppet.lookup(:http_session)
      api = session.route_to(:puppet)
      api.put_filebucket_file(
        request.key,
        body: request.instance.render,
        environment: request.environment.to_s
      )
    rescue Puppet::HTTP::ResponseError => e
      raise convert_to_http_error(e.response)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.10.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.10.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.10.0-universal-darwin lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.9.0 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.9.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.9.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.9.0-universal-darwin lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.8.1 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.8.1-x86-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.8.1-x64-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.8.1-universal-darwin lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.7.0 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.7.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.7.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.7.0-universal-darwin lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.6.0 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.6.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.6.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/rest.rb
puppet-8.6.0-universal-darwin lib/puppet/indirector/file_bucket_file/rest.rb