Class: Runcible::Resources::Repository

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

Overview

Direct Known Subclasses

Extensions::Repository

Instance Attribute Summary

Attributes inherited from Base

#logs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #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 Repositories

Parameters:

  • id (String) (defaults to: nil)

    the id of the repository

Returns:

  • (String)

    the repository path, may contain the id if passed



11
12
13
# File 'lib/runcible/resources/repository.rb', line 11

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

Instance Method Details

#associate_distributor(id, distributor_type_id, distributor_config, optional = {}) ⇒ RestClient::Response

Associates a distributor to a repository

Parameters:

  • id (String)

    the ID of the repository

  • distributor_type_id (String)

    the type ID of the distributor being associated

  • distributor_config (Hash)

    configuration options for the distributor

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


87
88
89
90
# File 'lib/runcible/resources/repository.rb', line 87

def associate_distributor(id, distributor_type_id, distributor_config, optional = {})
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, path("#{id}/distributors"), :payload => { :required => required, :optional => optional })
end

#associate_importer(id, importer_type_id, importer_config) ⇒ RestClient::Response

Associates an importer to a repository

Parameters:

  • id (String)

    the ID of the repository

  • importer_type_id (String)

    the type ID of the importer being associated

  • importer_config (Hash)

    configuration options for the importer

Returns:

  • (RestClient::Response)


75
76
77
78
# File 'lib/runcible/resources/repository.rb', line 75

def associate_importer(id, importer_type_id, importer_config)
  required = required_params(binding.send(:local_variables), binding)
  call(:post, path("#{id}/importers"), :payload => { :required => required })
end

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

Creates a repository

Parameters:

  • id (String)

    the id of the repository

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


20
21
22
23
# File 'lib/runcible/resources/repository.rb', line 20

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 repository

Parameters:

  • id (String)

    the id of the repository

Returns:

  • (RestClient::Response)


47
48
49
# File 'lib/runcible/resources/repository.rb', line 47

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

#delete_distributor(id, distributor_id) ⇒ RestClient::Response

Deletes the specified distributor from the repository

Parameters:

  • id (String)

    the id of the repository

  • distributor_id (String)

    the id of the distributor

Returns:

  • (RestClient::Response)


166
167
168
# File 'lib/runcible/resources/repository.rb', line 166

def delete_distributor(id, distributor_id)
  call(:delete, "#{path(id)}/distributors/#{distributor_id}/")
end

#delete_importer(id, importer_id) ⇒ RestClient::Response

Deletes the specified importer from the repository

Parameters:

  • id (String)

    the id of the repository

  • importer_id (String)

    the id of the importer

Returns:

  • (RestClient::Response)


186
187
188
# File 'lib/runcible/resources/repository.rb', line 186

def delete_importer(id, importer_id)
  call(:delete, "#{path(id)}/importers/#{importer_id}/")
end

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

Downloads all units in a repository (useful in the case of on_demand repositories)

Parameters:

  • id (String)

    the id of the repository

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


106
107
108
# File 'lib/runcible/resources/repository.rb', line 106

def download(id, optional = {})
  call(:post, "#{path(id)}actions/download/", :payload => { :optional => optional })
end

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

Publishes a repository using the specified distributor

Parameters:

  • id (String)

    the id of the repository

  • distributor_id (String)

    the id of the distributor

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

    optional params

Returns:

  • (RestClient::Response)


156
157
158
159
# File 'lib/runcible/resources/repository.rb', line 156

def publish(id, distributor_id, optional = {})
  call(:post, "#{path(id)}actions/publish/",
       :payload => {:required => {:id => distributor_id}, :optional => optional})
end

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

Regenerate the applicability for consumers bound to a given set of repositories

Parameters:

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

    payload representing criteria

Returns:

  • (RestClient::Response)


205
206
207
# File 'lib/runcible/resources/repository.rb', line 205

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

#retrieve(id, params = {}) ⇒ RestClient::Response

Retrieves a repository

Parameters:

  • id (String)

    the id of the repository

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

    container for optional query parameters

Returns:

  • (RestClient::Response)


