1.0.1 • Published 7 years ago

@eliperelman/bz v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
7 years ago

bz.js!

Build Status

A JavaScript wrapper for the Bugzilla REST API.

Warning!!!

Although Travis tests are now working, test coverage is far from complete. Please report issues especially if you find problems running bz.js in the browser. Worst case scenario, please revert to 0.3 as it still basically works.

Install

For node install with npm:

npm install bz

and use with var bz = require("bz")

For the browser, download the latest from https://unpkg.com/bz

Development

  1. git clone git@github.com:canuckistani/bz.js.git
  2. cd ./bz.js
  3. npm install

Builds

  • npm run build - this will build node and browser files from the ./src directory. The node main entry points to ./build.

Tests

Some tests are included. If you want to run the tests, you can do so with npm test.

Usage

var bugzilla = bz.createClient();

bugzilla
  .getBug(678223)
  .then(bug => {
    console.log(bug.summary);
  });

API

bz.createClient(options) creates a new Bugzilla API client, optionally takes options like the REST API url, username + password or apiKey:

var bugzilla = bz.createClient({
  url: 'https://api-dev.bugzilla.mozilla.org/rest/',
  username: 'bugs@bugmail.com',
  password: 'secret'
});
var bugzilla = bz.createClient({
  url: 'https://api-dev.bugzilla.mozilla.org/rest/',
  apiKey: '23dsf3423s',
  timeout: 30000
});

See docs on the login endpoint.

Client methods

Each method returns a Promise so you can await on the data or catch any errors.

getBug(id)
retrieves a bug given a bug id.

searchBugs(searchParams)
searches with given search parameters and fetches an array of bugs.

countBugs(searchParams)
searches with given search parameters and gets a integer count of bugs matching that query. this is not supported currently.

createBug(bug)
creates a bug and returns the id of the newly created bug.

updateBug(id, bug)
updates a bug with new bug info.

bugComments(id)
retrieves the comments for a bug.

addComment(id, comment)
adds a comment to a bug.

bugHistory(id)
retrieves array of changes for a bug.

bugFlags(id)
retrieves array of flags for a bug.

bugAttachments(id)
retrieves array of attachments for a bug.

createAttachment(bugId, attachment)
creates an attachment on a bug, and returns the id of the newly created attachment.

getAttachment(attachId)
gets an attachment given an attachment id.

updateAttachment(attachId, attachment)
updates the attachment.

searchUsers(match)
searches for users by string, matching against users' names or real names.

getUser(userId)
retrieves a user given a user id.

getSuggestedReviewers(id)
retrieves a list of suggested reviewers for a bug.

getConfiguration(options)
gets the configuration of this Bugzilla server. Note: this only works currently against Mozilla's production instance, the bugzilla 5.0 instance running on landfill has no equivalent call that can be run from the browser due to a lack of CORS headers.

1.0.1

7 years ago

1.0.0

7 years ago