Client
client
¶
Client for the Pretalx API
Documentation: https://docs.pretalx.org/api/resources/index.html
ToDo
- add additional parameters explicitly like querying according to the API
JSON = Union[JSONObj, JSONLst]
module-attribute
¶
Type of the JSON response as returned by the Pretalx API
JSONLst = List[JSONObj]
module-attribute
¶
Type of a JSON list of JSON objects
JSONObj = Dict[str, Any]
module-attribute
¶
Type of a JSON object (without recursion)
QueryParamType = Union[Dict[Any, Union[Any, List[Any]]], QueryParams]
module-attribute
¶
Type for the optional parameters to the Pretalx API
T = TypeVar('T', bound=BaseModel)
module-attribute
¶
PretalxClient(config: Optional[Config] = None, blocking: bool = False)
¶
Client for the Pretalx API
Source code in src/pytanis/pretalx/client.py
def __init__(self, config: Optional[Config] = None, blocking: bool = False):
if config is None:
config = get_cfg()
self._config = config
self._get_throttled = self._get
self.blocking = blocking
self.set_throttling(1, 2) # we are nice by default
blocking = blocking
instance-attribute
¶
answer(event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Answer
¶
Returns a specific answer
Source code in src/pytanis/pretalx/client.py
def answer(self, event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Answer:
"""Returns a specific answer"""
return self._endpoint_id(Answer, event_slug, "answers", id, params=params)
answers(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Answer]]
¶
Lists all answers and their details
Source code in src/pytanis/pretalx/client.py
def answers(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Answer]]:
"""Lists all answers and their details"""
return self._endpoint_lst(Answer, event_slug, "answers", params=params)
event(event_slug: str, *, params: Optional[QueryParamType] = None) -> Event
¶
Returns detailed information about a specific event
Source code in src/pytanis/pretalx/client.py
def event(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Event:
"""Returns detailed information about a specific event"""
endpoint = f"/api/events/{event_slug}/"
result = self._get_one(endpoint, params)
_logger.debug("result", resp=result)
return Event.parse_obj(result)
events(*, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Event]]
¶
Lists all events and their details
Source code in src/pytanis/pretalx/client.py
def events(self, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Event]]:
"""Lists all events and their details"""
count, results = self._get_many("/api/events/", params)
events = iter(_logger.debug("result", resp=r) or Event.parse_obj(r) for r in results)
return count, events
me() -> Me
¶
Returns what Pretalx knows about myself
Source code in src/pytanis/pretalx/client.py
def me(self) -> Me:
"""Returns what Pretalx knows about myself"""
result = self._get_one("/api/me")
return Me.parse_obj(result)
question(event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Question
¶
Returns a specific question
Source code in src/pytanis/pretalx/client.py
def question(self, event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Question:
"""Returns a specific question"""
return self._endpoint_id(Question, event_slug, "questions", id, params=params)
questions(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Question]]
¶
Lists all questions and their details
Source code in src/pytanis/pretalx/client.py
def questions(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Question]]:
"""Lists all questions and their details"""
return self._endpoint_lst(Question, event_slug, "questions", params=params)
review(event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Review
¶
Returns a specific review
Source code in src/pytanis/pretalx/client.py
def review(self, event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Review:
"""Returns a specific review"""
return self._endpoint_id(Review, event_slug, "reviews", id, params=params)
reviews(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Review]]
¶
Lists all reviews and their details
Source code in src/pytanis/pretalx/client.py
def reviews(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Review]]:
"""Lists all reviews and their details"""
return self._endpoint_lst(Review, event_slug, "reviews", params=params)
room(event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Room
¶
Returns a specific room
Source code in src/pytanis/pretalx/client.py
def room(self, event_slug: str, id: int, *, params: Optional[QueryParamType] = None) -> Room:
"""Returns a specific room"""
return self._endpoint_id(Room, event_slug, "rooms", id, params=params)
rooms(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Room]]
¶
Lists all rooms and their details
Source code in src/pytanis/pretalx/client.py
def rooms(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Room]]:
"""Lists all rooms and their details"""
return self._endpoint_lst(Room, event_slug, "rooms", params=params)
set_throttling(calls: int, seconds: int)
¶
Throttle the number of calls per seconds to the Pretalx API
Source code in src/pytanis/pretalx/client.py
def set_throttling(self, calls: int, seconds: int):
"""Throttle the number of calls per seconds to the Pretalx API"""
_logger.info("throttling", calls=calls, seconds=seconds)
self._get_throttled = throttle(calls, seconds)(self._get)
speaker(event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Speaker
¶
Returns a specific speaker
Source code in src/pytanis/pretalx/client.py
def speaker(self, event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Speaker:
"""Returns a specific speaker"""
return self._endpoint_id(Speaker, event_slug, "speakers", code, params=params)
speakers(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Speaker]]
¶
Lists all speakers and their details
Source code in src/pytanis/pretalx/client.py
def speakers(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Speaker]]:
"""Lists all speakers and their details"""
return self._endpoint_lst(Speaker, event_slug, "speakers", params=params)
submission(event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Submission
¶
Returns a specific submission
Source code in src/pytanis/pretalx/client.py
def submission(self, event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Submission:
"""Returns a specific submission"""
return self._endpoint_id(Submission, event_slug, "submissions", code, params=params)
submissions(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Submission]]
¶
Lists all submissions and their details
Source code in src/pytanis/pretalx/client.py
def submissions(
self, event_slug: str, *, params: Optional[QueryParamType] = None
) -> Tuple[int, Iterator[Submission]]:
"""Lists all submissions and their details"""
return self._endpoint_lst(Submission, event_slug, "submissions", params=params)
tag(event_slug: str, tag: str, *, params: Optional[QueryParamType] = None) -> Tag
¶
Returns a specific tag
Source code in src/pytanis/pretalx/client.py
def tag(self, event_slug: str, tag: str, *, params: Optional[QueryParamType] = None) -> Tag:
"""Returns a specific tag"""
return self._endpoint_id(Tag, event_slug, "tags", tag, params=params)
tags(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Tag]]
¶
Lists all tags and their details
Source code in src/pytanis/pretalx/client.py
def tags(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Tag]]:
"""Lists all tags and their details"""
return self._endpoint_lst(Tag, event_slug, "tags", params=params)
talk(event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Talk
¶
Returns a specific talk
Source code in src/pytanis/pretalx/client.py
def talk(self, event_slug: str, code: str, *, params: Optional[QueryParamType] = None) -> Talk:
"""Returns a specific talk"""
return self._endpoint_id(Talk, event_slug, "talks", code, params=params)
talks(event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Talk]]
¶
Lists all talks and their details
Source code in src/pytanis/pretalx/client.py
def talks(self, event_slug: str, *, params: Optional[QueryParamType] = None) -> Tuple[int, Iterator[Talk]]:
"""Lists all talks and their details"""
return self._endpoint_lst(Talk, event_slug, "talks", params=params)