Class: Runcible::Resources::Repository

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

Overview

Direct Known Subclasses

Extensions::Repository

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, #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



34
35
36
# File 'lib/runcible/resources/repository.rb', line 34

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)


110
111
112
113
# File 'lib/runcible/resources/repository.rb', line 110

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)


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

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)


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

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)


70
71
72
# File 'lib/runcible/resources/repository.rb', line 70

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)


179
180
181
# File 'lib/runcible/resources/repository.rb', line 179

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)


199
200
201
# File 'lib/runcible/resources/repository.rb', line 199

def delete_importer(id, importer_id)
  call(:delete, "#{path(id)}/importers/#{importer_id}/")
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)


170
171
172
# File 'lib/runcible/resources/repository.rb', line 170

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)


218
219
220
# File 'lib/runcible/resources/repository.rb', line 218

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)


53
54
55
# File 'lib/runcible/resources/repository.rb', line 53

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)


78
79
80
# File 'lib/runcible/resources/repository.rb', line 78

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)


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

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)


120
121
122
# File 'lib/runcible/resources/repository.rb', line 120

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)


128
129
130
# File 'lib/runcible/resources/repository.rb', line 128

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)


149
150
151
152
153
# File 'lib/runcible/resources/repository.rb', line 149

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)


138
139
140
141
142
# File 'lib/runcible/resources/repository.rb', line 138

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)


160
161
162
# File 'lib/runcible/resources/repository.rb', line 160

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)


62
63
64
# File 'lib/runcible/resources/repository.rb', line 62

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

#update_distributor(id, distributor_id, distributor_config) ⇒ 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)


189
190
191
192
# File 'lib/runcible/resources/repository.rb', line 189

def update_distributor(id, distributor_id, distributor_config)
  required = required_params(binding.send(:local_variables), binding, ["id", "distributor_id"])
  call(:put, path("#{id}/distributors/#{distributor_id}/"), :payload => { :required => required})
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)


209
210
211
212
# File 'lib/runcible/resources/repository.rb', line 209

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