forked from odoobgorg/connector-jira
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of the servicedesk client ext. for jira lib
The former code was based on pycontribs/jira#388 which is closed and unmaintained. We only need to read the organizations from the servicedesk REST API and the local code is minimal. We can now use the normal jira library.
- Loading branch information
Showing
3 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
connector_jira_servicedesk/models/jira_organization/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import common | ||
from . import importer | ||
from . import adapter |
51 changes: 51 additions & 0 deletions
51
connector_jira_servicedesk/models/jira_organization/adapter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
import jira | ||
from jira.utils import CaseInsensitiveDict | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class Organization(jira.resources.Resource): | ||
"""A Service Desk Organization.""" | ||
|
||
def __init__(self, options, session, raw=None): | ||
super().__init__( | ||
'organization/{0}', | ||
options, | ||
session, | ||
'{server}/rest/servicedeskapi/{path}' | ||
) | ||
if raw: | ||
self._parse_raw(raw) | ||
|
||
|
||
class OrganizationAdapter(Component): | ||
_name = 'jira.organization.adapter' | ||
_inherit = ['jira.webservice.adapter'] | ||
_apply_on = ['jira.organization'] | ||
|
||
_desk_headers = CaseInsensitiveDict({'X-ExperimentalApi': 'opt-in'}) | ||
|
||
def read(self, id_): | ||
organization = Organization( | ||
self.client._options, | ||
self.client._session | ||
) | ||
organization.find(id_, headers=self._desk_headers) | ||
return organization.raw | ||
|
||
def search(self): | ||
base = (self.client._options['server'] + | ||
'/rest/servicedeskapi/organization') | ||
orgs = self.client._fetch_pages( | ||
Organization, | ||
'values', | ||
'organization', | ||
# limit to False will get them in batch | ||
maxResults=False, | ||
headers=self._desk_headers, | ||
base=base | ||
) | ||
return [org.id for org in orgs] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters