Skip to content

Commit

Permalink
Add Dashboard Support: #72 Add dashboard related actions (#73)
Browse files Browse the repository at this point in the history
* Add Dashboard Support: #72 - Create Dashboard

Added `create_dashboard` action.

* Add Dashboard Support: #72 Add Gadget Action

* Added `add_gadget` action. Allows the user to add a gadget to an
existing dashboard.

* Add Dashboard Support: #72 Add `update_dashboard` Action

* Added `update_dashboard` action. It accepts parameters for the update,
fetches the dashboard by `id`, runs the `update` method on the
`dashboard` resource and returns it's `raw` result (`json` result from
the API)

* Add Dashboard Support: #72 Add `update_gadget` Action

* Added `update_gadget` action to allow a user to modify an existing
gadget on a dashboard.

* Add Dashboard Support: #72 Add `delete_dashboard` Action

* Added an action to delete dashboards by `id`. The `jira` library only
returns the raw `requests` response in this case. The return is a
dictionary containing the response status code and any text that was
included with the response. The action fails if any status code other
than 204 is produced.

* Add Dashboard Support: #72 Add `remove_gadget` Action

* Added `remove_gadget` action to allow users to delete gadgets from
dashboards.

* Add Dashboard Support: #72 Add `get_gadgets` Action

* The `get_gadgets` action just pulls the available list of gadgets from
the `jira` instance. This commit also includes a fix to the description
of the `remove_gadget` yaml.

* Change `get_gadgets` to `get_available_gadgets`

This is more in keeping with the API.

* Add Dashboard Support: #72 Add `get_dashboard_gadgets` Action

* The `get_dashboard_gadgets` action differs from the
`get_available_gadgets` action in that, it targets a specific dashboard
and returns only the gadgets present on that dashboard.

* Add Dashboard Support: #72 Add `copy_dashboard` Action

* Added the `copy_dashboard` action.
* Updated some descriptions in `update_dashboard` and `create_dashboard`
yaml files.

* Add `get_dashboard_item_property_keys` Action #72

* Added `get_dashboard_item_property_keys`. This returns a list of
dashboard item property keys which are used to identify metadata stores
on a given dashboard item (gadget).

* Dashboard Support: #72 Add `get_dashboard_item_property` Action

* Added `get_dashboard_item_property` action. This gets a dashboard item
(gadget) property by key. Typically these hold user specified metadata,
or in the case of some gadgets the `config` key can be sent a payload to
configure an otherwise unconfigured gadget.

* Dashboard Support: #72 Add `set_dashboard_item_property` Action

* Allows the user to set the values of item properties on a given
dashboard item (gadget). An example of this would be a configuration for
a dashboard gadget that is configured with a `Filter Result` module.

* Dashboard Support #72: Add `delete_dashboard_item_property`

* Added `delete_dashboard_item_property`. Allows the user to delete a
dashboard item property (like a config object on a filter module on a
gadget).

* Dashboard Support: #72 `update_dashboard_item_property`

* Added `update_dashboard_item_property` action. This differs from
`set_dashboard_item_property` in that, it updates the existing object
attributes, instead of simply replacing them. Good for updating specific
fields on gadget configuration items.

* Dashboard Support: #72 `update_dashboard_automatic_refresh`

* Added `update_dashboard_automatic_refresh` action. This let's the user
set how often the dashboard refreshes in minutes.

* Add Dashboard Support: #72 Tests

Added tests for all of the new actions. Included some new fixtures as
well for those tests. The report is as follows:

