Skip to content

Commit

Permalink
feat: add get Jira issue transitions action
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgrittner committed Nov 8, 2024
1 parent b626197 commit 84ebced
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions admyral/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
get_jira_audit_records,
create_opsgenie_alert,
create_pagerduty_incident,
get_jira_project,
get_jira_transitions,
)
from admyral.actions.integrations.vulnerability_management import (
list_snyk_vulnerabilities,
Expand Down Expand Up @@ -189,4 +191,6 @@
"list_groups_and_apps_per_user",
"list_used_groups_and_apps_per_user",
"list_google_drive_files_with_link_sharing_enabled",
"get_jira_project",
"get_jira_transitions",
]
4 changes: 4 additions & 0 deletions admyral/actions/integrations/cases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
comment_jira_issue_status,
search_jira_issues,
get_jira_audit_records,
get_jira_project,
get_jira_transitions,
)
from admyral.actions.integrations.cases.opsgenie import create_opsgenie_alert
from admyral.actions.integrations.cases.pagerduty import create_pagerduty_incident
Expand All @@ -16,4 +18,6 @@
"get_jira_audit_records",
"create_opsgenie_alert",
"create_pagerduty_incident",
"get_jira_project",
"get_jira_transitions",
]
25 changes: 25 additions & 0 deletions admyral/actions/integrations/cases/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,28 @@ def get_project(
response = client.get(f"/project/{project_id_or_key}")
response.raise_for_status()
return response.json()


@action(
display_name="Get Transitions",
display_namespace="Jira",
description="Get a Jira transition",
secrets_placeholders=["JIRA_SECRET"],
)
def get_jira_transitions(
issue_id_or_key: Annotated[
str,
ArgumentMetadata(
display_name="Issue ID or Key",
description="The ID or the key of the issue",
),
],
) -> list[dict[str, JsonValue]]:
# https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-get
secret = ctx.get().secrets.get("JIRA_SECRET")
secret = JiraSecret.model_validate(secret)

with get_jira_client(secret) as client:
response = client.get(f"/issue/{issue_id_or_key}/transitions")
response.raise_for_status()
return response.json()
41 changes: 41 additions & 0 deletions docs/pages/integrations/jira/apis/get_transitions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Callout } from "nextra/components";

# Get Transitions

Get transitions for a Jira issue. **This is useful for updating the issue status.**

<Callout type="info">
For more information on the API, see [Get
Transitions](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-get).
</Callout>

**SDK Import:**

```python
from admyral.actions import get_jira_transitions
```

## Arguments:

| Argument Name | Description | Required |
| ------------------------------------- | ------------------------------- | :------: |
| **Issue ID or Key** `issue_id_or_key` | The ID or the key of the issue. | Yes |

## Returns

A JSON object.

## Required Secrets

| Secret Placeholder | Description |
| ------------------ | ------------------------------------------------------ |
| `JIRA_SECRET` | Jira secret. See [Jira setup](/integrations/jira/jira) |

## SDK Example

```python
get_jira_transitions(
issue_id_or_key="SJ-1",
secrets={"JIRA_SECRET": "my_stored_jira_secret"}
)
```

0 comments on commit 84ebced

Please sign in to comment.