Class: Runcible::Resources::Consumer

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/consumer.rb

Overview

Direct Known Subclasses

Extensions::Consumer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #format_payload_json, #generate_log_message, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #path, #process_response, #required_params

Constructor Details

This class inherits a constructor from Runcible::Base

Class Method Details

.path(id = nil) ⇒ String

Generates the API path for Consumers

Parameters:

  • id (String) (defaults to: nil)

    the ID of the consumer

Returns:

  • (String)

    the consumer path, may contain the id if passed



9
10
11
# File 'lib/runcible/resources/consumer.rb', line 9

def self.path(id = nil)
  id.nil? ? 'consumers/' : "consumers/#{id}/"
end

Instance Method Details

#applicability(options = {}) ⇒ RestClient::Response

retrieve the applicability for some set of consumers

Parameters:

  • options (Hash) (defaults to: {})

    hash representing criteria

Returns:

  • (RestClient::Response)


163
164
165
# File 'lib/runcible/resources/consumer.rb', line 163

def applicability(options = {})
  call(:post, path + 'content/applicability/', :payload => { :required => options })
end

#bind(id, repo_id, distributor_id, optional = {}) ⇒ RestClient::Response

Bind a consumer to a repository for a given distributor

Parameters:

  • id (String)

    the ID of the consumer

  • repo_id (String)

    the ID of the repository

  • distributor_id (String)

    the ID of the distributor

  • optional (Hash) (defaults to: {})

    optional parameters

Returns:

  • (RestClient::Response)


93
94
95
96
# File 'lib/runcible/resources/consumer.rb', line 93

