Page tree
Skip to end of metadata
Go to start of metadata

On this page, you can find public REST services of Inventory Plugin for JIRA.

 

Below, you can find sample REST service calls via CURL

curl -D- -u user:password -X [GET|POST|PUT|DELETE] -H "Content-Type: application/json" 
http://path.to.jira.instance/rest/jip-api/1.0/[attribute|form|inventory][|/id|/list|/filter].json

OR just call REST services with another method with a request header "Authorization Basic Base64Encoded(user:password)" 

e.g. :"Authorization Basic YWRtaW46YWRtaW4="

Attribute REST Services

Listing all attributes

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/attribute/list.json
  • Method : GET
  • Response:

     Click here to expand...
    [
    {
    "attributeName": "CPU",
    "id": 10
     },
    {
    "attributeName": "Computer Name",
    "id": 8
     },
    {
    "attributeName": "Date of Purchase",
    "id": 17
     },
    {
    "attributeName": "First Name",
    "id": 1
     },
    {
    "attributeName": "Gender",
    "id": 4,
    "values": [
    {
    "id": 4,
    "sortOrder": 0,
    "attributeValue": "Male"
     },
    {
    "id": 5,
    "sortOrder": 0,
    "attributeValue": "Female"
     }
    ]
    },
    {
    "attributeName": "IP",
    "id": 6
     },
    {
    "attributeName": "JIRA User",
    "id": 9
     },
    {
    "attributeName": "Keyboard",
    "id": 14,
    "values": [
    {
    "id": 6,
    "sortOrder": 0,
    "attributeValue": "Standard Windows Q"
     },
    {
    "id": 7,
    "sortOrder": 1,
    "attributeValue": "Wireless"
     },
    {
    "id": 8,
    "sortOrder": 2,
    "attributeValue": "Multimedia"
     }
    ]
    },
    {
    "attributeName": "Last Name",
    "id": 2
     },
    {
    "attributeName": "License Key",
    "id": 12
     },
    {
    "attributeName": "MAC Address",
    "id": 16
     },
    {
    "attributeName": "Memory",
    "id": 11
     },
    {
    "attributeName": "Model",
    "id": 18
     },
    {
    "attributeName": "Monitor",
    "id": 13
     },
    {
    "attributeName": "Mouse",
    "id": 15,
    "values": [
    {
    "id": 9,
    "sortOrder": 0,
    "attributeValue": "Standard Mouse"
     },
    {
    "id": 10,
    "sortOrder": 1,
    "attributeValue": "Wireless Mouse"
     },
    {
    "id": 11,
    "sortOrder": 2,
    "attributeValue": "Optical Mouse"
     },
    {
    "id": 12,
    "sortOrder": 3,
    "attributeValue": "Bluetooth Mouse"
     }
    ]
    },
    {
    "attributeName": "Organization",
    "id": 3,
    "values": [
    {
    "id": 3,
    "sortOrder": 0,
    "attributeValue": "Customer Care"
     },
    {
    "id": 2,
    "sortOrder": 0,
    "attributeValue": "System Department"
     },
    {
    "id": 1,
    "sortOrder": 0,
    "attributeValue": "Software Department"
     }
    ]
    },
    {
    "attributeName": "Serial Number",
    "id": 7
     },
    {
    "attributeName": "Server Name",
    "id": 5
     },
    {
    "attributeName": "Storage Type",
    "id": 19,
    "values": [
    {
    "id": 13,
    "sortOrder": 0,
    "attributeValue": "FATA"
     },
    {
    "id": 14,
    "sortOrder": 1,
    "attributeValue": "SATA"
     },
    {
    "id": 15,
    "sortOrder": 2,
    "attributeValue": "SSD"
     }
    ]
    }
    ]

List single attribute

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/attribute/[attributeId].json
  • Method : POST
  • Response

    {
      "attributeName": "Organization",
      "attributeType": "ListBox",
      "id": 3,
      "values": [
        {
          "id": 3,
          "sortOrder": 0,
          "attributeValue": "Customer Care"
        },
        {
          "id": 2,
          "sortOrder": 0,
          "attributeValue": "System Department"
        },
        {
          "id": 1,
          "sortOrder": 0,
          "attributeValue": "Software Department"
        }
      ]
    }
  • Possible error response:

    {
      success:
      false,
      message:
      "Could not find form with id:[id]"
    }

