fix problem when deleting MediaFile with MediaActor relations
This commit is contained in:
+15
-5
@@ -83,7 +83,7 @@ class CredentialsValidationException(Exception):
|
||||
Raised when login failed or token is outdated.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class EndPointNotAvailableException(Exception):
|
||||
"""
|
||||
Raised when calling an not existing endpoint.
|
||||
@@ -114,7 +114,7 @@ class Server:
|
||||
password: str
|
||||
timeout: int
|
||||
|
||||
def login(self, log: Logger, refresh_token: bool= False):
|
||||
def login(self, log: Logger, refresh_token: bool = False):
|
||||
"""
|
||||
get token from server by calling login endpoint.
|
||||
"""
|
||||
@@ -177,14 +177,16 @@ class Server:
|
||||
raise EndPointNotAvailableException
|
||||
data = update.json()
|
||||
return data
|
||||
|
||||
|
||||
def create(self, log: Logger, table: str, new_item: dict):
|
||||
"""
|
||||
Create item in Kontor-API instance.
|
||||
"""
|
||||
url: str = f"{self.url}/{MAPPING[table]}"
|
||||
headers: Dict[str, str] = {"Authorization": f"Bearer {self.token}"}
|
||||
create = requests.post(url, headers=headers, json=new_item, timeout=self.timeout)
|
||||
create = requests.post(
|
||||
url, headers=headers, json=new_item, timeout=self.timeout
|
||||
)
|
||||
log.info(f"Status: {create.status_code}")
|
||||
if create.status_code == 404:
|
||||
raise EndPointNotAvailableException
|
||||
@@ -192,7 +194,15 @@ class Server:
|
||||
log.fatal("Create Exception %s", create.json())
|
||||
data = create.json()
|
||||
return data
|
||||
|
||||
|
||||
def delete(self, log: Logger, table: str, item_id: str):
|
||||
"""
|
||||
Delete item in Kontor-API instance.
|
||||
"""
|
||||
url: str = f"{self.url}/{MAPPING[table]}/{item_id}"
|
||||
headers: Dict[str, str] = {"Authorization": f"Bearer {self.token}"}
|
||||
delete = requests.delete(url, headers=headers, timeout=self.timeout)
|
||||
log.info(f"Status: {delete.status_code}")
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user