Sha256: ba7b6b5067b782b15d89ebc17c2257061f165a2be06b148735d47b96ad940c3b

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true
require_relative '../../../puppet/indirector/code'

module Puppet::FileBucketFile
  class Selector < Puppet::Indirector::Code
    desc "Select the terminus based on the request"

    def select(request)
      if request.protocol == 'https'
        :rest
      else
        :file
      end
    end

    def get_terminus(request)
      indirection.terminus(select(request))
    end

    def head(request)
      get_terminus(request).head(request)
    end

    def find(request)
      get_terminus(request).find(request)
    end

    def save(request)
      get_terminus(request).save(request)
    end

    def search(request)
      get_terminus(request).search(request)
    end

    def destroy(request)
      get_terminus(request).destroy(request)
    end

    def authorized?(request)
      terminus = get_terminus(request)
      if terminus.respond_to?(:authorized?)
        terminus.authorized?(request)
      else
        true
      end
    end

    def validate_key(request)
      get_terminus(request).validate(request)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.0-universal-darwin lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.1 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.1-x86-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.1-x64-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.3.1-universal-darwin lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.2.0 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.2.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.2.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.2.0-universal-darwin lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.1.0 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.1.0-x86-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.1.0-x64-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.1.0-universal-darwin lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.0.1 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.0.1-x86-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.0.1-x64-mingw32 lib/puppet/indirector/file_bucket_file/selector.rb
puppet-8.0.1-universal-darwin lib/puppet/indirector/file_bucket_file/selector.rb