"""Requests to ows-abacus-state.""" from typing import Dict, List, Optional from src.connectors.requests import get, put from src.exceptions import OwsStateException from src.models import AbacusState SERVICE = 'ows-abacus-state' def get_abacus_states( parent_table_name: str, parent_table_id: int ) -> Optional[List[AbacusState]]: """Get abacus states for specified parent_table and id.""" path = f'/abacus-state/{parent_table_name}/{parent_table_id}' response = get(SERVICE, path) if response.status_code != 200: raise OwsStateException(f'ERROR in GET {path}') return [AbacusState.model_validate(elem) for elem in response.json()] def update_abacus_state_by_id(abacus_state_id: int, body: Dict[str, str]) -> None: """Update single abacus state.""" path = f'/abacus-state/{abacus_state_id}' response = put(SERVICE, path, body) if response.status_code != 200: raise OwsStateException(f'ERROR in PUT {path}')