Class: ChinoRuby::Repositories
Instance Method Summary
collapse
#delete_resource, #get_resource, #initialize, #parse_response, #patch_resource, #post_resource, #post_resource_with_string_result, #put_resource, #return_uri
Methods inherited from CheckValues
#check_boolean, #check_int, #check_json, #check_string
Instance Method Details
#create_repository(description) ⇒ Object
475
476
477
478
479
480
481
|
# File 'lib/chino_ruby/classes.rb', line 475
def create_repository(description)
check_string(description)
data = {"description": description}.to_json
repo = Repository.new
repo.from_json(post_resource("/repositories", data).to_json, true)
repo
end
|
#delete_repository(repository_id, force) ⇒ Object
496
497
498
499
500
|
# File 'lib/chino_ruby/classes.rb', line 496
def delete_repository(repository_id, force)
check_string(repository_id)
check_boolean(force)
delete_resource("/repositories/#{repository_id}", force)
end
|
#get_repository(repo_id) ⇒ Object
451
452
453
454
455
456
|
# File 'lib/chino_ruby/classes.rb', line 451
def get_repository(repo_id)
check_string(repo_id)
repo = Repository.new
repo.from_json(get_resource("/repositories/#{repo_id}").to_json, true)
repo
end
|
#list_repositories(limit = nil, offset = nil) ⇒ Object
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
# File 'lib/chino_ruby/classes.rb', line 458
def list_repositories(limit=nil, offset=nil)
repos = GetRepositoriesResponse.new
if limit==nil && offset==nil
repos.from_json(get_resource("/repositories", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
else
repos.from_json(get_resource("/repositories", limit, offset).to_json)
end
rs = repos.repositories
repos.repositories = []
rs.each do |r|
repo = Repository.new
repo.from_json(r.to_json)
repos.repositories.push(repo)
end
repos
end
|
#update_repository(repository_id, description, is_active = nil) ⇒ Object
483
484
485
486
487
488
489
490
491
492
493
494
|
# File 'lib/chino_ruby/classes.rb', line 483
def update_repository(repository_id, description, is_active=nil)
check_string(repository_id)
check_string(description)
if is_active.nil?
data = {"description": description}.to_json
else
data = {"description": description, "is_active": is_active}.to_json
end
repo = Repository.new
repo.from_json(put_resource("/repositories/#{repository_id}", data).to_json, true)
repo
end
|