Support for policies (ro)

This commit is contained in:
2024-10-04 12:57:12 +02:00
parent db7be9e8e1
commit 075b8767e6
6 changed files with 403 additions and 112 deletions

24
hsapi_client/policies.py Normal file
View 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())