```
(st2) root@e74c68fe6ffa:/opt/stackstorm/packs.dev/jira#
st2-run-pack-tests -j -t -c -p /opt/stackstorm/packs.dev/jira
Running tests for pack: jira
Activating virtualenv in /tmp/st2-pack-tests-virtualenvs/jira...
::/opt/stackstorm/packs.dev/jira/sensors/:/opt/stackstorm/packs.dev/jira/actions/:/opt/stackstorm/packs.dev/jira/actions/lib/:/opt/stackstorm/packs.dev/jira/etc/
WARNING: You are using pip version 20.3.3; however, version 24.0 is
available.
You should consider upgrading via the
'/tmp/st2-pack-tests-virtualenvs/jira/bin/python -m pip install
--upgrade pip' command.
Running tests...
test_add_gadget (tests.test_action_add_gadget.AddGadgetTests) ... passed
test_copy_dashboard
(tests.test_action_copy_dashboard.CopyDashboardTests) ... passed
test_create_dashboard
(tests.test_action_create_dashboard.CreateDashboardTests) ... passed
test_delete_dashboard
(tests.test_action_delete_dashboard.DeleteDashboardTests) ... passed
test_delete_dashboard_item_property
(tests.test_action_delete_dashboard_item_property.DeleteDashboardItemPropertyTest)
... passed
test_get_available_gadgets
(tests.test_action_get_available_gadgets.GetAvailableGadgetsTests) ...
passed
test_get_dashboard_gadgets
(tests.test_action_get_dashboard_gadgets.GetDashboardGadgetsTest) ...
passed
test_get_dashboard_item_property
(tests.test_action_get_dashboard_item_property.GetDashboardItemPropertyTests)
... passed
test_get_dashboard_item_property_keys
(tests.test_action_get_dashboard_item_property_keys.GetDashboardItemPropertyKeysTests)
... passed
test_remove_gadget (tests.test_action_remove_gadget.RemoveGadgetTests)
... passed
test_run_with_invalid_action (tests.test_action_run.RunTestCase) ...
passed
test_run_with_jira_exception (tests.test_action_run.RunTestCase) ...
passed
test_run_without_exception (tests.test_action_run.RunTestCase) ...
passed
test_transition_name_to_id (tests.test_action_run.RunTestCase) ...
passed
test_get_dashboard_item_property
(tests.test_action_set_dashboard_item_property.SetDashboardItemPropertyTests)
... passed
test_update_dashboard
(tests.test_action_update_dashboard.UpdateDashboardTests) ... passed
test_update_dashboard_automatic_refresh
(tests.test_action_update_dashboard_automatic_refresh.UpdateJiraDashboardAutomaticRefreshActionDashboardTests)
... passed
test_set_dashboard_item_property
(tests.test_action_update_dashboard_property.UpdateDashboardItemPropertyTests)
... passed
test_update_gadget (tests.test_action_update_gadget.UpdateGadgetTests)
... passed
test_poll (tests.test_sensor_jira_sensor.JIRASensorTestCase) ... passed
test_poll
(tests.test_sensor_jira_sensor_for_apiv2.JIRASensorForAPIv2TestCase) ...
passed

TEST RESULT OUTPUT:

Name                                            Stmts   Miss  Cover
-------------------------------------------------------------------
actions/add_field_value.py                          8      8     0%
actions/add_gadget.py                               8      0   100%
actions/attach_file_to_issue.py                    10     10     0%
actions/attach_files_to_issue.py                   11     11     0%
actions/bulk_link_issue.py                         27     27     0%
actions/comment_issue.py                            8      8     0%
actions/copy_dashboard.py                           8      0   100%
actions/create_dashboard.py                         8      0   100%
actions/create_issue.py                            14     14     0%
actions/delete_dashboard.py                         8      0   100%
actions/delete_dashboard_item_property.py           8      0   100%
actions/get_available_gadgets.py                    6      0   100%
actions/get_dashboard_gadgets.py                    6      0   100%
actions/get_dashboard_item_property.py              6      0   100%
actions/get_dashboard_item_property_keys.py         6      0   100%
actions/get_issue.py                                8      8     0%
actions/get_issue_attachments.py                   11     11     0%
actions/get_issue_comments.py                      11     11     0%
actions/get_issue_links.py                          8      8     0%
actions/lib/__init__.py                             0      0   100%
actions/lib/base.py                                41     21    49%
actions/lib/formatters.py                          57     57     0%
actions/lib/utils.py                                4      0   100%
actions/link_issue.py                               6      6     0%
actions/remove_gadget.py                            9      0   100%
actions/run.py                                     21      3    86%
actions/search_issues.py                           10     10     0%
actions/set_dashboard_item_property.py              6      0   100%
actions/transition_issue.py                         6      6     0%
actions/update_dashboard.py                         9      0   100%
actions/update_dashboard_automatic_refresh.py       7      0   100%
actions/update_dashboard_item_property.py           7      0   100%
actions/update_field_value.py                       8      8     0%
actions/update_gadget.py                           10      0   100%
sensors/jira_sensor.py                             97     45    54%
sensors/jira_sensor_for_apiv2.py                   96     45    53%
-------------------------------------------------------------------
TOTAL                                             574    317    45%
[success] 16.58%
tests.test_action_run.RunTestCase.test_run_without_exception: 0.0253s
[success] 6.88%
tests.test_action_add_gadget.AddGadgetTests.test_add_gadget: 0.0105s
[success] 5.61%
tests.test_action_delete_dashboard_item_property.DeleteDashboardItemPropertyTest.test_delete_dashboard_item_property:
0.0086s
[success] 5.45%
tests.test_action_update_gadget.UpdateGadgetTests.test_update_gadget:
0.0083s
[success] 5.38%
tests.test_action_create_dashboard.CreateDashboardTests.test_create_dashboard:
0.0082s
[success] 5.22%
tests.test_action_get_available_gadgets.GetAvailableGadgetsTests.test_get_available_gadgets:
0.0080s
[success] 5.22%
tests.test_action_copy_dashboard.CopyDashboardTests.test_copy_dashboard:
0.0080s
[success] 5.09%
tests.test_action_update_dashboard_property.UpdateDashboardItemPropertyTests.test_set_dashboard_item_property:
0.0078s
[success] 5.06%
tests.test_action_delete_dashboard.DeleteDashboardTests.test_delete_dashboard:
0.0077s
[success] 4.80%
tests.test_action_set_dashboard_item_property.SetDashboardItemPropertyTests.test_get_dashboard_item_property:
0.0073s
[success] 4.76%
tests.test_action_get_dashboard_gadgets.GetDashboardGadgetsTest.test_get_dashboard_gadgets:
0.0073s
[success] 4.68%
tests.test_action_get_dashboard_item_property.GetDashboardItemPropertyTests.test_get_dashboard_item_property:
0.0071s
[success] 4.66%
tests.test_action_remove_gadget.RemoveGadgetTests.test_remove_gadget:
0.0071s
[success] 4.64%
tests.test_action_update_dashboard_automatic_refresh.UpdateJiraDashboardAutomaticRefreshActionDashboardTests.test_update_dashboard_automatic_refresh:
0.0071s
[success] 4.45%
tests.test_action_update_dashboard.UpdateDashboardTests.test_update_dashboard:
0.0068s
[success] 4.09%
tests.test_action_get_dashboard_item_property_keys.GetDashboardItemPropertyKeysTests.test_get_dashboard_item_property_keys:
0.0063s
[success] 2.27%
tests.test_action_run.RunTestCase.test_transition_name_to_id: 0.0035s
[success] 2.25%
tests.test_action_run.RunTestCase.test_run_with_jira_exception: 0.0034s
[success] 1.90%
tests.test_action_run.RunTestCase.test_run_with_invalid_action: 0.0029s
[success] 0.51%
tests.test_sensor_jira_sensor_for_apiv2.JIRASensorForAPIv2TestCase.test_poll:
0.0008s
[success] 0.50%
tests.test_sensor_jira_sensor.JIRASensorTestCase.test_poll: 0.0008s
-----------------------------------------------------------------------------
21 tests run in 0.159 seconds (21 tests passed)
```

