Skip to content

API Reference parrot.interfaces.jira.client

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.interfaces.jira.client

View source

JiraInterface — shared auth resolution + read surface (FEAT-454, M1).

The single Jira read implementation in the repo: both JiraToolkit (TASK-2402) and the wiki sweep (parrot.knowledge.wiki.jira_sync, TASK-2403) consume this class. Read-only — ticket mutation stays JiraToolkit's job.

Two disciplines are non-negotiable, carried over from JiraToolkit because getting either wrong is silent and self-perpetuating:

  1. No auth heuristic. An unresolved auth_type leaves the interface unauthenticated; every read raises :class:JiraAuthError rather than guessing a mode or falling back to env credentials.
  2. An empty result set is not proof of an empty scope. Jira Cloud answers a failed auth with 200 + an empty list + X-Seraph-Loginreason: AUTHENTICATED_FAILED. An empty first search page (or an empty project list) triggers a /myself probe, and a failed probe raises instead of returning an empty-but-successful result.

The jira (pycontribs) distribution is optional and lazily imported — importing this module must never require it to be installed.

Alias JiraAuthError

Re-exported from parrot.interfaces.jira.errors.JiraAuthError.

Alias JiraDependencyError

Re-exported from parrot.interfaces.jira.errors.JiraDependencyError.

Class JiraInterface

Shared Jira read interface. Lazily imports jira.

Owns connection/auth resolution (every mode JiraToolkit supports: basic_auth, token_auth, oauth (1.0a), oauth2_3lo via :class:parrot.auth.jira_oauth.JiraOAuthManager) and the read surface: paginated JQL search, issue fetch, changelog, remote links, project metadata, an auth probe, and acceptance-criteria field resolution.

Note on oauth2_3lo: the interface accepts a duck-typed credential_resolver exposing an async resolve() returning a token-set-like object with access_token, api_base_url and (optionally) account_id attributes — e.g. :class:parrot.auth.jira_oauth.JiraTokenSet. Unlike JiraToolkit (which resolves per (channel, user_id) from a PermissionContext), this interface has no per-call user context in its read-method signatures, so credential_resolver.resolve() is called with no arguments — it is expected to already be scoped to a single identity when 3LO is used through this interface directly.

Parameter Type Default Description
server_url str | None None Jira instance base URL. Required for the static auth modes; optional for oauth2_3lo, whose URL is resolved per-user at call time.
auth_type str | None None One of basic_auth/token_auth/oauth/ oauth2_3lo. Falls back to JIRA_AUTH_TYPE. If left unresolved, the interface is unauthenticated and every read raises :class:JiraAuthError — no heuristic fallback.
username str | None None Basic-auth username. Falls back to JIRA_USERNAME.
password str | None None Basic-auth password/token. Falls back to JIRA_PASSWORD/JIRA_API_TOKEN.
token str | None None Personal access token for token_auth. Falls back to JIRA_SECRET_TOKEN.
site_url str | None None
oauth_consumer_key str | None None OAuth 1.0a consumer key.
oauth_key_cert str | None None OAuth 1.0a private key — PEM content or a path to a PEM file.
oauth_access_token str | None None OAuth 1.0a access token.
oauth_access_token_secret str | None None OAuth 1.0a access token secret.
credential_resolver Any None Duck-typed per-user token resolver for oauth2_3lo (see class docstring).
request_timeout float 30.0 HTTP timeout in seconds, passed to JIRA(timeout=...).
verify_credentials bool True When True, probe /myself on first use of a static-mode client and raise on a definitive rejection.
verify_tls bool False TLS verification for static-mode clients. Defaults to False to match JiraToolkit's existing behaviour (jiratoolkit.py:960) — override for a stricter run.

Attributes:

Attribute Type Description
auth_type str | None

Method JiraInterface.attach_client

Attach an already-resolved jira.JIRA client.

Bypasses this interface's own auth resolution entirely for every subsequent call. This is the delegation seam JiraToolkit uses (TASK-2402, G1) so oauth2_3lo's per-(channel, user_id) token resolution — which this interface's own credential_resolver.resolve() has no context to perform — is resolved exactly once, inside the toolkit's own _pre_execute, and simply reused here rather than duplicated.

attach_client(client: Any) -> None

Parameter Type Default Description
client Any An already-constructed jira.JIRA client (or any stand-in used by tests), or None to clear it.

Method JiraInterface.get_site_url

Return the browser-facing site URL used for /browse/ links.

Same as server_url unless API calls go through the Atlassian gateway, in which case the site is read once from serverInfo and cached (site_url= / JIRA_SITE_URL skips the lookup).

get_site_url() -> str

Returns: str

Method JiraInterface.myself

Return the authenticated user projected to G9-safe identity fields.

myself() -> JiraPerson

Returns: JiraPerson

Raises:

  • JiraAuthError — If authentication fails or Jira returns an unusable current-user identity.

Method JiraInterface.verify_auth

Verify the interface is authenticated against Jira. Never raises.

Performs a raw GET /rest/api/{2,3}/myself so the Atlassian X-Seraph-Loginreason header is inspected — this catches the silent-auth-failure case where the API still returns HTTP 200 but serves anonymous content.

verify_auth() -> dict[str, Any]

Returns: dict[str, Any] — A result dict with at least authenticated: bool.

Method JiraInterface.get_issue

Fetch a single raw issue payload by key.

get_issue(key: str, *, fields: str | None = None, expand: str | None = None) -> dict[str, Any]

Parameter Type Default Description
key str Issue key, e.g. "NAV-9372".
fields str | None None Comma-separated field list, or None for the client's default.
expand str | None None Comma-separated expand list — pass "renderedFields,changelog" to get HTML descriptions and the changelog in one call.

Returns: dict[str, Any] — The raw issue dict (Issue.raw).

Method JiraInterface.search_issues

Yield raw issue dicts matching jql, paging until exhausted.

Deployment-aware pagination (FEAT-454 follow-up): Jira Cloud's offset-based /search endpoint is gone — pycontribs delegates search_issues(startAt=0) to the cursor-based enhanced_search_issues and raises for any startAt > 0 (jira/client.py:3629-3640). That response carries no total either, so an offset loop silently stopped after the first page (exactly page_size issues). On Cloud this therefore follows nextPageToken; on Server/DC it keeps the startAt loop.

An empty first page is not trusted as proof of an empty scope (the Jira Cloud AUTHENTICATED_FAILED trap) — it triggers a /myself probe, which raises on a definitive rejection.

search_issues(jql: str, *, fields: str | None = None, expand: str | None = None, page_size: int = 100) -> AsyncIterator[dict[str, Any]]

Parameter Type Default Description
jql str JQL scope.
fields str | None None Comma-separated field list, or None for all.
expand str | None None Comma-separated expand list.
page_size int 100 Page size for each underlying search call.

Returns: AsyncIterator[dict[str, Any]]

Method JiraInterface.approximate_issue_count

Return Jira Cloud's approximate issue count for jql.

A canary, never a gate: the endpoint is explicitly approximate, Cloud-only, and this method swallows every failure — callers use it to notice a sweep that came up short (the truncated-pagination class of bug), not to decide correctness.

approximate_issue_count(jql: str) -> int | None

Parameter Type Default Description
jql str JQL scope.

Returns: int | None — The approximate count, or None when the deployment does not offer the endpoint or the call failed.

Method JiraInterface.configure_connection_pool

Right-size the underlying requests connection pool.

pycontribs never mounts an adapter of its own, so the session inherits requests' default pool_maxsize=10. Driving more concurrent reads than that (see the sweep's concurrency) makes every overflow discard its connection and pay a fresh TLS handshake. Mounting a right-sized HTTPAdapter does not disturb the library's retry handling, which lives in ResilientSession, not in the adapter.

A no-op for size <= 10 (the default pool already covers it), and for any client without a mountable session.

configure_connection_pool(size: int) -> None

Parameter Type Default Description
size int Peak number of concurrent requests to size the pool for.

Method JiraInterface.get_changelog

Fetch the full changelog for an issue, paging as needed.

