Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ if outcome.status != "COMPLETED":

`head_commit_sha` is a full SHA of 40 or 64 hexadecimal characters; any other value raises `ValueError` before a request. A review pinned to another head ends the wait on the read that names it. Its outcome is `INCOMPLETE` whatever the review's own status, its last gap has the reason code `HEAD_COMMIT_MISMATCH`, and `reason` says that the review is pinned to another head commit. A settled review that names no head has `HEAD_COMMIT_UNAVAILABLE` instead and is not `COMPLETED` either. `outcome.review.head_commit_sha` is the commit the review is pinned to. A patch review's head is a derived revision ID, so no commit matches it. In a GitHub Actions `pull_request` job, `GITHUB_SHA` is the merge commit; pass the pull request's head.

## Deploy verifications and scans

Inspect deployment verification records for a specific commit SHA using `get_commit_deploy_verifications`:

```python
verifications = client.get_commit_deploy_verifications(organization_id, repository_id, commit_sha)
for deploy in verifications.deploys:
print(deploy.environment_id, deploy.state)
```

To request an ad-hoc scan on a repository, use `request_scan`:

```python
from uuid import uuid4
from proofline import ScanRequestBody

response = client.request_scan(
organization_id,
repository_id,
body=ScanRequestBody(
budget_credits=100,
commit_sha=commit_sha,
request_id=uuid4(),
),
)
print(response.outcome, response.resolution_id)
```

Both methods accept canonical `organization_id` / `repository_id` or `org_id` / `repo_id` aliases. `get_commit_deploy_verifications` validates that `commit_sha` is a full 40- or 64-character hexadecimal SHA before sending the request.

## Review exports

`export_reviews` reads one CSV or NDJSON page over the bounded transport. Export tokens require `analytics:read`.
Expand Down
2 changes: 2 additions & 0 deletions proofline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ._generated.models import (
AgentSession,
AgentVendor,
CommitDeployVerifications,
CommitReviewRequest,
CommitReviewResponse,
CoverageUploadRequest,
Expand Down Expand Up @@ -44,6 +45,7 @@
"AssessmentGap",
"AsyncProoflineClient",
"CheckGap",
"CommitDeployVerifications",
"CommitReviewRequest",
"CommitReviewResponse",
"CoverageUploadRequest",
Expand Down
79 changes: 0 additions & 79 deletions proofline/_generated/api/operations.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,11 @@
"""Typed methods generated from the public operations without custom adapters."""

from typing import cast
from uuid import UUID

from ... import _transport
from ..client import AuthenticatedClient
from ..models.commit_deploy_verifications import CommitDeployVerifications
from ..models.scan_request_body import ScanRequestBody
from ..models.scan_response import ScanResponse
from .default import get_commit_deploy_verifications as operation_get_commit_deploy_verifications
from .default import request_scan as operation_request_scan


class Operations:
_api: AuthenticatedClient

def get_commit_deploy_verifications(
self,
org_id: UUID,
repo_id: UUID,
commit_sha: str,
) -> CommitDeployVerifications:
with _transport.operation_errors():
response = operation_get_commit_deploy_verifications.sync_detailed(
client=self._api,
org_id=org_id,
repo_id=repo_id,
commit_sha=commit_sha,
)
if not (response.status_code == 200):
raise _transport.invalid_response()
return cast(CommitDeployVerifications, response.parsed)

def request_scan(
self,
org_id: UUID,
repo_id: UUID,
*,
body: ScanRequestBody,
) -> ScanResponse:
with _transport.operation_errors():
response = operation_request_scan.sync_detailed(
client=self._api,
org_id=org_id,
repo_id=repo_id,
body=body,
)
if not (response.status_code == 200):
raise _transport.invalid_response()
return cast(ScanResponse, response.parsed)


class AsyncOperations:
_api: AuthenticatedClient

async def get_commit_deploy_verifications(
self,
org_id: UUID,
repo_id: UUID,
commit_sha: str,
) -> CommitDeployVerifications:
with _transport.operation_errors():
response = await operation_get_commit_deploy_verifications.asyncio_detailed(
client=self._api,
org_id=org_id,
repo_id=repo_id,
commit_sha=commit_sha,
)
if not (response.status_code == 200):
raise _transport.invalid_response()
return cast(CommitDeployVerifications, response.parsed)

async def request_scan(
self,
org_id: UUID,
repo_id: UUID,
*,
body: ScanRequestBody,
) -> ScanResponse:
with _transport.operation_errors():
response = await operation_request_scan.asyncio_detailed(
client=self._api,
org_id=org_id,
repo_id=repo_id,
body=body,
)
if not (response.status_code == 200):
raise _transport.invalid_response()
return cast(ScanResponse, response.parsed)
108 changes: 108 additions & 0 deletions proofline/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
get_agent_session,
get_agent_session_prompt,
get_assessment,
get_commit_deploy_verifications,
get_deployment_review,
get_finding,
get_finding_fix_prompt,
Expand All @@ -34,6 +35,7 @@
request_file_review,
request_patch_review,
request_review,
request_scan,
rerun_review,
start_agent_session,
stop_review,
Expand All @@ -44,6 +46,7 @@
from ._generated.models.agent_session import AgentSession
from ._generated.models.agent_session_prompt_type_0 import AgentSessionPromptType0
from ._generated.models.agent_session_prompt_type_1 import AgentSessionPromptType1
from ._generated.models.commit_deploy_verifications import CommitDeployVerifications
from ._generated.models.commit_review_request import CommitReviewRequest
from ._generated.models.commit_review_response import CommitReviewResponse
from ._generated.models.coverage_upload_request import CoverageUploadRequest
Expand All @@ -67,6 +70,8 @@
from ._generated.models.review_summary import ReviewSummary
from ._generated.models.run_now_request import RunNowRequest
from ._generated.models.run_now_response import RunNowResponse
from ._generated.models.scan_request_body import ScanRequestBody
from ._generated.models.scan_response import ScanResponse
from ._generated.models.start_session import StartSession
from ._generated.models.stop_response import StopResponse
from ._generated.types import UNSET, Response, Unset
Expand Down Expand Up @@ -153,6 +158,23 @@ def _page_limits(page_size: int, max_pages: int, max_items: int) -> None:
)


def _resolve_id(
canonical: UUID | None,
alias: UUID | None,
name: str,
alias_name: str,
) -> UUID:
if canonical is not None and alias is not None:
if canonical != alias:
raise ValueError(f"Conflicting arguments for {name} and {alias_name}.")
return canonical
if canonical is not None:
return canonical
if alias is not None:
return alias
raise TypeError(f"Missing required argument: {name!r} (or {alias_name!r}).")


def _head_commit(value: str | None) -> None:
# Only a full SHA names one exact commit; a branch or an abbreviation does not.
if value is not None and (
Expand Down Expand Up @@ -507,6 +529,49 @@ def request_commit_review(
def rerun_review(self, organization_id: UUID, review_id: UUID) -> RerunResponse:
return self._call(rerun_review.sync_detailed, RerunResponse, organization_id, review_id)

def get_commit_deploy_verifications(
self,
organization_id: UUID | None = None,
repository_id: UUID | None = None,
commit_sha: str | None = None,
*,
org_id: UUID | None = None,
repo_id: UUID | None = None,
) -> CommitDeployVerifications:
"""Read deployment verifications for a specific commit SHA."""
resolved_org_id = _resolve_id(organization_id, org_id, "organization_id", "org_id")
resolved_repo_id = _resolve_id(repository_id, repo_id, "repository_id", "repo_id")
if commit_sha is None:
raise TypeError("Missing required argument: 'commit_sha'.")
_head_commit(commit_sha)
return self._call(
get_commit_deploy_verifications.sync_detailed,
CommitDeployVerifications,
resolved_org_id,
resolved_repo_id,
commit_sha,
)

def request_scan(
self,
organization_id: UUID | None = None,
repository_id: UUID | None = None,
*,
body: ScanRequestBody,
org_id: UUID | None = None,
repo_id: UUID | None = None,
) -> ScanResponse:
"""Request an asynchronous security or configuration scan for a repository."""
resolved_org_id = _resolve_id(organization_id, org_id, "organization_id", "org_id")
resolved_repo_id = _resolve_id(repository_id, repo_id, "repository_id", "repo_id")
return self._call(
request_scan.sync_detailed,
ScanResponse,
resolved_org_id,
resolved_repo_id,
body=body,
)

def iter_reviews(
self,
organization_id: UUID,
Expand Down Expand Up @@ -902,6 +967,49 @@ async def rerun_review(self, organization_id: UUID, review_id: UUID) -> RerunRes
rerun_review.asyncio_detailed, RerunResponse, organization_id, review_id
)

async def get_commit_deploy_verifications(
self,
organization_id: UUID | None = None,
repository_id: UUID | None = None,
commit_sha: str | None = None,
*,
org_id: UUID | None = None,
repo_id: UUID | None = None,
) -> CommitDeployVerifications:
"""Read deployment verifications for a specific commit SHA."""
resolved_org_id = _resolve_id(organization_id, org_id, "organization_id", "org_id")
resolved_repo_id = _resolve_id(repository_id, repo_id, "repository_id", "repo_id")
if commit_sha is None:
raise TypeError("Missing required argument: 'commit_sha'.")
_head_commit(commit_sha)
return await self._call(
get_commit_deploy_verifications.asyncio_detailed,
CommitDeployVerifications,
resolved_org_id,
resolved_repo_id,
commit_sha,
)

async def request_scan(
self,
organization_id: UUID | None = None,
repository_id: UUID | None = None,
*,
body: ScanRequestBody,
org_id: UUID | None = None,
repo_id: UUID | None = None,
) -> ScanResponse:
"""Request an asynchronous security or configuration scan for a repository."""
resolved_org_id = _resolve_id(organization_id, org_id, "organization_id", "org_id")
resolved_repo_id = _resolve_id(repository_id, repo_id, "repository_id", "repo_id")
return await self._call(
request_scan.asyncio_detailed,
ScanResponse,
resolved_org_id,
resolved_repo_id,
body=body,
)

async def iter_reviews(
self,
organization_id: UUID,
Expand Down
Loading