Sha256: 7ae30d7a67f26e3c1e5205a411fdb0211e9af8fa3ef045e04997524f6dd4283c

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

module Katello
  module Resources
    module Candlepin
      class Pool < CandlepinResource
        extend PoolResource

        class << self
          def get_for_owner(owner_key, include_temporary_guests = false)
            url = "#{prefix}/owners/#{owner_key}/pools?add_future=true"
            url += "&attribute=unmapped_guests_only:!true" if include_temporary_guests
            pools_json = self.get(url, self.default_headers).body
            JSON.parse(pools_json)
          end

          def create(owner_key, attrs)
            pool = self.post("/candlepin/owners/#{owner_key}/pools", attrs.to_json, self.default_headers).body
            pool
          end

          def find(pool_id)
            pool_json = self.get(path(pool_id), self.default_headers).body
            fail ArgumentError, "pool id cannot contain ?" if pool_id["?"]
            JSON.parse(pool_json).with_indifferent_access
          end

          def destroy(id)
            fail ArgumentError, "pool id has to be specified" unless id
            self.delete(path(id), self.default_headers).code.to_i
          end

          def entitlements(pool_id, included = [])
            entitlement_json = self.get("#{path(pool_id)}/entitlements?#{included_list(included)}", self.default_headers).body
            JSON.parse(entitlement_json)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-3.8.1 app/lib/katello/resources/candlepin/pool.rb
katello-3.7.1.1 app/lib/katello/resources/candlepin/pool.rb
katello-3.7.1 app/lib/katello/resources/candlepin/pool.rb
katello-3.8.0 app/lib/katello/resources/candlepin/pool.rb
katello-3.8.0.rc3 app/lib/katello/resources/candlepin/pool.rb
katello-3.8.0.rc2 app/lib/katello/resources/candlepin/pool.rb
katello-3.7.0 app/lib/katello/resources/candlepin/pool.rb
katello-3.8.0.rc1 app/lib/katello/resources/candlepin/pool.rb
katello-3.7.0.rc2 app/lib/katello/resources/candlepin/pool.rb
katello-3.7.0.rc1 app/lib/katello/resources/candlepin/pool.rb