def bind(id, repo_id, distributor_id, optional = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/bindings/"), :payload => { :required => required, :optional => optional })
end

#create(id, optional = {}) ⇒ RestClient::Response

Creates a consumer

Parameters:

  • id (String)

    the ID of the consumer

  • optional (Hash) (defaults to: {})

    container for all optional parameters

Returns:

  • (RestClient::Response)


18
19
20
21
# File 'lib/runcible/resources/consumer.rb', line 18

def create(id, optional = {})
  required = required_params(binding.send(:local_variables), binding)
  call(:post, path, :payload => { :required => required, :optional => optional })
end

#delete(id) ⇒ RestClient::Response

Deletes a consumer

Parameters:

  • id (String)

    the id of the consumer

Returns:

  • (RestClient::Response)


44
45
46
# File 'lib/runcible/resources/consumer.rb', line 44

def delete(id)
  call(:delete, path(id))
end

#install_units(id, units, options = {}) ⇒ RestClient::Response

Install a set of units onto a consumer

Parameters:

  • id (String)

    the ID of the consumer

  • units (Array)

    array of units to install

  • options (Hash) (defaults to: {})

    hash of install options

Returns:

  • (RestClient::Response)


114
115
116
117
# File 'lib/runcible/resources/consumer.rb', line 114

def install_units(id, units, options = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
end

#regenerate_applicability(options = {}) ⇒ RestClient::Response

(Re)Generate applicability for some set of consumers

Parameters:

  • options (Hash) (defaults to: {})

    payload representing criteria

Returns:

  • (RestClient::Response)


145
146
147
# File 'lib/runcible/resources/consumer.rb', line 145

def regenerate_applicability(options = {})
  call(:post, path('actions/content/regenerate_applicability/'), :payload => { :required => options})
end

#regenerate_applicability_by_id(id, options = {}) ⇒ RestClient::Response

(Re)Generate applicability for a single consumer. This does not cause a pulp lock, see pulp.plan.io/issues/1173#note-12

Parameters:

  • id (String)

    the ID of the consumer

  • options (Hash) (defaults to: {})

    payload representing criteria

Returns:

  • (RestClient::Response)


155
156
157
# File 'lib/runcible/resources/consumer.rb', line 155

def regenerate_applicability_by_id(id, options = {})
  call(:post, path(id) + 'actions/content/regenerate_applicability/', :payload => { :required => options})
end

#retrieve(id) ⇒ RestClient::Response

Retrieves a consumer

Parameters:

  • id (String)

    the ID of the consumer

Returns:

  • (RestClient::Response)


27
28
29
# File 'lib/runcible/resources/consumer.rb', line 27

def retrieve(id)
  call(:get, path(id))
end

#retrieve_binding(id, repo_id, distributor_id) ⇒ RestClient::Response

Retrieve a consumer binding

Parameters:

  • id (String)

    the ID of the consumer

  • repo_id (String)

    the ID of the repository

  • distributor_id (String)

    the ID of the distributor

Returns:

  • (RestClient::Response)


74
75
76
# File 'lib/runcible/resources/consumer.rb', line 74

def retrieve_binding(id, repo_id, distributor_id)
  call(:get, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
end

#retrieve_bindings(id) ⇒ RestClient::Response

Retrieve all consumer bindings

Parameters:

  • id (String)

    the ID of the consumer

Returns:

  • (RestClient::Response)


82
83
84
# File 'lib/runcible/resources/consumer.rb', line 82

def retrieve_bindings(id)
  call(:get, path("#{id}/bindings/"))
end

#retrieve_profile(id, content_type) ⇒ RestClient::Response

Retrieve a consumer profile

Parameters:

  • id (String)

    the ID of the consumer

  • content_type (String)

    the content type

Returns:

  • (RestClient::Response)


64
65
66
# File 'lib/runcible/resources/consumer.rb', line 64

def retrieve_profile(id, content_type)
  call(:get, path("#{id}/profiles/#{content_type}/"))
end

#unbind(id, repo_id, distributor_id) ⇒ RestClient::Response

Unbind a consumer to a repository for a given distributor

Parameters:

  • id (String)

    the ID of the consumer

  • repo_id (String)

    the ID of the repository

  • distributor_id (String)

    the ID of the distributor

Returns:

  • (RestClient::Response)


104
105
106
# File 'lib/runcible/resources/consumer.rb', line 104

def unbind(id, repo_id, distributor_id)
  call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
end

#uninstall_units(id, units, options = {}) ⇒ RestClient::Response

Uninstall a set of units from a consumer

Parameters:

  • id (String)

    the ID of the consumer

  • units (Array)

    array of units to uninstall

  • options (Hash) (defaults to: {})

    hash of uninstall options

Returns:

  • (RestClient::Response)


136
137
138
139
# File 'lib/runcible/resources/consumer.rb', line 136

def uninstall_units(id, units, options = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
end

#update(id, optional = {}) ⇒ RestClient::Response

Updates a consumer

Parameters:

  • id (String)

    the ID of the consumer

  • optional (Hash) (defaults to: {})

    container for all optional parameters

Returns:

  • (RestClient::Response)


36
37
38
# File 'lib/runcible/resources/consumer.rb', line 36

def update(id, optional = {})
  call(:put, path(id), :payload => { :delta => optional })
end

#update_units(id, units, options = {}) ⇒ RestClient::Response

Update a set of units on a consumer

Parameters:

  • id (String)

    the ID of the consumer

  • units (Array)

    array of units to update

  • options (Hash) (defaults to: {})

    hash of update options

Returns:

  • (RestClient::Response)


125
126
127
128
# File 'lib/runcible/resources/consumer.rb', line 125

def update_units(id, units, options = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
end

#upload_profile(id, content_type, profile) ⇒ RestClient::Response

Create consumer profile

Parameters:

  • id (String)

    the ID of the consumer

  • content_type (String)

    the content type

  • profile (Hash)

    hash representing the consumer profile

Returns:

  • (RestClient::Response)


54
55
56
57
# File 'lib/runcible/resources/consumer.rb', line 54

def upload_profile(id, content_type, profile)
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/profiles/"), :payload => { :required => required })
end