Skip to content
API Reference

Get a specific policy version

zones.policies.versions.retrieve(strversion_id, VersionRetrieveParams**kwargs) -> PolicyVersion
GET/zones/{zone_id}/policies/{policy_id}/versions/{version_id}

Get a specific policy version

ParametersExpand Collapse
zone_id: str
policy_id: str
version_id: str
format: Optional[Literal["cedar", "json"]]

Policy representation format. json returns cedar_json, cedar returns cedar_raw.

Accepts one of the following:
"cedar"
"json"
x_api_version: Optional[str]
x_client_request_id: Optional[str]
formatuuid
ReturnsExpand Collapse
class PolicyVersion:
id: str
created_at: datetime
formatdate-time
created_by: str
policy_id: str
schema_version: str

Schema version this policy was validated against when created.

sha: str

Hex-encoded content hash

version: int
zone_id: str
archived_at: Optional[datetime]
formatdate-time
archived_by: Optional[str]
cedar_json: Optional[object]

Cedar policy in JSON representation. Populated when format=json (default).

cedar_raw: Optional[str]

Cedar policy in human-readable syntax. Populated when format=cedar.

Get a specific policy version

from keycardai_api import KeycardAPI

client = KeycardAPI()
policy_version = client.zones.policies.versions.retrieve(
    version_id="version_id",
    zone_id="zone_id",
    policy_id="policy_id",
)
print(policy_version.id)
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "policy_id": "policy_id",
  "schema_version": "schema_version",
  "sha": "sha",
  "version": 0,
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "archived_by": "archived_by",
  "cedar_json": {},
  "cedar_raw": "cedar_raw"
}
Returns Examples
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": "created_by",
  "policy_id": "policy_id",
  "schema_version": "schema_version",
  "sha": "sha",
  "version": 0,
  "zone_id": "zone_id",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "archived_by": "archived_by",
  "cedar_json": {},
  "cedar_raw": "cedar_raw"
}