CodebaseApi
A gem to interact with the Codebase API.
Installation
Add this line to your application's Gemfile:
gem 'codebase_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install codebase_api
Changelog
0.1.2
- Fixed JSON parsing error when viewing files
0.1.1
- Fixed issue when using the gem with non Rails apps
- Output false when 404
0.1.0
- Public release
Usage
The Codebase API requires authentication using your account name & username along with your API Key.
In a Rails app, create a file called config/initializers/codebase.rb
and fill it with this info (changing it for your account, etc)
CodebaseApi.account_user = "account/user"
CodebaseApi.api_key = "apikey"
Commands
The CodebaseApi gem is built to access all the Codebase API functions. Below are a list of commands currently supported.
Projects
All projects
CodebaseApi::Project.all
Shows a specific project
CodebaseApi::Project.view("my-cool-project")
Create a new project
CodebaseApi::Project.create("a new project")
Project Groups
All project groups
CodebaseApi::ProjectGroup.all
Project Users
All users assigned to a project
CodebaseApi::ProjectUser.all("my-cool-project")
Assign users to a project
CodebaseApi::ProjectUser.assign("my-cool-project", [{:id => 123}, {:id => 321}])
Repositories
All repositories for a project
CodebaseApi::Repository.all("my-cool-project")
View a specified repository
CodebaseApi::Repository.show("my-cool-project", "test-repo")
Create a repository for a project
The types of repository are Git (git), Subversion (svn), Mercurial (hg) and Bazaar (bzr).
CodebaseApi::Repository.create("my-cool-project", "new-repo-name", "git")
Commits
Show a list of commits for a specific ref (short or long)
CodebaseApi::Commit.show("my-cool-project", "test-repo", "abc123abc")
Show a list of commits for a specific ref (short or long) for a path
CodebaseApi::Commit.show_path("my-cool-project", "test-repo", "abc123abc", "spec/features/admin_spec.rb")
Deployments
Create a deployment for a project & repository
CodebaseApi::Deployment.create("my-cool-project", "test-repo", "branch", "revision", "environment", "servers")
Hooks
Show the hooks for a project & repository
CodebaseApi::Hook.all("my-cool-project", "test-repo")
Create a hook for a project & repository
By default the username and password are nil
CodebaseApi::Hook.create("my-cool-project", "test-repo", "url", "username", "password")
Tickets
All tickets for a project
CodebaseApi::Ticket.all("my-cool-project")
Search all tickets in a project
CodebaseApi::Ticket.search("my-cool-project", "query")
Create a new ticket for a project
CodebaseApi::Ticket.create("my-cool-project", "ticket title", "ticket description")
Show all the notes for a ticket
CodebaseApi::Ticket.show("my-cool-project", ticket_id)
Show a specific ticket note
CodebaseApi::Ticket.show_note("my-cool-project", ticket_id, note_id)
Update a ticket
Unfortunately these are required otherwise it will set them to nil time_added, status_id, priority_id, category_id, assignee_id. To change the name of the ticket, change the summary.
CodebaseApi::Ticket.update("my-cool-project", ticket_id, "content", time_added=nil, status_id=nil, priority_id=nil, category_id=nil, assignee_id=nil, summary=nil)
Show all ticket statuses for a project
CodebaseApi::Ticket.statuses("my-cool-project")
Show all ticket priorities for a project
CodebaseApi::Ticket.priorities("my-cool-project")
Show all ticket categories for a project
CodebaseApi::Ticket.categories("my-cool-project")
Show all ticket milestones for a project
CodebaseApi::Ticket.milestones("my-cool-project")
Show all watchers of a ticket for a project
CodebaseApi::Ticket.watchers("my-cool-project", ticket_id)
Wiki
All the pages in the wiki for a project
CodebaseApi::Wiki.all("my-cool-project")
Show a specific page in the wiki for a project
CodebaseApi::Wiki.show("my-cool-project", "page-name")
Public Keys
All public keys for a user
CodebaseApi::PublicKey.all("username")
All deployment keys for a project
CodebaseApi::PublicKey.deploy_keys("my-cool-project")
Create a new public key for a user
CodebaseApi::PublicKey.create("username", "description", "key")
Create a deployment key for a project
CodebaseApi::PublicKey.create_deployment("project", "description", "key")
Users
All users
CodebaseApi::User.all
All user roles
CodebaseApi::User.roles
Create a new user
CodebaseApi::User.create("first name", "last name", "email address", role_id)
Discussions
All discussions for a project
CodebaseApi::Discussion.all("my-cool-project")
Show all the categories for discussions in a project
CodebaseApi::Discussion.categories("my-cool-project")
Show a specific discussion for a project
CodebaseApi::Discussion.show("my-cool-project", "test-discussion")
Create a new discussion for a project
CodebaseApi::Discussion.create("my-cool-project", "discussion title", "discussion content")
Update a discussion for a project
CodebaseApi::Discussion.update("my-cool-project", "test-discussion", "discussion content")
Time Sessions
All time sessions for a project
CodebaseApi::TimeSession.all("my-cool-project")
Show time sessions added today for a project
CodebaseApi::TimeSession.today("my-cool-project")
Show time sessions added this week for a project
CodebaseApi::TimeSession.this_week("my-cool-project")
Show time sessions added this month for a project
CodebaseApi::TimeSession.this_month("my-cool-project")
Create a new time session for a project
CodebaseApi::TimeSession.create("my-cool-project", "message", time)
Show an existing time session for a project
CodebaseApi::TimeSession.show("my-cool-project", 123)
Update an existing time session for a project
CodebaseApi::TimeSession.update("my-cool-project", 123, "message", time)
Delete a time session for a project
CodebaseApi::TimeSession.delete("my-cool-project", 1234)
Contributing
Fork this project, make any changes and create a pull request :)