inttegro.async_resources.operating_policies

Operating-policy operations.

 1# Generated by scripts/generate_async_resources.py; do not edit by hand.
 2"""Operating-policy operations."""
 3from __future__ import annotations
 4from typing import cast
 5from ..async_http_client import AsyncHttpClient
 6from inttegro.operating_policy import CreateRequest, LookupRequest, OperatingPolicy, Page, PageRequest, UpdateRequest
 7
 8class AsyncOperatingPolicies:
 9    """Create, look up, and version reusable operating policies."""
10
11    def __init__(self, http: AsyncHttpClient) -> None:
12        self.http = http
13
14    async def create(self, payload: CreateRequest) -> OperatingPolicy:
15        """Create the first immutable version of an operating policy."""
16        return cast(OperatingPolicy, await self.http.post('/operating_policies/create', payload))
17
18    async def lookup(self, operating_policy_id: str | LookupRequest, version: int | None=None) -> OperatingPolicy:
19        """Return the latest policy by default, or one exact immutable version."""
20        if isinstance(operating_policy_id, LookupRequest):
21            if version is not None:
22                raise ValueError('version must be supplied in LookupRequest, not twice')
23            payload = operating_policy_id
24        else:
25            payload = LookupRequest(operating_policy_id=operating_policy_id) if version is None else LookupRequest(operating_policy_id=operating_policy_id, version=version)
26        return cast(OperatingPolicy, await self.http.post('/operating_policies/lookup', payload))
27
28    async def page(self, payload: PageRequest) -> Page:
29        """List immutable versions of one operating policy."""
30        return cast(Page, await self.http.post('/operating_policies/page', payload))
31
32    async def update(self, payload: UpdateRequest) -> OperatingPolicy:
33        """Create and activate a new immutable operating-policy version."""
34        return cast(OperatingPolicy, await self.http.post('/operating_policies/update', payload))
class AsyncOperatingPolicies:
 9class AsyncOperatingPolicies:
10    """Create, look up, and version reusable operating policies."""
11
12    def __init__(self, http: AsyncHttpClient) -> None:
13        self.http = http
14
15    async def create(self, payload: CreateRequest) -> OperatingPolicy:
16        """Create the first immutable version of an operating policy."""
17        return cast(OperatingPolicy, await self.http.post('/operating_policies/create', payload))
18
19    async def lookup(self, operating_policy_id: str | LookupRequest, version: int | None=None) -> OperatingPolicy:
20        """Return the latest policy by default, or one exact immutable version."""
21        if isinstance(operating_policy_id, LookupRequest):
22            if version is not None:
23                raise ValueError('version must be supplied in LookupRequest, not twice')
24            payload = operating_policy_id
25        else:
26            payload = LookupRequest(operating_policy_id=operating_policy_id) if version is None else LookupRequest(operating_policy_id=operating_policy_id, version=version)
27        return cast(OperatingPolicy, await self.http.post('/operating_policies/lookup', payload))
28
29    async def page(self, payload: PageRequest) -> Page:
30        """List immutable versions of one operating policy."""
31        return cast(Page, await self.http.post('/operating_policies/page', payload))
32
33    async def update(self, payload: UpdateRequest) -> OperatingPolicy:
34        """Create and activate a new immutable operating-policy version."""
35        return cast(OperatingPolicy, await self.http.post('/operating_policies/update', payload))

Create, look up, and version reusable operating policies.

AsyncOperatingPolicies(http: inttegro.async_http_client.AsyncHttpClient)
12    def __init__(self, http: AsyncHttpClient) -> None:
13        self.http = http
http
15    async def create(self, payload: CreateRequest) -> OperatingPolicy:
16        """Create the first immutable version of an operating policy."""
17        return cast(OperatingPolicy, await self.http.post('/operating_policies/create', payload))

Create the first immutable version of an operating policy.

async def lookup( self, operating_policy_id: str | inttegro.operating_policy.LookupRequest, version: int | None = None) -> inttegro.operating_policy.OperatingPolicy:
19    async def lookup(self, operating_policy_id: str | LookupRequest, version: int | None=None) -> OperatingPolicy:
20        """Return the latest policy by default, or one exact immutable version."""
21        if isinstance(operating_policy_id, LookupRequest):
22            if version is not None:
23                raise ValueError('version must be supplied in LookupRequest, not twice')
24            payload = operating_policy_id
25        else:
26            payload = LookupRequest(operating_policy_id=operating_policy_id) if version is None else LookupRequest(operating_policy_id=operating_policy_id, version=version)
27        return cast(OperatingPolicy, await self.http.post('/operating_policies/lookup', payload))

Return the latest policy by default, or one exact immutable version.

async def page( self, payload: inttegro.operating_policy.PageRequest) -> inttegro.operating_policy.Page:
29    async def page(self, payload: PageRequest) -> Page:
30        """List immutable versions of one operating policy."""
31        return cast(Page, await self.http.post('/operating_policies/page', payload))

List immutable versions of one operating policy.

33    async def update(self, payload: UpdateRequest) -> OperatingPolicy:
34        """Create and activate a new immutable operating-policy version."""
35        return cast(OperatingPolicy, await self.http.post('/operating_policies/update', payload))

Create and activate a new immutable operating-policy version.