All changes are covered at 100%.

* Add Dashboard Support: #72 Finishing touches.

* Updated `CHANGES.md`
* Updated `README.md`
* Bumped `pack` version.
* Committed missed addition to `test/lib/actions.py`

* Dashboard Support #72: Update `jira` version

The changes necessary for these pack updates have been merged into the
`jira` package and that package has had a release to `pypi`.

* Force Tests

* Add Dashboard Actions #72: Update

Had to update some tests/class references/method calls to match the
final interface over in the `jira` lib.

* `Gadget` renamed to `DashboardGadget`.
* `gadgets` method renamed to `all_dashboard_gadgets`.
* Update
`%s/update_dashboard_automatic_refresh_seconds/update_dashboard/automatic_refresh_minutes`

* Add Dashboard Support #72: CI && Pack bump

The latest versions of the `jira` library require `python >= 3.8`. In
light of the fact that `StackStorm` is going to shed support for
`python3.6` (which is EOL
https://www.python.org/downloads/release/python-360/) this pack is
updating to stop testing `3.6` and bumping the pack to the next major
version to signal a potentially breaking change.

* Add Dashboard Support #72: Try CI again

Cutting this down to the lowest common denominator in terms of working
tests for `StackStorm`. `3.11` is breaking on installing some dev
dependencies:

```
    ERROR: Command errored out with exit status 1:
command: /home/runner/virtualenv/bin/python
/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py
get_requires_for_build_wheel /tmp/tmp_5anenlq
cwd:
/tmp/pip-install-mj_5c6wi/pyyaml_3973c6602d81416aa8ada0b8d43f48a5
    Complete output (54 lines):
    running egg_info
    writing lib3/PyYAML.egg-info/PKG-INFO
writing dependency_links to
lib3/PyYAML.egg-info/dependency_links.txt
    writing top-level names to lib3/PyYAML.egg-info/top_level.txt
    Traceback (most recent call last):
File
"/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py",
line 280, in <module>
        main()
File
"/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py",
line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py",
line 114, in get_requires_for_build_wheel
        return hook(config_settings)
               ^^^^^^^^^^^^^^^^^^^^^
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py",
line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings,
requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py",
line 295, in _get_build_requires
        self.run_setup()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py",
line 311, in run_setup
        exec(code, locals())
      File "<string>", line 271, in <module>
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/__init__.py",
line 104, in setup
        return distutils.core.setup(**attrs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py",
line 185, in setup
        return run_commands(dist)
               ^^^^^^^^^^^^^^^^^^
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py",
line 201, in run_commands
        dist.run_commands()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py",
line 969, in run_commands
        self.run_command(cmd)
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/dist.py",
line 967, in run_command
        super().run_command(command)
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py",
line 988, in run_command
        cmd_obj.run()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py",
line 321, in run
        self.find_sources()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py",
line 329, in find_sources
        mm.run()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py",
line 550, in run
        self.add_defaults()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py",
line 588, in add_defaults
        sdist.add_defaults(self)
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/sdist.py",
line 102, in add_defaults
        super().add_defaults()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py",
line 251, in add_defaults
        self._add_defaults_ext()
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py",
line 336, in _add_defaults_ext
        self.filelist.extend(build_ext.get_source_files())
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<string>", line 201, in get_source_files
File
"/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py",
line 107, in __getattr__
        raise AttributeError(attr)
    AttributeError: cython_sources
    ----------------------------------------
ERROR: Command errored out with exit status 1:
/home/runner/virtualenv/bin/python
/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py
get_requires_for_build_wheel /tmp/tmp_5anenlq Check the logs for full
command output.
WARNING: You are using pip version 20.3.3; however, version 24.0 is
available.
You should consider upgrading via the
'/home/runner/virtualenv/bin/python -m pip install --upgrade pip'
command.
```

* Add Dashboard Support #72: Updated CHANGES && Import Paths

This PR updates the CHANGES.md to include the deprecation of `python
3.6`. Further, it updates the paths to the `utils` function
`remove_empty_attributes`. The test set up puts the

* Add Dashboard Support #72: More pathing issues

Turns out the `.gitignore` ignores the `lib/` dir. This applies to the
`lib` dir within the `actions` dir. Caused me to miss the fact that I
didn't actually commit the `utils.py` file.

* Add Dashboard Support #72: Update `release.yaml`

I just realized the `release.yaml` GHA also uses the upstream
`pack-build_and_test` workflow. It would have failed when an attempt was
released because of our now deprecating `python 3.6`. Updating this to
mirror the `build_and_test.yaml` workflow.
  • Loading branch information
jpavlav authored Mar 26, 2024
1 parent c3de69a commit a45a2e5
Show file tree
Hide file tree
Showing 57 changed files with 1,106 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ jobs:
enable-common-libs: true
#apt-cache-version: v0
#py-cache-version: v0
python-version: '["3.8", "3.9"]'
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
enable-common-libs: true
#apt-cache-version: v0
#py-cache-version: v0
python-version: '["3.8", "3.9"]'

tag_release:
needs: build_and_test
Expand Down
23 changes: 21 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# Change Log

## 3.0.0

- Drop support for `python 3.6`
- Add new ``jira.add_gadget`` action
- Add new ``jira.copy_dashboard`` action
- Add new ``jira.create_dashboard`` action
- Add new ``jira.delete_dashboard_item_property`` action
- Add new ``jira.delete_dashboard`` action
- Add new ``jira.get_available_gadgets`` action
- Add new ``jira.get_dashboard_gadgets`` action
- Add new ``jira.get_dashboard_item_property_keys`` action
- Add new ``jira.get_dashboard_item_property`` action
- Add new ``jira.remove_gadget`` actionn
- Add new ``jira.set_dashboard_item_property`` action
- Add new ``jira.update_dashboard_automatic_refresh`` action
- Add new ``jira.update_dashboard_item_property`` action
- Add new ``jira.update_dashboard`` action
- Add new ``jira.update_gadget`` action

## 2.6.0

- Add new ``jira.get_issue_links`` action
- Add new ``jira.get_issue_links`` action

- Evaluate if an issue has a priority set before attempting to get the priority

Expand All @@ -17,7 +36,7 @@
## 2.4.2

- Update `formatters.py` to include `priority` field

## 2.4.1

- Update `search_issue` to include `include_components` and `include_subtasks` as flags
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ The sensor monitors for new tickets and sends a trigger into the system whenever
* ``transition_issue`` - Do a transition on a JIRA issue / ticket.
* ``transition_issue_by_name`` - Do a transition on a JIRA issue / ticket.
* ``update_field_value`` - Update a field in a particular JIRA issue.
* ``add_gadget`` - Add a gadget to an existing JIRA dashboard.
* ``copy_dashboard`` - Copy an existing JIRA dashboard
* ``create_dashboard`` - Create a JIRA dashboard
* ``delete_dashboard_item_property`` - Delete a JIRA dashboard item property.
* ``delete_dashboard`` - Delete a JIRA dashboard.
* ``get_available_gadgets`` - Get all available JIRA dashboard gadgets.
* ``get_dashboard_gadgets`` - Get all JIRA dashboard gadgets for an existing dashboard.
* ``get_dashboard_item_property_keys`` - Get the dashboard item (gadget) property keys for an existing dashboard.
* ``get_dashboard_item_property`` - Get a dashboard item (gadget) property from a gadget on JIRA dashboard.
* ``remove_gadget`` - Remove a gadget from a JIRA dashboard.
* ``set_dashboard_item_property`` - Set the value of a dashboard item (gadget) property on a JIRA dashboard.
* ``update_dashboard_automatic_refresh`` - Set the refresh interval for JIRA dashboard in minutes.
* ``update_dashboard_item_property`` - Update the value of a dashboard item (gadget) property on a JIRA dashboard.
* ``update_dashboard`` - Update an existing JIRA dashboard.
* ``update_gadget`` - Update an existing gadget on a JIRA dashboard.

## Maintainers
Active pack maintainers with review & write repository access and expertise with JIRA:
Expand Down
31 changes: 31 additions & 0 deletions actions/add_gadget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from lib.base import BaseJiraAction
from lib.utils import remove_empty_attributes

__all__ = ["AddGadgetAction"]


class AddGadgetAction(BaseJiraAction):
def run(
self,
dashboard_id,
color=None,
ignore_uri_and_module_key_validation=None,
module_key=None,
position=None,
title=None,
uri=None,
):
data = remove_empty_attributes(
{
"dashboard_id": dashboard_id,
"color": color,
"ignore_uri_and_module_key_validation": ignore_uri_and_module_key_validation,
"module_key": module_key,
"position": position,
"title": title,
"uri": uri,
}
)

gadget = self._client.add_gadget_to_dashboard(**data)
return gadget.raw
53 changes: 53 additions & 0 deletions actions/add_gadget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: add_gadget
runner_type: python-script
description: Add a gadget to a dashboard.
enabled: true
entry_point: add_gadget.py
parameters:
dashboard_id:
type: string
description: The ID of the Dashboard to add the gadget to.
required: true
color:
type: string
description: The color of the gadget.
default: blue
enum:
- blue
- red
- yellow
- green
- cyan
- purple
- gray
- white
required: false
ignore_uri_and_module_key_validation:
type: boolean
description: |
Whether to ignore the validation of the module key and URI.
For example, when a gadget is created that is part of an
application that is not installed.
default: false
required: false
module_key:
type: string
description: |
The module to use in the gadget. Mutually exclusive with `uri`.
required: false
position:
type: object
description: |
A dictionary (object) containing positioning information for the
gadget like - {"column": 0, "row": 0}
required: false
title:
type: string
description: The title of the gadget.
required: false
uri:
type: string
description: |
The uri to the module to use in the gadget. Mutually exclusive
with `uri`.
27 changes: 27 additions & 0 deletions actions/copy_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from lib.base import BaseJiraAction
from lib.utils import remove_empty_attributes

__all__ = ["CopyJiraDashboardAction"]


class CopyJiraDashboardAction(BaseJiraAction):
def run(
self,
id,
name,
description=None,
edit_permissions=None,
share_permissions=None,
):
data = remove_empty_attributes(
{
"id": id,
"name": name,
"description": description,
"edit_permissions": edit_permissions,
"share_permissions": share_permissions,
}
)

dashboard = self._client.copy_dashboard(**data)
return dashboard.raw
31 changes: 31 additions & 0 deletions actions/copy_dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: copy_dashboard
runner_type: python-script
description: Copy an existing JIRA dashboard.
enabled: true
entry_point: copy_dashboard.py
parameters:
id:
type: string
description: The ID of the Dashboard to copy.
required: true
name:
type: string
description: The name of the new dashboard.
required: true
description:
type: string
description: A description of the dashboard.
required: false
edit_permissions:
type: array
items:
type: object
required: false
description: A list of permission objects to grant editing permissions.
share_permissions:
type: array
items:
type: object
required: false
description: A list of permissions objects to grant sharing permissions.
21 changes: 21 additions & 0 deletions actions/create_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from lib.base import BaseJiraAction
from lib.utils import remove_empty_attributes

__all__ = ["CreateJiraDashboardAction"]


class CreateJiraDashboardAction(BaseJiraAction):
def run(
self, name, description=None, edit_permissions=None, share_permissions=None
):
data = remove_empty_attributes(
{
"name": name,
"description": description,
"edit_permissions": edit_permissions,
"share_permissions": share_permissions,
}
)

dashboard = self._client.create_dashboard(**data)
return dashboard.raw
27 changes: 27 additions & 0 deletions actions/create_dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: create_dashboard
runner_type: python-script
description: Create a new JIRA dashboard.
enabled: true
entry_point: create_dashboard.py
parameters:
name:
type: string
description: The name of the new dashboard.
required: true
description:
type: string
description: A description of the dashboard.
required: false
edit_permissions:
type: array
items:
type: object
required: false
description: A list of permission objects to grant editing permissions.
share_permissions:
type: array
items:
type: object
required: false
description: A list of permissions objects to grant sharing permissions.
11 changes: 11 additions & 0 deletions actions/delete_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lib.base import BaseJiraAction

__all__ = ["DeleteJiraDashboardAction"]


class DeleteJiraDashboardAction(BaseJiraAction):
def run(self, dashboard_id):
dashboard = self._client.dashboard(dashboard_id)
response = dashboard.delete()
result = {"status_code": response.status_code, "response_text": response.text}
return bool(response.status_code == 204), result
15 changes: 15 additions & 0 deletions actions/delete_dashboard_item_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from lib.base import BaseJiraAction

__all__ = ["DeleteDashboardItemPropertyAction"]


class DeleteDashboardItemPropertyAction(BaseJiraAction):
def run(self, dashboard_id, item_id, property_key):
dashboard_item_property = self._client.dashboard_item_property(
dashboard_id,
item_id,
property_key,
)
response = dashboard_item_property.delete(dashboard_id, item_id)
result = {"status_code": response.status_code, "response_text": response.text}
return bool(response.status_code == 204), result
19 changes: 19 additions & 0 deletions actions/delete_dashboard_item_property.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: delete_dashboard_item_property
runner_type: python-script
description: Delete the property of an item (gadget) on a dashboard.
enabled: true
entry_point: delete_dashboard_item_property.py
parameters:
dashboard_id:
type: string
description: The ID of the Dashboard.
required: true
item_id:
type: string
description: The ID of the dashboard item (gadget).
required: true
property_key:
type: string
description: The item property key.
required: true
11 changes: 11 additions & 0 deletions actions/delete_dashbord.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: delete_dashboard
runner_type: python-script
description: delete an existing JIRA dashboard.
enabled: true
entry_point: delete_dashboard.py
parameters:
dashboard_id:
type: string
description: The ID of the Dashboard to delete.
required: true
9 changes: 9 additions & 0 deletions actions/get_available_gadgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lib.base import BaseJiraAction

__all__ = ["GetAvailableGadgetsAction"]


class GetAvailableGadgetsAction(BaseJiraAction):
def run(self):
gadgets = self._client.all_dashboard_gadgets()
return [gadget.raw for gadget in gadgets]
6 changes: 6 additions & 0 deletions actions/get_available_gadgets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: get_available_gadgets
runner_type: python-script
description: Get a list of available gadgets.
enabled: true
entry_point: get_available_gadgets.py
9 changes: 9 additions & 0 deletions actions/get_dashboard_gadgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from lib.base import BaseJiraAction

__all__ = ["GetDashboardGadgetsAction"]


class GetDashboardGadgetsAction(BaseJiraAction):
def run(self, dashboard_id):
gadgets = self._client.dashboard_gadgets(dashboard_id)
return [gadget.raw for gadget in gadgets]
11 changes: 11 additions & 0 deletions actions/get_dashboard_gadgets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: get_dashboard_gadgets
runner_type: python-script
description: Get all the gadgets on a dashboard.
enabled: true
entry_point: get_dashboard_gadgets.py
parameters:
dashboard_id:
type: string
description: The ID of the Dashboard get gadgets from.
required: true
11 changes: 11 additions & 0 deletions actions/get_dashboard_item_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lib.base import BaseJiraAction

__all__ = ["GetDashboardItemPropertyAction"]


class GetDashboardItemPropertyAction(BaseJiraAction):
def run(self, dashboard_id, item_id, property_key):
dashboard_item_property = self._client.dashboard_item_property(
dashboard_id, item_id, property_key
)
return dashboard_item_property.raw
19 changes: 19 additions & 0 deletions actions/get_dashboard_item_property.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: get_dashboard_item_property
runner_type: python-script
description: Get the property of an item (gadget) on a dashboard.
enabled: true
entry_point: get_dashboard_item_property.py
parameters:
dashboard_id:
type: string
description: The ID of the Dashboard.
required: true
item_id:
type: string
description: The ID of the dashboard item (gadget).
required: true
property_key:
type: string
description: The item property key.
required: true
Loading

0 comments on commit a45a2e5

Please sign in to comment.