
Products
********

This part of the Bugzilla API allows you to list the available
products and get information about them.


List Products
=============

Returns a list of the IDs of the products the user can search on.

**Request**

To get a list of product IDs a user can select such as for querying
bugs:

   GET /rest/product_selectable

To get a list of product IDs a user can enter a bug against:

   GET /rest/product_enterable

To get a list of product IDs a user can search or enter bugs against.

   GET /rest/product_accessible

**Response**

   {
     "ids": [
       "2",
       "3",
       "19",
       "1",
       "4"
     ]
   }

+------+-------+----------------------------------------+
| name | type  | description                            |
+======+=======+========================================+
| ids  | array | List of integer product IDs.           |
+------+-------+----------------------------------------+


Get Product
===========

Returns a list of information about the products passed to it.

**Request**

To return information about a specific type of products such as
"accessible", "selectable", or "enterable":

   GET /rest/product?type=accessible

To return information about a specific product by "id" or "name":

   GET /rest/product/(id_or_name)

You can also return information about more than one product by using
the following parameters in your query string:

   GET /rest/product?ids=1&ids=2&ids=3
   GET /rest/product?names=ProductOne&names=Product2

+------------+--------+---------------------------------------------------------------+
| name       | type   | description                                                   |
+============+========+===============================================================+
| id_or_name | mixed  | Integer product ID or product name.                           |
+------------+--------+---------------------------------------------------------------+
| ids        | array  | Product IDs                                                   |
+------------+--------+---------------------------------------------------------------+
| names      | array  | Product names                                                 |
+------------+--------+---------------------------------------------------------------+
| type       | string | The group of products to return. Valid values are             |
+------------+--------+---------------------------------------------------------------+

**Response**

   {
     "products": [
       {
         "id": 1,
         "default_milestone": "---",
         "components": [
           {
             "is_active": true,
             "default_assigned_to": "admin@bugzilla.org",
             "id": 1,
             "sort_key": 0,
             "name": "TestComponent",
             "flag_types": {
               "bug": [
                 {
                   "is_active": true,
                   "grant_group": null,
                   "cc_list": "",
                   "is_requestable": true,
                   "id": 3,
                   "is_multiplicable": true,
                   "name": "needinfo",
                   "request_group": null,
                   "is_requesteeble": true,
                   "sort_key": 0,
                   "description": "needinfo"
                 }
               ],
               "attachment": [
                 {
                   "description": "Review",
                   "is_multiplicable": true,
                   "name": "review",
                   "is_requesteeble": true,
                   "request_group": null,
                   "sort_key": 0,
                   "cc_list": "",
                   "grant_group": null,
                   "is_requestable": true,
                   "id": 2,
                   "is_active": true
                 }
               ]
             },
             "default_qa_contact": "",
             "description": "This is a test component."
           }
         ],
         "is_active": true,
         "classification": "Unclassified",
         "versions": [
           {
             "id": 1,
             "name": "unspecified",
             "is_active": true,
             "sort_key": 0
           }
         ],
         "description": "This is a test product.",
         "has_unconfirmed": true,
         "milestones": [
           {
             "name": "---",
             "is_active": true,
             "sort_key": 0,
             "id": 1
           }
         ],
         "name": "TestProduct"
       }
     ]
   }

"products" (array) Each product object has the following items:

+-------------------+---------+-------------------------------------------------------+
| name              | type    | description                                           |
+===================+=========+=======================================================+
| id                | int     | An integer ID uniquely identifying the product in     |
+-------------------+---------+-------------------------------------------------------+
| name              | string  | The name of the product. This is a unique identifier  |
+-------------------+---------+-------------------------------------------------------+
| description       | string  | A description of the product, which may contain HTML. |
+-------------------+---------+-------------------------------------------------------+
| is_active         | boolean | A boolean indicating if the product is active.        |
+-------------------+---------+-------------------------------------------------------+
| default_milestone | string  | The name of the default milestone for the product.    |
+-------------------+---------+-------------------------------------------------------+
| has_unconfirmed   | boolean | Indicates whether the UNCONFIRMED bug status is       |
+-------------------+---------+-------------------------------------------------------+
| classification    | string  | The classification name for the product.              |
+-------------------+---------+-------------------------------------------------------+
| components        | array   | Each component object has the items described in the  |
+-------------------+---------+-------------------------------------------------------+
| versions          | array   | Each object describes a version, and has the          |
+-------------------+---------+-------------------------------------------------------+
| milestones        | array   | Each object describes a milestone, and has the        |
+-------------------+---------+-------------------------------------------------------+

If the user tries to access a product that is not in the list of
accessible products for the user, or a product that does not exist,
that is silently ignored, and no information about that product is
returned.

Component object:

+---------------------+---------+-----------------------------------------------------+
| name                | type    | description                                         |
+=====================+=========+=====================================================+
| id                  | int     | An integer ID uniquely identifying the component in |
+---------------------+---------+-----------------------------------------------------+
| name                | string  | The name of the component.  This is a unique        |
+---------------------+---------+-----------------------------------------------------+
| description         | string  | A description of the component, which may contain   |
+---------------------+---------+-----------------------------------------------------+
| default_assigned_to | string  | The login name of the user to whom new bugs will be |
+---------------------+---------+-----------------------------------------------------+
| default_qa_contact  | string  | The login name of the user who will be set as the   |
+---------------------+---------+-----------------------------------------------------+
| sort_key            | int     | Components, when displayed in a list, are sorted    |
+---------------------+---------+-----------------------------------------------------+
| is_active           | boolean | A boolean indicating if the component is active.    |
+---------------------+---------+-----------------------------------------------------+
| flag_types          | object  | An object containing two items "bug" and            |
+---------------------+---------+-----------------------------------------------------+

