inttegro.resources.operating_policies
Operating-policy operations.
1"""Operating-policy operations.""" 2 3from __future__ import annotations 4 5from typing import cast 6 7from ..http_client import HttpClient 8from inttegro.operating_policy import ( 9 CreateRequest, 10 LookupRequest, 11 OperatingPolicy, 12 Page, 13 PageRequest, 14 UpdateRequest, 15) 16 17 18class OperatingPolicies: 19 """Create, look up, and version reusable operating policies.""" 20 21 def __init__(self, http: HttpClient) -> None: 22 self.http = http 23 24 def create(self, payload: CreateRequest) -> OperatingPolicy: 25 """Create the first immutable version of an operating policy.""" 26 return cast(OperatingPolicy, self.http.post("/operating_policies/create", payload)) 27 28 def lookup( 29 self, 30 operating_policy_id: str | LookupRequest, 31 version: int | None = None, 32 ) -> OperatingPolicy: 33 """Return the latest policy by default, or one exact immutable version.""" 34 if isinstance(operating_policy_id, LookupRequest): 35 if version is not None: 36 raise ValueError("version must be supplied in LookupRequest, not twice") 37 payload = operating_policy_id 38 else: 39 payload = ( 40 LookupRequest(operating_policy_id=operating_policy_id) 41 if version is None 42 else LookupRequest(operating_policy_id=operating_policy_id, version=version) 43 ) 44 return cast(OperatingPolicy, self.http.post("/operating_policies/lookup", payload)) 45 46 def page(self, payload: PageRequest) -> Page: 47 """List immutable versions of one operating policy.""" 48 return cast(Page, self.http.post("/operating_policies/page", payload)) 49 50 def update(self, payload: UpdateRequest) -> OperatingPolicy: 51 """Create and activate a new immutable operating-policy version.""" 52 return cast(OperatingPolicy, self.http.post("/operating_policies/update", payload))
class
OperatingPolicies:
19class OperatingPolicies: 20 """Create, look up, and version reusable operating policies.""" 21 22 def __init__(self, http: HttpClient) -> None: 23 self.http = http 24 25 def create(self, payload: CreateRequest) -> OperatingPolicy: 26 """Create the first immutable version of an operating policy.""" 27 return cast(OperatingPolicy, self.http.post("/operating_policies/create", payload)) 28 29 def lookup( 30 self, 31 operating_policy_id: str | LookupRequest, 32 version: int | None = None, 33 ) -> OperatingPolicy: 34 """Return the latest policy by default, or one exact immutable version.""" 35 if isinstance(operating_policy_id, LookupRequest): 36 if version is not None: 37 raise ValueError("version must be supplied in LookupRequest, not twice") 38 payload = operating_policy_id 39 else: 40 payload = ( 41 LookupRequest(operating_policy_id=operating_policy_id) 42 if version is None 43 else LookupRequest(operating_policy_id=operating_policy_id, version=version) 44 ) 45 return cast(OperatingPolicy, self.http.post("/operating_policies/lookup", payload)) 46 47 def page(self, payload: PageRequest) -> Page: 48 """List immutable versions of one operating policy.""" 49 return cast(Page, self.http.post("/operating_policies/page", payload)) 50 51 def update(self, payload: UpdateRequest) -> OperatingPolicy: 52 """Create and activate a new immutable operating-policy version.""" 53 return cast(OperatingPolicy, self.http.post("/operating_policies/update", payload))
Create, look up, and version reusable operating policies.
def
create( self, payload: inttegro.operating_policy.CreateRequest) -> inttegro.operating_policy.OperatingPolicy:
25 def create(self, payload: CreateRequest) -> OperatingPolicy: 26 """Create the first immutable version of an operating policy.""" 27 return cast(OperatingPolicy, self.http.post("/operating_policies/create", payload))
Create the first immutable version of an operating policy.
def
lookup( self, operating_policy_id: str | inttegro.operating_policy.LookupRequest, version: int | None = None) -> inttegro.operating_policy.OperatingPolicy:
29 def lookup( 30 self, 31 operating_policy_id: str | LookupRequest, 32 version: int | None = None, 33 ) -> OperatingPolicy: 34 """Return the latest policy by default, or one exact immutable version.""" 35 if isinstance(operating_policy_id, LookupRequest): 36 if version is not None: 37 raise ValueError("version must be supplied in LookupRequest, not twice") 38 payload = operating_policy_id 39 else: 40 payload = ( 41 LookupRequest(operating_policy_id=operating_policy_id) 42 if version is None 43 else LookupRequest(operating_policy_id=operating_policy_id, version=version) 44 ) 45 return cast(OperatingPolicy, self.http.post("/operating_policies/lookup", payload))
Return the latest policy by default, or one exact immutable version.
47 def page(self, payload: PageRequest) -> Page: 48 """List immutable versions of one operating policy.""" 49 return cast(Page, self.http.post("/operating_policies/page", payload))
List immutable versions of one operating policy.
def
update( self, payload: inttegro.operating_policy.UpdateRequest) -> inttegro.operating_policy.OperatingPolicy:
51 def update(self, payload: UpdateRequest) -> OperatingPolicy: 52 """Create and activate a new immutable operating-policy version.""" 53 return cast(OperatingPolicy, self.http.post("/operating_policies/update", payload))
Create and activate a new immutable operating-policy version.