Sha256: cbb567668e587c2cf97bc2a5f48b7c2be1c7cefa700bd1a70cb524f931609809

Contents?: true

Size: 1.46 KB

Versions: 136

Compression:

Stored size: 1.46 KB

Contents

module Katello
  module Resources
    module Candlepin
      class Content < CandlepinResource
        class << self
          def create(owner_label, attrs)
            JSON.parse(self.post(path(owner_label), JSON.generate(attrs), self.default_headers).body).with_indifferent_access
          end

          def get(owner_label, id)
            content_json = super(path(owner_label, id), self.default_headers).body
            JSON.parse(content_json).with_indifferent_access
          end

          def all(owner_label, include_only: nil)
            includes = include_only ? "?#{included_list(include_only)}" : ""
            content_json = Candlepin::CandlepinResource.get(path(owner_label) + includes, self.default_headers).body
            JSON.parse(content_json)
          end

          def destroy(owner_label, id)
            fail ArgumentError, "content id has to be specified" unless id

            begin
              self.delete(path(owner_label, id), self.default_headers).code.to_i
            rescue RestClient::NotFound
              # this is OK
              :content_gone
            end
          end

          def update(owner_label, attrs)
            JSON.parse(self.put(path(owner_label, attrs[:id] || attrs['id']), JSON.generate(attrs), self.default_headers).body).with_indifferent_access
          end

          def path(owner_label, id = nil)
            "/candlepin/owners/#{owner_label}/content/#{id}"
          end
        end
      end
    end
  end
end

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
katello-4.4.0.2 app/lib/katello/resources/candlepin/content.rb
katello-4.4.0.1 app/lib/katello/resources/candlepin/content.rb
katello-4.3.1 app/lib/katello/resources/candlepin/content.rb
katello-4.4.0 app/lib/katello/resources/candlepin/content.rb
katello-4.4.0.rc2 app/lib/katello/resources/candlepin/content.rb
katello-4.4.0.rc1 app/lib/katello/resources/candlepin/content.rb
katello-4.2.2 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0.rc4 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0.rc3 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0.rc2.1 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0.rc2 app/lib/katello/resources/candlepin/content.rb
katello-4.3.0.rc1 app/lib/katello/resources/candlepin/content.rb
katello-4.2.1 app/lib/katello/resources/candlepin/content.rb
katello-4.2.0.1 app/lib/katello/resources/candlepin/content.rb
katello-4.1.4 app/lib/katello/resources/candlepin/content.rb
katello-4.0.3 app/lib/katello/resources/candlepin/content.rb
katello-4.2.0.1.rc3 app/lib/katello/resources/candlepin/content.rb
katello-3.18.5 app/lib/katello/resources/candlepin/content.rb
katello-4.2.0.1.rc2 app/lib/katello/resources/candlepin/content.rb