30
31
32
# File 'lib/runcible/resources/repository.rb', line 30

def retrieve(id, params = {})
  call(:get, path(id), :params => params)
end

#retrieve_all(optional = {}) ⇒ RestClient::Response

Retrieve all repositories

Parameters:

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


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

def retrieve_all(optional = {})
  call(:get, path, :payload => { :optional => optional })
end

#search(criteria, optional = {}) ⇒ RestClient::Response

Searches for repositories based on criteria

Parameters:

  • criteria (Hash)

    criteria object containing Mongo syntax

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


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

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

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

Syncs a repository

Parameters:

  • id (String)

    the id of the repository

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


97
98
99
# File 'lib/runcible/resources/repository.rb', line 97

def sync(id, optional = {})
  call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional })
end

#sync_history(id) ⇒ RestClient::Response

History of all sync actions on a repository

Parameters:

  • id (String)

    the id of the repository

Returns:

  • (RestClient::Response)


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

def sync_history(id)
  call(:get, "#{path(id)}/history/sync/")
end

#unassociate_units(source_repo_id, criteria = {}) ⇒ RestClient::Response

Unassociates units from the repository

Parameters:

  • source_repo_id (String)

    the id of the source repository

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

    criteria object containing Mongo syntax

Returns:

  • (RestClient::Response)


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

def unassociate_units(source_repo_id, criteria = {})
  required = required_params(binding.send(:local_variables), binding, ['source_repo_id'])
  call(:post, "#{path(source_repo_id)}actions/unassociate/",
       :payload => { :required => required })
end

#unit_copy(destination_repo_id, source_repo_id, optional = {}) ⇒ RestClient::Response

Copies units from one repository to another

Parameters:

  • destination_repo_id (String)

    the id of the destination repository

  • source_repo_id (String)

    the id of the source repository

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


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

def unit_copy(destination_repo_id, source_repo_id, optional = {})
  required = required_params(binding.send(:local_variables), binding, ['destination_repo_id'])
  call(:post, "#{path(destination_repo_id)}actions/associate/",
       :payload => { :required => required, :optional => optional })
end

#unit_search(id, criteria = {}) ⇒ RestClient::Response

Searches the repository for units based on criteria

Parameters:

  • id (String)

    the id of the repository

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

    criteria object containing Mongo syntax

Returns:

  • (RestClient::Response)


146
147
148
# File 'lib/runcible/resources/repository.rb', line 146

def unit_search(id, criteria = {})
  call(:post, "#{path(id)}search/units/", :payload => {:required => {:criteria => criteria}})
end

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

Updates a repository

Parameters:

  • id (String)

    the id of the repository

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

    container for all optional parameters

Returns:

  • (RestClient::Response)


39
40
41
# File 'lib/runcible/resources/repository.rb', line 39

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

#update_distributor(id, distributor_id, distributor_config, optional = {}) ⇒ RestClient::Response

Updates the specified distributor from the repository

Parameters:

  • id (String)

    the id of the repository

  • distributor_id (String)

    the id of the distributor

  • distributor_config (Hash)

    attributes to change

Returns:

  • (RestClient::Response)


176
177
178
179
# File 'lib/runcible/resources/repository.rb', line 176

def update_distributor(id, distributor_id, distributor_config, optional = {})
  required = required_params(binding.send(:local_variables), binding, ['id', 'distributor_id'])
  call(:put, path("#{id}/distributors/#{distributor_id}/"), :payload => { :required => required, :optional => optional})
end

#update_importer(id, importer_id, importer_config) ⇒ RestClient::Response

Updates the specified distributor from the repository

Parameters:

  • id (String)

    the id of the repository

  • importer_id (String)

    the id of the importer

  • importer_config (Hash)

    attributes to change

Returns:

  • (RestClient::Response)


196
197
198
199
# File 'lib/runcible/resources/repository.rb', line 196

def update_importer(id, importer_id, importer_config)
  required = required_params(binding.send(:local_variables), binding, ['id', 'importer_id'])
  call(:put, path("#{id}/importers/#{importer_id}/"), :payload => { :required => required})
end