Mirrors JiraToolkit._get_full_changelog (jiratoolkit.py:1314).

get_changelog(key: str, page_size: int = 100) -> list[dict[str, Any]]

Parameter Type Default Description
key str Issue key.
page_size int 100 Page size for each underlying changelog call.

Returns: list[dict[str, Any]] — A flat list of raw changelog history entries.

Method JiraInterface.get_projects

List all accessible projects.

An empty result is probed via /myself before being trusted, for the same reason as :meth:search_issues.

get_projects() -> list[dict[str, Any]]

Returns: list[dict[str, Any]] — A list of {"id", "key", "name"} dicts.

Method JiraInterface.get_remote_links

Fetch raw remote-link entries for an issue.

Remote links come from a separate endpoint (/rest/api/2/issue/{key}/remotelink), not from fields.

get_remote_links(key: str) -> list[dict[str, Any]]

Parameter Type Default Description
key str Issue key.

Returns: list[dict[str, Any]] — A list of raw remote-link dicts (each RemoteLink.raw).

Method JiraInterface.list_projects

Raw client.projects() call — no empty-result auth probing.

Unlike :meth:get_projects, this never probes /myself on an empty result — callers needing that guard (JiraToolkit .jira_get_projects) already have their own probe and error message and must keep using it unchanged.

list_projects() -> list[dict[str, Any]]

Returns: list[dict[str, Any]] — A list of {"id", "key", "name"} dicts.

Method JiraInterface.fetch_issue_object

Fetch and return the raw pycontribs Issue object — transport only.

Callers needing a dict apply their own projection (e.g. JiraToolkit._issue_to_dict, which is LLM-shaped and not JiraIssue-shaped) — this method does not project at all, so that projection stays byte-identical wherever it already lives.

fetch_issue_object(key: str, *, fields: str | None = None, expand: str | None = None) -> Any

Parameter Type Default Description
key str Issue key, e.g. "NAV-9372".
fields str | None None Comma-separated field list, or None for the client's default.
expand str | None None Comma-separated expand list.

Returns: Any — The raw pycontribs Issue object.

Method JiraInterface.fetch_issues

Fetch raw pycontribs Issue objects for jql — transport only.

Mirrors JiraToolkit.jira_search_issues's own pre-existing loop verbatim (TASK-2402, G1): Jira Cloud's current search endpoint is cursor- (nextPageToken-) based, not offset-based, so this uses enhanced_search_issues rather than :meth:search_issues above (which wraps the older, still-valid-for-Server/DC startAt API). No auth probing on an empty result — callers needing that guard have their own, and none of the tool paths this feeds currently probe empty search results either.

fetch_issues(jql: str, *, fields: str | list[str] | None = None, expand: str | None = None, max_results: int | None = 100, page_size: int = 100) -> list[Any]

Parameter Type Default Description
jql str JQL scope.
fields str | list[str] | None None Comma-separated field string, a list of fields, or None for every field.
expand str | None None Comma-separated expand list.
max_results int | None 100 Cap on the number of issues to fetch; None fetches every matching issue.
page_size int 100 Page size per underlying call.

Returns: list[Any] — A list of raw pycontribs Issue objects, not projected.

Method JiraInterface.resolve_ac_field_id

Resolve the acceptance-criteria custom-field id.

JIRA_WIKI_AC_FIELD wins when set. Otherwise the field is matched by name (case-insensitive) against GET /rest/api/2/field, and the result is cached for the lifetime of this instance. Never raises — a Jira instance without the field is normal; the renderer then omits the acceptance-criteria section entirely rather than emitting an empty one, so determinism holds either way (spec §8, resolved).

resolve_ac_field_id() -> str | None

Returns: str | None — The resolved custom-field id, or None.

Alias JiraPerson

Re-exported from parrot.interfaces.jira.models.JiraPerson.

Attribute OAUTH_SCOPES

Type: tuple[str, ...]

Alias SiteUrlResolver

Re-exported from parrot.interfaces.jira.site.SiteUrlResolver.

Attribute logger

Alias parse_issue

Re-exported from parrot.interfaces.jira.parse.parse_issue.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally