Extender for JIRA

 

About plugin

Plugin add new REST API endpoint into JIRA and allows JIRA administrators to execute all REST API on behalf of another user.

New endpoints gives you ability to:

  • get all JQL filters from JIRA
  • get all JQL filters for specific user
  • bulk activate users
  • bulk deactivate users
  • bulk delete projects
  • manage custom field values
  • add/delete/view users properties
  • set Project Lead
  • get all Screens from JIRA (Screen Id, Screen Name and Screen Tabs Name, Id and Position)

 

Download Add-on from Atlassian Marketplace – Extender for JIRA

 

 

Run REST API on behalf of another user.

  Available for JIRA administrator

How it’s works?, it’s simple, add into REST API request new header parameter contextUser.

 

  • POSTMAN Example
  • CURL Example

1. Use in authorization section a user with administrator privileges

2. In context section add new header contextUser. Enter in value another user name, for example i used user named user

3. Set body for specific REST and click Send

4. Comment was added to issue for user user. Response body looks like this:

{
    "self": "http://localhost:2990/jira/rest/api/2/issue/10000/comment/10125",
    "id": "10125",
    "author": {
        "self": "http://localhost:2990/jira/rest/api/2/user?username=user",
        "name": "user",
        "key": "user",
        ...
    },
    "body": "REST API Extender works good :)",
    "updateAuthor": {
        "self": "http://localhost:2990/jira/rest/api/2/user?username=user",
        "name": "user",
        "key": "user",
        "emailAddress": "user@user.user",
        ...
    },
    "created": "2017-08-04T20:50:23.351+0200",
    "updated": "2017-08-04T20:50:23.351+0200"
}

and into JIRA you can see this

1. Create CURL command (admin credential, new header contextUser set to user) and run it.

2. Response in terminal

3. JIRA Preview

 

Manage custom fields values

  Available for JIRA administrator

 

Get all custom fields informations

{JIRA_URL}/rest/extender/1.0/customField/all

Example response

{
   "customFields":[
      {
         "name":"Checkboxes",
         "id":"10000",
         "type":"Checkboxes",
         "key":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes"
      },
      {
         "name":"Radio Buttons",
         "id":"10001",
         "type":"Radio Buttons",
         "key":"com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons"
      },
      {
         "name":"Select List (cascading)",
         "id":"10004",
         "type":"Select List (cascading)",
         "key":"com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect"
      },
      {
         "name":"Select List (multiple choices)",
         "id":"10003",
         "type":"Select List (multiple choices)",
         "key":"com.atlassian.jira.plugin.system.customfieldtypes:multiselect"
      },
      {
         "name":"Select List (single choice)",
         "id":"10002",
         "type":"Select List (single choice)",
         "key":"com.atlassian.jira.plugin.system.customfieldtypes:select"
      }
   ]
}

 

 

Get configuration scheme for custom field

{JIRA_URL}/rest/extender/1.0/customField/configScheme/field/{customFieldId}

where {customFieldId} is custom field id

Example request

{JIRA_URL}/rest/extender/1.0/customField/configScheme/field/10003

Example response

{
   "customFieldSchemes":[
      {
         "name":"Default Configuration Scheme for Select List (multiple choices)",
         "id":"10104"
      },
      {
         "name":"Another configuration scheme",
         "id":"10106"
      }
   ]
}

 

Get values for custom field configuration scheme

{JIRA_URL}/rest/extender/1.0/customField/getValue/{configSchemeId}

where {configSchemeId} is custom field configuration scheme

Example request

{JIRA_URL}/rest/extender/1.0/customField/getValue/10104