New attribute

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/attribute.json
  • Method : POST
  • Request:

    {
      "attributeName": "Storage Type",
      "attributeType": "DropdownList",
      "values": [
        {
          "sortOrder": 0,
          "attributeValue": "FATA"
        },
        {
          "sortOrder": 1,
          "attributeValue": "SATA"
        },
        {
          "sortOrder": 2,
          "attributeValue": "SSD"
        }
      ]
    }
  • OR for non-multi valued attributes

    {
      "attributeName": "Test Text Sample Attribute",
      "attributeType": "Test Text",
      "values": [ ]
    }
  • Success message:

    {
        "success": true,
        "message": "Attribute[Test Text Sample Attribute] created successfully"
    }
  • Possible failure messages :

    {
      "success": false,
      "message": "[attributeValue] should not be empty"
    }
    
    {
      "success": false,
      "message": "Please define at least one attribute value for type [DropdownList]"
    }

Update attribute

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/attribute/[attributeId].json
  • Method : PUT
  • Request for multi value types (e.g. DropdownList) request:

    {
      "attributeName": "Storage Type",
      "attributeType": "DropdownList",
      "values": [
        {
          "sortOrder": 0,
          "attributeValue": "FATA2"
        },
        {
          "sortOrder": 1,
          "attributeValue": "SATA2"
        },
        {
          "sortOrder": 2,
          "attributeValue": "SSD2"
        }
      ]
    }
  • or for single value for the attributes that have not multiple values (e.g. Textbox)

    {
        "attributeName": "CPU"
    }
  • Success message:

    {
      "success": true,
      "message": "Attribute[89] updated successfully"
    }
  • Possible failure messages :

    {
      "success": false,
      "message": "attributeType should be one of [DropdownList,ListBox,ListBoxMultiple,Text,TextArea,RadioButtonList,CheckboxList,DatePicker,DatetimePicker,UserPicker]"
    }
    {
      "success": false,
      "message": "attributeName or attributeType should not be empty"
    }
    {
      "success": false,
      "message": "Could not find attribute with id:190"
    }

Delete attribute

  • Possible failure message:

    {
      "success": false
      "message": "Attribute[attributeId] could not be found"
    }

Form REST Services

