Skip to content

Commit

Permalink
Merge pull request #59 from mfleader/jira
Browse files Browse the repository at this point in the history
Jira Service Connection
  • Loading branch information
chentex authored Jan 24, 2024
2 parents 19f7e24 + 864447a commit ad5ab60
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 7 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ password=
[ocp-server]
port=8000

[jira]
url=
personal_access_token=

[airflow]
url=
username=
password=
```

[TOML](https://toml.io/en/) is used above, but it also accepts YAML.

The elasticsearch configuration should be set up by product, that way each product can configure their own ES server.

As an example for `OCP` the configuration looks like this:
Expand All @@ -38,7 +44,14 @@ password=

Internally the API when serving the `/ocp` enpoints will use this connection.

[TOML](https://toml.io/en/) is used above, but it also accepts YAML.
The `jira` table requires a `url` key and a `personal_access_token` key. The `url` is a string value that points to the URL address of your Jira resource. The [Personal Access Token](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) is a string value that is the credential issued to authenticate and authorize this application with your Jira resource.

```toml
[jira]
url=""
personal_access_token=""
```


## Development on System

Expand Down Expand Up @@ -215,5 +228,5 @@ For the purpose of adding new configuration and authentication credentials to th
password=password123
```

* Assing the ticket to `vzepedam@redhat.com`
* Assign the ticket to `vzepedam@redhat.com`
* Add as watcher `jtaleric@redhat.com`
8 changes: 6 additions & 2 deletions backend/app/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
from app.api.v1.endpoints.ocp import ocpJobs
from app.api.v1.endpoints.ocp import graph
from app.api.v1.endpoints.cpt import cptJobs
from app.api.v1.endpoints.jira import jira
from app.api.v1.endpoints.quay import quayJobs
from app.api.v1.endpoints.quay import quayGraphs

router = APIRouter()

# OCP endopoints
# OCP endpoints
router.include_router(ocpJobs.router, tags=['ocp'])
router.include_router(results.router, tags=['ocp'])
router.include_router(graph.router, tags=['ocp.graphs'])

# CPT endopoints
# CPT endpoints
router.include_router(cptJobs.router, tags=['cpt'])

# Quay endpoints
router.include_router(quayJobs.router, tags=['quay'])
router.include_router(quayGraphs.router, tags=['quay'])

# Jira endpoints
router.include_router(jira.router, tags=['jira'])
14 changes: 14 additions & 0 deletions backend/app/api/v1/endpoints/jira/jira.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from fastapi import APIRouter, Query
from app.services.jira_svc import JiraService

router = APIRouter()

@router.get(
'/api/v1/jira',
summary="Query Jira Issues",
)
async def query(
q: str = Query(None, description="Jira query language string")
):
jira = JiraService()
return jira.jql(q)
24 changes: 24 additions & 0 deletions backend/app/services/jira_svc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from atlassian import Jira

from app import config


class JiraService:

def __init__(self, configpath="jira"):
self.cfg = config.get_config()
self.url = self.cfg.get(configpath+'.url')
self.pat = self.cfg.get(configpath+'.personal_access_token')
self.svc = Jira(
url=self.url,
token=self.pat
)

def jql(self, query: str, fields="*all", expand=None, validate_query=None):
return self.svc.jql(
jql=query,
fields=fields,
expand=expand,
validate_query=validate_query
)

176 changes: 174 additions & 2 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trio = "^0.18.0"
aiohttp = "^3.7.4"
httpx = "^0.18.1"
orjson = "^3.5.3"
atlassian-python-api = "^3.41.9"

[tool.poetry.dev-dependencies]
watchgod = "^0.7"
Expand Down
2 changes: 1 addition & 1 deletion backend/scripts/start-reload.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/bash

uvicorn --reload --host="0.0.0.0" --port=8000 --forwarded-allow-ips='*' --proxy-headers app.main:app app.main:app
uvicorn --reload --host="0.0.0.0" --port=8000 --forwarded-allow-ips='*' --proxy-headers app.main:app
3 changes: 3 additions & 0 deletions backend/skeleton.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ password=
[ocp-server]
port=8000

[jira]
url=
personal_access_token=

0 comments on commit ad5ab60

Please sign in to comment.