Support for policies (ro)
This commit is contained in:
24
hsapi_client/policies.py
Normal file
24
hsapi_client/policies.py
Normal file
@ -0,0 +1,24 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
# from datetime import datetime
|
||||
|
||||
from .model import HSAPICall
|
||||
from .schemas import v1Policy
|
||||
|
||||
|
||||
class v1PutPolicyResponse(BaseModel):
|
||||
policy: str = Field(alias="policy", default=None)
|
||||
|
||||
|
||||
class Policy(HSAPICall):
|
||||
|
||||
objectPath = "policy"
|
||||
|
||||
def get(self) -> v1Policy:
|
||||
response = self.call('get')
|
||||
return v1Policy(**response.json())
|
||||
|
||||
def put(self, data: v1Policy) -> v1Policy:
|
||||
policy_txt = v1PutPolicyResponse(policy=data.json)
|
||||
response = self.call('put', data=policy_txt)
|
||||
return v1Policy(**response.json())
|
||||
Reference in New Issue
Block a user