Listing all forms

 

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/form/list.json
  • Method : GET
  • Sample Response

     Click here to expand sample response...
    [
    {
    "id": 2,
    "formName": "Servers",
    "attributes": [
    {
    "id": 8,
    "attribute": {
    "attributeName": "Serial Number",
    "attributeType": "Text",
    "id": 7
     },
    "sortOrder": 0
     },
    {
    "id": 7,
    "attribute": {
    "attributeName": "IP",
    "attributeType": "Text",
    "id": 6
     },
    "sortOrder": 0
     },
    {
    "id": 6,
    "attribute": {
    "attributeName": "Server Name",
    "attributeType": "Text",
    "id": 5
     },
    "sortOrder": 0
     }
    ]
    },
    {
    "id": 3,
    "formName": "Personal Computers",
    "attributes": [
    {
    "id": 18,
    "attribute": {
    "attributeName": "Computer Name",
    "attributeType": "Text",
    "id": 8
     },
    "sortOrder": 0
     },
    {
    "id": 12,
    "attribute": {
    "attributeName": "First Name",
    "attributeType": "Text",
    "id": 1
     },
    "sortOrder": 1
     },
    {
    "id": 13,
    "attribute": {
    "attributeName": "Last Name",
    "attributeType": "Text",
    "id": 2
     },
    "sortOrder": 2
     },
    {
    "id": 16,
    "attribute": {
    "attributeName": "Serial Number",
    "attributeType": "Text",
    "id": 7
     },
    "sortOrder": 3
     },
    {
    "id": 20,
    "attribute": {
    "attributeName": "License Key",
    "attributeType": "Text",
    "id": 12
     },
    "sortOrder": 4
     },
    {
    "id": 17,
    "attribute": {
    "attributeName": "IP",
    "attributeType": "Text",
    "id": 6
     },
    "sortOrder": 5
     },
    {
    "id": 15,
    "attribute": {
    "attributeName": "Organization",
    "attributeType": "ListBox",
    "id": 3,
    "values": [
    {
    "id": 3,
    "sortOrder": 0,
    "attributeValue": "Customer Care"
     },
    {
    "id": 2,
    "sortOrder": 0,
    "attributeValue": "System Department"
     },
    {
    "id": 1,
    "sortOrder": 0,
    "attributeValue": "Software Department"
     }
    ]
    },
    "sortOrder": 6
     },
    {
    "id": 19,
    "attribute": {
    "attributeName": "JIRA User",
    "attributeType": "UserPicker",
    "id": 9
     },
    "sortOrder": 7
     },
    {
    "id": 21,
    "attribute": {
    "attributeName": "CPU",
    "attributeType": "Text",
    "id": 10
     },
    "sortOrder": 8
     },
    {
    "id": 22,
    "attribute": {
    "attributeName": "Memory",
    "attributeType": "Text",
    "id": 11
     },
    "sortOrder": 9
     },
    {
    "id": 23,
    "attribute": {
    "attributeName": "Keyboard",
    "attributeType": "ListBox",
    "id": 14,
    "values": [
    {
    "id": 6,
    "sortOrder": 0,
    "attributeValue": "Standard Windows Q"
     },
    {
    "id": 7,
    "sortOrder": 1,
    "attributeValue": "Wireless"
     },
    {
    "id": 8,
    "sortOrder": 2,
    "attributeValue": "Multimedia"
     }
    ]
    },
    "sortOrder": 10
     },
    {
    "id": 24,
    "attribute": {
    "attributeName": "Mouse",
    "attributeType": "ListBox",
    "id": 15,
    "values": [
    {
    "id": 9,
    "sortOrder": 0,
    "attributeValue": "Standard Mouse"
     },
    {
    "id": 10,
    "sortOrder": 1,
    "attributeValue": "Wireless Mouse"
     },
    {
    "id": 11,
    "sortOrder": 2,
    "attributeValue": "Optical Mouse"
     },
    {
    "id": 12,
    "sortOrder": 3,
    "attributeValue": "Bluetooth Mouse"
     }
    ]
    },
    "sortOrder": 11
     },
    {
    "id": 25,
    "attribute": {
    "attributeName": "Monitor",
    "attributeType": "Text",
    "id": 13
     },
    "sortOrder": 12
     }
    ]
    }
    ]

List single form

 

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/form/[formId].json

  • Method : GET
  • Response:

    {
      "id": 1,
      "name": "Alpha Tomcat Server",
      "formId": 2,
      "sortOrder": 0,
      "attributes": [
        {
          "id": 1,
          "attribute": {
            "attributeName": "Server Name",
            "attributeType": "Text",
            "id": 5
          },
          "attributeValue": "cyrus"
        },
        {
          "id": 2,
          "attribute": {
            "attributeName": "IP",
            "attributeType": "Text",
            "id": 6
          },
          "attributeValue": "10.10.13.21"
        },
        {
          "id": 3,
          "attribute": {
            "attributeName": "Serial Number",
            "attributeType": "Text",
            "id": 7
          },
          "attributeValue": "1254-4432-3455-6642"
        }
      ]
    }
  • Possible failure message:

    {
      "success":false,
      "message":"Could not find form with id:[formId]"
    }

New form

 

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/form.json
  • Method : POST
  • Sample Request:

    {
      "formName": "My new form name",
      "attributes": [
        {"attributeName": "Computer Name"},
        {"attributeName": "First Name"},
        {"attributeName": "Last Name"},
        {"attributeName": "Serial Number"},
        {"attributeName": "License Key"},
        {"attributeName": "IP"},
        {"attributeName": "Organization"},
        {"attributeName": "JIRA User"},
        {"attributeName": "CPU"},
        {"attributeName": "Memory"},
        {"attributeName": "Keyboard"},
        {"attributeName": "Mouse"},
        {"attributeName": "Monitor"}
      ]
    }
  • Possible failure messages:

    {
      "success": false
      "message": "[formName] should not be empty"
    }
    {
      "success": false
      "message": "You may define at least one form attribute"
    }
    {
      "success": false
      "message": "Could not find form with id:formId"
    }

Update form

  • Success message

    {
      "success": true,
      "message": "Form[formId] updated successfully"
    }
  • Failure messages:

    {
      "success": false
      "message": "[formName] should not be empty"
    }
    {
      "success": false
      "message": "Could not find form with id:[formId]"
    }

Delete form

Inventory REST Services

