Module: NexusCli::RepositoryActions
Overview
Instance Method Summary collapse
-
#add_to_group_repository(group_id, repository_to_add_id) ⇒ Boolean
Adds the given [repository_to_add_id] to the given group repository, [group_id].
-
#create_group_repository(name, id, provider) ⇒ Boolean
Creates a group repository with the given name.
-
#create_repository(name, proxy, url, id, policy, provider) ⇒ Boolean
Creates a repository that the Nexus uses to hold artifacts.
-
#delete_group_repository(group_id) ⇒ Boolean
Deletes the given group repository.
-
#delete_repository(name) ⇒ Boolean
Deletes the given repository.
-
#get_group_repository(group_id) ⇒ String
Gets information about the given group repository with the given [group_id].
-
#get_repository_info(name) ⇒ String
Find information about the repository with the given [name].
-
#remove_from_group_repository(group_id, repository_to_remove_id) ⇒ Boolean
Removes the given [repository_to_remove_id] from the group repository, [group_id].
-
#repository_in_group?(group_id, repository_to_check) ⇒ Boolean
Checks if a the given [repository_to_check] is a member of the given group repository - [group_ip].
Instance Method Details
#add_to_group_repository(group_id, repository_to_add_id) ⇒ Boolean
Adds the given [repository_to_add_id] to the given group repository, [group_id].
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 132 def add_to_group_repository(group_id, repository_to_add_id) raise RepositoryInGroupException if repository_in_group?(group_id, repository_to_add_id) response = nexus.put(nexus_url("service/local/repo_groups/#{sanitize_for_id(group_id)}"), :body => create_add_to_group_repository_json(group_id, repository_to_add_id), :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 200 return true when 400 raise RepositoryNotFoundException else raise UnexpectedStatusCodeException.new(response.status) end end |
#create_group_repository(name, id, provider) ⇒ Boolean
Creates a group repository with the given name.
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 81 def create_group_repository(name, id, provider) response = nexus.post(nexus_url("service/local/repo_groups"), :body => create_group_repository_json(name, id, provider), :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 201 return true when 400 raise CreateRepsitoryException.new(response.content) else raise UnexpectedStatusCodeException.new(response.status) end end |
#create_repository(name, proxy, url, id, policy, provider) ⇒ Boolean
Creates a repository that the Nexus uses to hold artifacts.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 17 def create_repository(name, proxy, url, id, policy, provider) json = if proxy create_proxy_repository_json(name, url, id, policy, provider) else create_hosted_repository_json(name, id, policy, provider) end response = nexus.post(nexus_url("service/local/repositories"), :body => json, :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 201 return true when 400 raise CreateRepsitoryException.new(response.content) else raise UnexpectedStatusCodeException.new(response.status) end end |
#delete_group_repository(group_id) ⇒ Boolean
Deletes the given group repository.
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 168 def delete_group_repository(group_id) response = nexus.delete(nexus_url("service/local/repo_groups/#{sanitize_for_id(group_id)}")) case response.status when 204 return true when 404 raise RepositoryNotFoundException else raise UnexpectedStatusCodeException.new(response.status) end end |
#delete_repository(name) ⇒ Boolean
Deletes the given repository
into an id.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 40 def delete_repository(name) response = nexus.delete(nexus_url("service/local/repositories/#{sanitize_for_id(name)}")) case response.status when 204 return true when 404 raise RepositoryDoesNotExistException else raise UnexpectedStatusCodeException.new(response.status) end end |
#get_group_repository(group_id) ⇒ String
Gets information about the given group repository with the given [group_id].
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 99 def get_group_repository(group_id) response = nexus.get(nexus_url("service/local/repo_groups/#{sanitize_for_id(group_id)}"), :header => DEFAULT_ACCEPT_HEADER) case response.status when 200 return response.content when 404 raise RepositoryNotFoundException else raise UnexpectedStatusCodeException.new(response.status) end end |
#get_repository_info(name) ⇒ String
Find information about the repository with the given [name].
into an id.
repository.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 60 def get_repository_info(name) response = nexus.get(nexus_url("service/local/repositories/#{sanitize_for_id(name)}"), :header => DEFAULT_ACCEPT_HEADER) case response.status when 200 return response.content when 404 raise RepositoryNotFoundException when 503 raise CouldNotConnectToNexusException else raise UnexpectedStatusCodeException.new(response.status) end end |
#remove_from_group_repository(group_id, repository_to_remove_id) ⇒ Boolean
Removes the given [repository_to_remove_id] from the group repository, [group_id].
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 152 def remove_from_group_repository(group_id, repository_to_remove_id) raise RepositoryNotInGroupException unless repository_in_group?(group_id, repository_to_remove_id) response = nexus.put(nexus_url("service/local/repo_groups/#{sanitize_for_id(group_id)}"), :body => create_remove_from_group_repository_json(group_id, repository_to_remove_id), :header => DEFAULT_CONTENT_TYPE_HEADER) case response.status when 200 return true else raise UnexpectedStatusCodeException.new(response.status) end end |
#repository_in_group?(group_id, repository_to_check) ⇒ Boolean
Checks if a the given [repository_to_check] is a member of the given group repository - [group_ip].
118 119 120 121 122 123 |
# File 'lib/nexus_cli/mixins/repository_actions.rb', line 118 def repository_in_group?(group_id, repository_to_check) group_repository = JSON.parse(get_group_repository(group_id)) repositories_in_group = group_repository["data"]["repositories"] repositories_in_group.find{|repository| repository["id"] == sanitize_for_id(repository_to_check)} end |