Example response

  • Example for standard fields (Radio buttons, Select list (sings/multiple choices), Checkboxes
  • Example for cascading field (Select list (cascading))
Flags “disabled” (true/false) for options available since 1.1.0 plugin version

{
   "schemeOptions":[
      {
         "id":"10006",
         "name":"Select List (multiple choices) Value 1",
         "disabled":"false"
      },
      {
         "id":"10007",
         "name":"Select List (multiple choices) Value 2",
         "disabled":"true"
      }
   ]
}

Flags “disabled” (true/false) for options available since 1.1.0 plugin version

{  
   "schemeOptions":[  
      {  
         "id":"10008",
         "name":"Select List (cascading) Parent Value 1",
         "disabled":"false"
         "childOptions":[  
            {  
               "parent_id":"10008",
               "name":"Select List (cascading) Children Parent 1 Value 1",
               "id":"10010",
               "disabled":"false"
            },
            {  
               "parent_id":"10008",
               "name":"Select List (cascading) Children Parent 1 Value 2",
               "id":"10011",
               "disabled":"false"
            },
            {  
               "parent_id":"10008",
               "name":"Select List (cascading) Children Parent 1 Value 3",
               "id":"10012",
               "disabled":"false"
            }
         ]
      },
      {  
         "id":"10009",
         "name":"Select List (cascading) Parent Value 2",
         "disabled":"true",
         "childOptions":[  
            {  
               "parent_id":"10009",
               "name":"Select List (cascading) Children Parent 2 Value 1",
               "id":"10013",
               "disabled":"false"
            },
            {  
               "parent_id":"10009",
               "name":"Select List (cascading) Children Parent 2 Value 2",
               "id":"10014",
               "disabled":"false"
            }
         ]
      }
   ]
}

 

Add values into custom field configuration scheme

{JIRA_URL}/rest/extender/1.0/customField/addValue/{configSchemeId}

where {configSchemeId} is custom field configuration scheme

Example URL

{JIRA_URL}/rest/extender/1.0/customField/addValue/10104

JSON POST body for request

  • POST example for one value
  • POST example for several values
  • POST example for value into cascading field

{
    "optionName":["New option"]
}

{
    "optionName":["New option 1", "New Option 2"]
}

{
    "parentOptionId":"10105",
    "optionName":["New option 1", "New Option 2"]
}

Example response

  • Positive response example
  • Error response example

{
  "message": "done - values [New value 1, New value 2] added to 10104 config scheme id"
}

{
    "message": "scheme config don't exist"
}

 

Remove values into custom field configuration scheme

{JIRA_URL}/rest/extender/1.0/customField/removeValue

JSON POST body for request

  • POST example for one value
  • POST example for several values

{
    "optionId":[10013]
}

{
    "optionName":[10013, 10014]
}

Example response
  • Example 1
  • Example 2

{
    "message": "all options deleted",
    "skipped": [],
    "deleted": [
        "10013",
        "10014"
    ]
}

{
    "message": "options deleted, some options skipped",
    "skipped": [
        "1001300000"
    ],
    "deleted": []
}

 

Get JQL filters

 

Get all filters for user

  Available for all JIRA users

{JIRA_URL}/rest/extender/1.0/filter/user/{JIRA_USER}

where {JIRA_USER} is JIRA user name.

Example response

{
  "filters": [
    {
      "owner": "admin",
      "query": "project = 10000 and statusCategory != Done and assignee = EMPTY ORDER BY priority desc",
      "name": "Open and unassigned (PROJA)",
      "id": "11000"
    },
    {
      "owner": "admin",
      "query": "project = PROJB AND stars = Done",
      "name": "Done issues in project B",
      "id": "11100"
  }]
}

 

Get all JIRA filters

  Available for JIRA administrators

{JIRA_URL}/rest/extender/1.0/filter/all

Example response

{
  "filters": [
    {
      "owner": "admin",
      "query": "project = 10000 and statusCategory != Done and assignee = EMPTY ORDER BY priority desc",
      "name": "Open and unassigned (PROJA)",
      "id": "10000"
    },
    {
      "owner": "user",
      "query": "project = PROJA AND resolution = Unresolved ORDER BY priority DESC, updated DESC",
      "name": "aaaa",
      "id": "10100"
  }]
}

 

Get all Screens from JIRA – since v. 1.2.0

View Screen Id, Screen Name and Screen Tabs (Name, Id and Position) – GET

{JIRA_URL}/rest/extender/1.0/screen/all

Example response

{
    "screens": [
        {
            "name": "Default Screen",
            "tabs": [
                {
                    "name": "Field Tab",
                    "id": "10000",
                    "position": "0"
                },
                {
                    "name": "New tab",
                    "id": "10100",
                    "position": "1"
                }
            ],
            "id": "1"
        },
        {
            "name": "Resolve Issue Screen",
            "tabs": [
                {
                    "name": "Field Tab",
                    "id": "10002",
                    "position": "0"
                }
            ],
            "id": "3"
        },
        {
            "name": "Workflow Screen",
            "tabs": [
                {
                    "name": "Field Tab",
                    "id": "10001",
                    "position": "0"
                }
            ],
            "id": "2"
        }
    ]
}

 

Set Project Lead – since v. 1.3.0

  Available for JIRA Administrators
  Available for actual Project Lead
  Available for project Administrators

Method PUT

{JIRA_URL}/rest/extender/1.0/project/{projectKeyOrId}/setLead/{userName}

where {projectKeyOrId} is project key or id (10000, TEST etc.) and {userName} is user (new Project Lead).

Example response

{
    "message": "User 'admin' is new Project Lead in 'test' project-."
}

 

Add, delete or view user properties – since v. 1.1.0

  Available for JIRA administrators

View user properties – GET

{JIRA_URL}/rest/extender/1.0/user/{JIRA_USER}/properties

where {JIRA_USER} is JIRA user name.

Example GET request:

{JIRA_URL}/rest/extender/1.0/user/admin/properties

Example response:

{
    "properties": {
        "jira.onboarding.first.use.flow.current.sequence": "nextStep",
        "jira.onboarding.first.use.flow.started": "jiraFirstUseFlow",
        "jira.meta.extenderPropertiesKey": "Extender test Properties Value",
        "jira.meta.extenderAnotherPropertiesKey": "Another Extender test Properties Value"
    }
}

 

Add user properties – PUT

{JIRA_URL}/rest/extender/1.0/user/{JIRA_USER}/properties/{PROPERTIES_NAME}"

where {JIRA_USER} is JIRA user name and {PROPERTIES_NAME} is properties name

Example PUT request with JSON body

{JIRA_URL}/rest/extender/1.0/user/admin/properties/jira.meta.extenderAnotherPropertiesKey
{
    "value":"Another Extender test Properties Value"
}

If you add prefix (lira.meta.) for your properties like me, you can see property into user view
{JIRA_URL}/jira/secure/admin/user/ViewUser.jspa?name=admin

 

Delete user properties – DELETE

{JIRA_URL}/rest/extender/1.0/user/{JIRA_USER}/properties/{PROPERTIES_NAME}"

where {JIRA_USER} is JIRA user name and {PROPERTIES_NAME} is properties name

Example DELETE request

{JIRA_URL}/rest/extender/1.0/user/admin/properties/jira.meta.extenderAnotherPropertiesKey

 

Bulk delete projects – since v. 1.4.0

  Available for JIRA administrators
 NOTE: Deleting large or multiple projects can take a long time or slow down the application

Method DELETE

{JIRA_URL}/rest/extender/1.0/project/deleteProject

Example JSON DELETE body for request

  • DELETE example for one value
  • DELETE example for several values

{
    "project":["KEY1"]
}

{
    "project":["KEY1", "PROJECTID1"]
}

Example response

  • Positive response example
  • Error response example

{
    "deleted": [
        "KEY1", "PROJECTID1"
    ],
    "message": "all projects deleted",
    "skipped": []
}

{
    "message": "no projects to delete"
}

 

Activate/Deactivate JIRA users

  Available for JIRA administrators

{JIRA_URL}/rest/extender/1.0/user/activate

or

{JIRA_URL}/rest/extender/1.0/user/deactivate

JSON POST body for request

  • POST example for one user
  • POST example for several users

{
  "users": ["user"]
}

{
  "users": ["user1","user2"]
}


Example response
  • Example 1
  • Example 2
  • Example 3
  • Example 4

{
    "activated": [
        "user"
    ],
    "skipped": [],
    "message": "all users activated"
}

{
    "activated": [],
    "skipped": [
        "user1",
        "user2"
    ],
    "message": "users deactivated, some users skipped"
}

{
    "deactivated": [
        "user"
    ],
    "skipped": [],
    "message": "all users deactivated"
}

{
    "deactivated": [],
    "skipped": [
        "user1",
        "user2"
    ],
    "message": "users deactivated, some users skipped"
}

 

Installation

Read official Atlassian documentation about installing add-ons in JIRA “Atlassian – Installing add-ons

 

Support

If you have any questions or suggestions please don’t hesitate to contact me.

Please feel free to contact by support@itlab.net.pl, if you require any further information.