Listing all inventories

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/inventory/list.json
  • Method : GET
  • Sample Response

    [
      {
        "id": 12,
        "name": "Alpha Database Server",
        "formId": 2,
        "sortOrder": 0,
        "attributes": [
          {
            "id": 120,
            "attribute": {
              "attributeName": "Serial Number",
              "attributeType": "Text",
              "id": 7
            },
            "attributeValue": "3243-34343-434-2344"
          },
          {
            "id": 121,
            "attribute": {
              "attributeName": "IP",
              "attributeType": "Text",
              "id": 6
            },
            "attributeValue": "10.10.13.24"
          },
          {
            "id": 122,
            "attribute": {
              "attributeName": "Server Name",
              "attributeType": "Text",
              "id": 5
            },
            "attributeValue": "gollum"
          }
        ]
      },
      {
        ...
      }
    ]

List single inventory

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/inventory/[inventoryId].json
  • Method : GET
  • Sample Response:

    {
      "id": 1,
      "name": "Alpha Tomcat Server",
      "formId": 2,
      "sortOrder": 0,
      "attributes": [
        {
          "id": 1,
          "attribute": {
            "attributeName": "Server Name",
            "attributeType": "Text",
            "id": 5
          },
          "attributeValue": "cyrus"
        },
        {
          "id": 2,
          "attribute": {
            "attributeName": "IP",
            "attributeType": "Text",
            "id": 6
          },
          "attributeValue": "10.10.13.21"
        },
        {
          "id": 3,
          "attribute": {
            "attributeName": "Serial Number",
            "attributeType": "Text",
            "id": 7
          },
          "attributeValue": "1254-4432-3455-6642"
        }
      ]
    }
  • Failure message:

    {
      "success": false,
      "message": "Could not find inventory with id:[id]
    }

Filtering inventory

  • Filtering by only form:

    {
      "formId": 3
    }
  • Filtering by inventory name:

    {
      "name": "Kevin's computer"
    }
  • Filtering by form and attribute :

    {
      "formId": 3,
      "attributeId": 15,
      "attributeValue": "Optical Mouse"
    }
  • Possible failure message:

    {
      "success": false,
      "message": "[formId] or [attributeId] should be specified"
    }

 


New inventory

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/inventory.json
  • Method : POST
  • Request:

    {
      "formId": 7,
      "name": "Test Inventory",
      "attributes": [
        {
          "attributeId": 8,
          "attributeValue": "My computer name"
        },
        {
          "attributeId": 19,
          "attributeValue": "FATA"
        },
        {
          "attributeId": 7,
          "attributeValue": "My Serial Number"
        }
      ]
    }

    Success response:

    {
        "success": true,
        "message": "Inventory[New Asset] created successfully",
        "id": 154,
        "name": "New Asset"
    }
  • Possible failure messages :

    {
      success: false,
      message: "[name] should not be empty"
    }
    {
      success: false,
      message: "[formId] should not be empty"
    }
    {
      success: false,
      message: "Form[formId] could not be found"
    }
    {
      success: false,
      message: "Form[formName] does not have an attribute with id:[attributeId]"
    }
    {
      "success": false,
      "message": "Attribute[attributeName] does not have a defined value[attributeValue]"
    }
    {
      "success": false,
      "message": "You may define at least one inventory attribute"
    }

Update inventory

  • URL: http://localhost:2990/jira/rest/jip-api/1.0/inventory/[inventoryId].json
  • Method : PUT

  • Request:

    {
      "id": 22,
      "formId": 7,
      "name": "Updated Storage",
      "attributes": [
        {
          "attributeId": 19,
          "attributeValue": "SATA"
        },
        {
          "attributeId": 8,
          "attributeValue": "Updated computer name"
        },
        {
          "attributeId": 7,
          "attributeValue": "Updated Serial Number"
        }
      ]
    }

    "name" is required, if you won't send it, asset name will be cleared. Attributes are optional. You can send only the attributes you need to update.

  • Success message:

    {
        "success": true,
        "message": "Inventory[154] updated successfully",
        "id": 154,
        "name": "New Asset"
    }
  • Possible failure messages:

    {
      "success": false,
      "message": "Could not find inventory with id:[id]"
    }
    {
      "success": false,
      "message": "Form[formName] does not have an attribute with id:[attributeId]"
    }

Delete inventory

 

  • No labels