Class: Katello::Resources::Candlepin::Pool

Inherits:
CandlepinResource show all
Extended by:
PoolResource
Defined in:
app/lib/katello/resources/candlepin/pool.rb

Constant Summary

Constants inherited from HttpResource

HttpResource::REQUEST_MAP

Instance Attribute Summary

Attributes inherited from HttpResource

#json

Class Method Summary collapse

Methods included from PoolResource

path

Methods inherited from CandlepinResource

default_headers, fetch_paged, included_list, logger, name_to_key, process_response, raise_rest_client_exception

Methods inherited from HttpResource

#[], #[]=, hash_to_query, #initialize, issue_request, join_path, logger, process_response, raise_rest_client_exception, rest_client

Methods included from Concerns::FilterSensitiveData

#filter_sensitive_data

Constructor Details

This class inherits a constructor from Katello::HttpResource

Class Method Details

.consumer_uuids(pool_id) ⇒ Object



35
36
37
38
# File 'app/lib/katello/resources/candlepin/pool.rb', line 35

def consumer_uuids(pool_id)
  entitlement_json = self.get("#{path(pool_id)}/entitlements/consumer_uuids", self.default_headers).body
  JSON.parse(entitlement_json)
end

.create(owner_key, attrs) ⇒ Object



15
16
17
18
# File 'app/lib/katello/resources/candlepin/pool.rb', line 15

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

.destroy(id) ⇒ Object



30
31
32
33
# File 'app/lib/katello/resources/candlepin/pool.rb', line 30

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

.find(pool_id) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/lib/katello/resources/candlepin/pool.rb', line 20

def find(pool_id)
  begin
    pool_json = self.get(path(pool_id), self.default_headers).body
  rescue RestClient::ResourceNotFound
    raise Katello::Errors::CandlepinPoolGone
  end

  JSON.parse(pool_json).with_indifferent_access
end

.get_for_owner(owner_key, include_temporary_guests = false) ⇒ Object



8
9
10
11
12
13
# File 'app/lib/katello/resources/candlepin/pool.rb', line 8

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