Giter VIP home page Giter VIP logo

bz.js's Introduction

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 lastest bz-.js from the root directory.

Development

  1. git clone [email protected]:canuckistani/bz.js.git
  2. cd ./bz.js
  3. npm install

Builds

  1. gulp - this will build node and browser files from the ./src directory. The node main entry now points to ./build/node/index.

Tests

Some tests are included. If you want to run the browser tests you need to copy the file config-test.json-sample in the test/browser/files directory to a file called config-test.json in the same directory, then fill in the placeholders with your bugzilla credentials.

Usage

var bugzilla = bz.createClient();

bugzilla.getBug(678223, function(error, bug) {
  if (!error) {
    alert(bug.summary);
  }
});

API

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

var bugzilla = bz.createClient({
  url: "https://api-dev.bugzilla.mozilla.org/rest/",
  username: '[email protected]',
  password: 'secret',
  timeout: 30000
});
var bugzilla = bz.createClient({
  url: "https://api-dev.bugzilla.mozilla.org/rest/",
  api_key: "23dsf3423s",
  timeout: 30000
});

See docs on the login endpoint.

Client methods

Each method takes a callback that takes an error message (if any kind of error occurs) as its first argument, and the expected return data as its second.

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

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

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

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

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

bugComments(id, callback)
retrieves the comments for a bug.

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

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

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

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

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

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

updateAttachment(attachId, attachment, callback)
updates the attachment.

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

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

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

getConfiguration(options, callback)
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.

bz.js's People

Contributors

harthur avatar coyotebringsfire avatar graememcc avatar jasonlaster avatar kevingrandon avatar pike avatar blakmatrix avatar lightsofapollo avatar jdm avatar kwierso avatar

Watchers

Cody Foss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.