Closed jpavlav closed 6 months ago
Thanks for taking a look! I'll make another commit with some updates addressing your feedback.
@adehad I think I've got it now. I added the paths to the new resources. Added some more data points for the parameterized test_generic_resource
that cover the new additions to that resource map dict. I also peppered the dashboard tests themselves with isinstance
assertions where I thought it made sense. The cloud tests are still passing locally for me so figured π . Let me know if there is anything else I need to address please π
Addresses ISSUE-1836
1836
The impetus for these changes is a project I'm working on at work. We want to create a dynamically updating dashboard that helps prioritize maintenance operations. I realize this is a large PR, and one large commit, but I feel like the work in it's entirety makes sense when looked at together. Additionally, there are some changes that were just formatting, in the case where spacing or anything along those lines have changed, that was auto-formatting and accepted by the linting
tox -e lint
.jira/client.py
DashboardItemProperty
,DashboardItemPropertyKey
, andGadget
resources to client for use in new methods.dashboards
method to include thegadgets
that exist on a given dashboard. This is a logical association that makes sense, but isn't directly exposed in the API.create_dashboard
method. It creates a dashboard via the API and returns aDashbord
object.copy_dashboard
method.update_dashboard_automatic_refresh_seconds
method. This calls theinternal
API, which is why it's decorated withexperimental
andcloud
. This might change in the future, but it really is a handy thing to have, otherwise, the user has to configure this in the web interface.Added
dashboard_item_property
method. This is available on bothcloud
andserver
.Added
dashboard_item_property_keys
method. This is available on bothcloud
andserver
.Added
set_dashboard_item_property
method. This is available on bothcloud
andserver
.^^ These methods all provide a means of adding arbitrary metadata to
dashboard_items
(gadgets
) and/or configure them via specific keys.Added
dashboard_gadgets
method. This returns the gadgets associated with a given dashboard. It also iterates over thekeys
for thisgadget
's properties, generating a list ofDashboardItemProperty
objects that are associated with each gadget. This makes it really easy for the user to associate which configuration/metadata goes with which gadget.Added
gadgets
method. This returns a list of fromjira
of all thegadgets
that are available to add to any dashboard.Added
add_gadget_to_dashboard
method. This allows the user to add gadgets to a specified dashboard.Added the protected method
_get_internal_url
. This is very similar toget_url
orget_latest
url, whereoptions
are updated to allow for easy resolution of paths that are on theinternal
jira
api.Updated the
_find_for_resource
type hint onids
because it is possible that a resource requires more than2
ids to resolve it's url.jira/resources.py
DashboardItemProperty
,DashboardItemPropertyKey
, andGadget
to the__all__
list so they are represented.find
method for the same reason as the_find_for_resource
method.gadgets
attribute to theDashboard
resource to housegadget
references.DashbordItemPropertyKey
resource.DashboardItemProperty
resource. Theupdate
anddelete
methods are overridden here because it does not have aself
attribute. This is kind of in an in between space as far as being considered a resource, but for ease of use as an interface, it makes sense for it to be considered.Gadget
resource. It too has overriddenupdate
anddelete
methods for the aforementioned reasons.jira/utils/init.py
cloud
convenience decorator for client methods that make calls that are only available on thecloud
api. It checks theclient
instance to see if it_is_cloud
. If not, it logs a warning and returnsNone
. This was the convention seen on other endpoints on theclient
.experimental
convenience decorator for client methods that make calls that are experimental. It attempts to run the client method, if aJIRAError
is raised that has a response object, the response is checked for a status code in[404, 405]
indicating either the path no longer accepts the HTTP verb or no longer exists, and then logs a warning and returnsNone
. Otherwise it reraises the error^^ Regarding these convenience decorators, it makes it really apparent to developers which calls are for the cloud and/or experimental.
remove_empty_attributes
convenience method. I found myself having to remove empty attributes or add a lot of branching in order to accommodate optional payload parameters or path parameters. This function made that easier.Finally I wrote tests to cover these changes. These tests worked for me locally against my docker
jira server
instance. However, most of them didn't run, because the test checks the environment to find out where it is running.For the cloud tests, I signed up for a trial account for
jira cloud
and ran them against my instance. They all panned out okay and cleaned up after themselves appropriately.