Flagtype object:

+------------------+---------+--------------------------------------------------------+
| name             | type    | description                                            |
+==================+=========+========================================================+
| id               | int     | Returns the ID of the flagtype.                        |
+------------------+---------+--------------------------------------------------------+
| name             | string  | Returns the name of the flagtype.                      |
+------------------+---------+--------------------------------------------------------+
| description      | string  | Returns the description of the flagtype.               |
+------------------+---------+--------------------------------------------------------+
| cc_list          | string  | Returns the concatenated CC list for the flagtype, as  |
+------------------+---------+--------------------------------------------------------+
| sort_key         | int     | Returns the sortkey of the flagtype.                   |
+------------------+---------+--------------------------------------------------------+
| is_active        | boolean | Returns whether the flagtype is active or disabled.    |
+------------------+---------+--------------------------------------------------------+
| is_requestable   | boolean | Returns whether you can request for the given flagtype |
+------------------+---------+--------------------------------------------------------+
| is_requesteeble  | boolean | Returns whether you can ask someone specifically or    |
+------------------+---------+--------------------------------------------------------+
| is_multiplicable | boolean | Returns whether you can have more than one flag for    |
+------------------+---------+--------------------------------------------------------+
| grant_group      | int     | the group ID that is allowed to grant/deny flags of    |
+------------------+---------+--------------------------------------------------------+
| request_group    | int     | The group ID that is allowed to request the flag if    |
+------------------+---------+--------------------------------------------------------+


Create Product
==============

This allows you to create a new product in Bugzilla.

**Request**

   POST /rest/product

   {
     "name" : "AnotherProduct",
     "description" : "Another Product",
     "classification" : "Unclassified",
     "is_open" : false,
     "has_unconfirmed" : false,
     "version" : "unspecified"
   }

Some params must be set, or an error will be thrown. The required
params are marked in bold.

+-------------------+---------+-------------------------------------------------------+
| name              | type    | description                                           |
+===================+=========+=======================================================+
| **name**          | string  | The name of this product. Must be globally unique     |
+-------------------+---------+-------------------------------------------------------+
| **description**   | string  | A description for this product. Allows some simple    |
+-------------------+---------+-------------------------------------------------------+
| **version**       | string  | The default version for this product.                 |
+-------------------+---------+-------------------------------------------------------+
| has_unconfirmed   | boolean | Allow the UNCONFIRMED status to be set on bugs in     |
+-------------------+---------+-------------------------------------------------------+
| classification    | string  | The name of the Classification which contains this    |
+-------------------+---------+-------------------------------------------------------+
| default_milestone | string  | The default milestone for this product. Default       |
+-------------------+---------+-------------------------------------------------------+
| is_open           | boolean | "true" if the product is currently allowing bugs to   |
+-------------------+---------+-------------------------------------------------------+
| create_series     | boolean | "true" if you want series for New Charts to be        |
+-------------------+---------+-------------------------------------------------------+

**Response**

   {
     "id": 20
   }

Returns an object with the following items:

+------+------+---------------------------------------+
| name | type | description                           |
+======+======+=======================================+
| id   | int  | ID of the newly-filed product.        |
+------+------+---------------------------------------+


Update Product
==============

This allows you to update a product in Bugzilla.

**Request**

   PUT /rest/product/(id_or_name)

You can edit a single product by passing the ID or name of the product
in the URL. To edit more than one product, you can specify addition
IDs or product names using the "ids" or "names" parameters
respectively.

   {
     "ids" : [123],
     "name" : "BarName",
     "has_unconfirmed" : false
   }

One of the below must be specified.

+----------------+-------+------------------------------------------------------------+
| name           | type  | description                                                |
+================+=======+============================================================+
| **id_or_name** | mixed | Integer product ID or name.                                |
+----------------+-------+------------------------------------------------------------+
| **ids**        | array | Numeric IDs of the products that you wish to update.       |
+----------------+-------+------------------------------------------------------------+
| **names**      | array | Names of the products that you wish to update.             |
+----------------+-------+------------------------------------------------------------+

The following parameters specify the new values you want to set for
the product(s) you are updating.

+-------------------+---------+-------------------------------------------------------+
| name              | type    | description                                           |
+===================+=========+=======================================================+
| name              | string  | A new name for this product. If you try to set this   |
+-------------------+---------+-------------------------------------------------------+
| default_milestone | string  | When a new bug is filed, what milestone does it get   |
+-------------------+---------+-------------------------------------------------------+
| description       | string  | Update the long description for these products to     |
+-------------------+---------+-------------------------------------------------------+
| has_unconfirmed   | boolean | Allow the UNCONFIRMED status to be set on bugs in     |
+-------------------+---------+-------------------------------------------------------+
| is_open           | boolean | "true" if the product is currently allowing bugs to   |
+-------------------+---------+-------------------------------------------------------+

**Response**

   {
      "products" : [
         {
            "id" : 123,
            "changes" : {
               "name" : {
                  "removed" : "FooName",
                  "added" : "BarName"
               },
               "has_unconfirmed" : {
                  "removed" : "1",
                  "added" : "0"
               }
            }
         }
      ]
   }

"products" (array) Product change objects containing the following
items:

+---------+--------+------------------------------------------------------------------+
| name    | type   | description                                                      |
+=========+========+==================================================================+
| id      | int    | The ID of the product that was updated.                          |
+---------+--------+------------------------------------------------------------------+
| changes | object | The changes that were actually done on this product. The keys    |
+---------+--------+------------------------------------------------------------------+

Booleans will be represented with the strings '1' and '0' for changed
values as they are stored as strings in the database currently.

======================================================================

This documentation undoubtedly has bugs; if you find some, please file
them here.
