update rest client to reflect latest openapi spec

This commit is contained in:
Tomas Groth 2024-04-24 21:49:26 +02:00
parent 2e810294f5
commit 36fc129bb2
4 changed files with 84 additions and 32 deletions

View File

@ -13,6 +13,8 @@ class ItemInfo(BaseModel):
version: Optional[int] = Field(alias="version", default=None)
created: Optional[str] = Field(alias="created", default=None)
user: Optional[str] = Field(alias="user", default=None)
updated: Optional[str] = Field(alias="updated", default=None)
timestamp: Optional[str] = Field(alias="timestamp", default=None)
title: Optional[str] = Field(alias="title", default=None)

View File

@ -13,9 +13,9 @@ class TextItem(BaseModel):
version: Optional[int] = Field(alias="version", default=None)
created: Optional[str] = Field(alias="created", default=None)
user: Optional[str] = Field(alias="user", default=None)
updated: Optional[str] = Field(alias="updated", default=None)
timestamp: Optional[str] = Field(alias="timestamp", default=None)
title: Optional[str] = Field(alias="title", default=None)

View File

@ -7,11 +7,11 @@ from ..api_config import APIConfig, HTTPException
from ..models import *
def getCustomslideList(churchId: str, api_config_override: Optional[APIConfig] = None) -> ItemList:
def getCustomslideList(api_config_override: Optional[APIConfig] = None) -> ItemList:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom-list"
path = f"/custom-list"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -34,11 +34,11 @@ def getCustomslideList(churchId: str, api_config_override: Optional[APIConfig] =
return ItemList(**response.json()) if response.json() is not None else ItemList()
def getCustomslide(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
def getCustomslide(uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom/{uuid}"
path = f"/custom/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -61,13 +61,11 @@ def getCustomslide(churchId: str, uuid: str, api_config_override: Optional[APICo
return TextItem(**response.json()) if response.json() is not None else TextItem()
def updateCustomslide(
churchId: str, uuid: str, data: TextItem, api_config_override: Optional[APIConfig] = None
) -> None:
def updateCustomslide(uuid: str, data: TextItem, api_config_override: Optional[APIConfig] = None) -> None:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom/{uuid}"
path = f"/custom/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -86,11 +84,11 @@ def updateCustomslide(
return None
def deleteCustomslide(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> None:
def deleteCustomslide(uuid: str, api_config_override: Optional[APIConfig] = None) -> None:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom/{uuid}"
path = f"/custom/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -113,13 +111,11 @@ def deleteCustomslide(churchId: str, uuid: str, api_config_override: Optional[AP
return None
def getCustomslideVersion(
churchId: str, uuid: str, version: int, api_config_override: Optional[APIConfig] = None
) -> TextItem:
def getCustomslideVersion(uuid: str, version: int, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom/{uuid}/{version}"
path = f"/custom/{uuid}/{version}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -142,11 +138,11 @@ def getCustomslideVersion(
return TextItem(**response.json()) if response.json() is not None else TextItem()
def getCustomslideHistory(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
def getCustomslideHistory(uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/custom-history/{uuid}"
path = f"/custom-history/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",

View File

@ -7,11 +7,11 @@ from ..api_config import APIConfig, HTTPException
from ..models import *
def getSongList(churchId: str, api_config_override: Optional[APIConfig] = None) -> ItemList:
def getSongList(api_config_override: Optional[APIConfig] = None) -> ItemList:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song-list"
path = f"/song-list"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -34,11 +34,38 @@ def getSongList(churchId: str, api_config_override: Optional[APIConfig] = None)
return ItemList(**response.json()) if response.json() is not None else ItemList()
def getSong(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
def getSongListChangesSince(sinceDateTime: str, api_config_override: Optional[APIConfig] = None) -> ItemList:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song/{uuid}"
path = f"/song-list/changes/{sinceDateTime}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer { api_config.get_access_token() }",
}
query_params: Dict[str, Any] = {}
query_params = {key: value for (key, value) in query_params.items() if value is not None}
response = requests.request(
"get",
f"{base_path}{path}",
headers=headers,
params=query_params,
verify=api_config.verify,
)
if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
return ItemList(**response.json()) if response.json() is not None else ItemList()
def getSong(uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/song/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -61,11 +88,11 @@ def getSong(churchId: str, uuid: str, api_config_override: Optional[APIConfig] =
return TextItem(**response.json()) if response.json() is not None else TextItem()
def updateSong(churchId: str, uuid: str, data: TextItem, api_config_override: Optional[APIConfig] = None) -> None:
def updateSong(uuid: str, data: TextItem, api_config_override: Optional[APIConfig] = None) -> None:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song/{uuid}"
path = f"/song/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -84,11 +111,11 @@ def updateSong(churchId: str, uuid: str, data: TextItem, api_config_override: Op
return None
def deleteSong(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> None:
def deleteSong(uuid: str, api_config_override: Optional[APIConfig] = None) -> None:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song/{uuid}"
path = f"/song/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -111,11 +138,11 @@ def deleteSong(churchId: str, uuid: str, api_config_override: Optional[APIConfig
return None
def getSongVersion(churchId: str, uuid: str, version: int, api_config_override: Optional[APIConfig] = None) -> TextItem:
def getSongVersion(uuid: str, version: int, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song/{uuid}/{version}"
path = f"/song/{uuid}/{version}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -138,11 +165,11 @@ def getSongVersion(churchId: str, uuid: str, version: int, api_config_override:
return TextItem(**response.json()) if response.json() is not None else TextItem()
def getSongHistory(churchId: str, uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
def getSongHistory(uuid: str, api_config_override: Optional[APIConfig] = None) -> TextItem:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/{churchId}/song-history/{uuid}"
path = f"/song-history/{uuid}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
@ -163,3 +190,30 @@ def getSongHistory(churchId: str, uuid: str, api_config_override: Optional[APICo
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
return TextItem(**response.json()) if response.json() is not None else TextItem()
def getCustomSlideListChangesSince(sinceDateTime: str, api_config_override: Optional[APIConfig] = None) -> ItemList:
api_config = api_config_override if api_config_override else APIConfig()
base_path = api_config.base_path
path = f"/custom-list/changes/{sinceDateTime}"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer { api_config.get_access_token() }",
}
query_params: Dict[str, Any] = {}
query_params = {key: value for (key, value) in query_params.items() if value is not None}
response = requests.request(
"get",
f"{base_path}{path}",
headers=headers,
params=query_params,
verify=api_config.verify,
)
if response.status_code != 200:
raise HTTPException(response.status_code, f" failed with status code: {response.status_code}")
return ItemList(**response.json()) if response.json() is not None else ItemList()