-
Notifications
You must be signed in to change notification settings - Fork 0
API Module: Projects
The Projects module allows you to create, modify, query, or delete Open Build Server source projects.
To access this module, establish a new connection to an Open Build Service instance.
The module itself can be accessed through an OpenBuildServiceAPI::Connection object. In this guide we assume that the object api stores an OpenBuildServiceAPI::Connection.
Creates a new source project.
Arguments:
-
name: name of your project (String) -
meta: the meta definition of your project - leaving it empty lets the library create a default meta which will be used to create that project (StringorNokogiri::XML)
Return Value: OpenBuildServiceAPI::Project when the creation was successful
Possible Exceptions:
-
OpenBuildServiceAPI::ProjectCreationPermissionErrorif the user has no permission to create this project -
OpenBuildServiceAPI::ProjectCreationFailedErrorif the remote Open Build Service API didn't respond with HTTP status200 OK -
OpenBuildServiceAPI::ProjectAlreadyExistsErrorif the project name has already been taken
Example:
# depending on your permission you may only be able to create sub projects of your home project.
# If you're an Admin you will be able to create a project in any namespace.
project = api.projects.create('home:your_username:test123')Lists all available projects in this Open Build Service instance.
Return Value: Array (elements are an object of OpenBuildServiceAPI::Project)
Example:
api.projects.list.each do |project|
puts project.name
endChecks whether a project does already exist.
Arguments:
-
name: name of the project (String)
Return Value: Boolean (true or false)
Example:
if api.projects.exists?('home:test')
puts "I do exist"
else
puts "This project name is still free."
endFinds a project by its name.
Arguments:
-
name: name of the project (String)
Return Value: OpenBuildServiceAPI::Project or nil
Example:
project = api.projects.find('home:test')
puts "#{project.name} has #{project.packages.size} packages."Finds a project by its name or raises an exception if it does not exist.
Arguments:
-
name: name of the project (String)
Return Value: OpenBuildServiceAPI::Project or nil
Possible Exceptions:
-
OpenBuildServiceAPI::ProjectNotFoundErrorif the project does not exist
Example:
begin
project = api.projects.find('home:test')"
puts "#{project.name} has #{project.packages.size} packages."
rescue OpenBuildServiceAPI::ProjectNotFoundError
puts "project does not exist"
end