Information about a multilingual glossary, excluding the entry list. Used by the /v3/glossaries API endpoints :param glossary_id: Unique ID assigned to the glossary. :param name: User-defined name assigned to the glossary. :param creation_time: Timestamp when the glossary was create
| 516 | |
| 517 | |
| 518 | class MultilingualGlossaryInfo: |
| 519 | """Information about a multilingual glossary, excluding the entry list. |
| 520 | Used by the /v3/glossaries API endpoints |
| 521 | |
| 522 | :param glossary_id: Unique ID assigned to the glossary. |
| 523 | :param name: User-defined name assigned to the glossary. |
| 524 | :param creation_time: Timestamp when the glossary was created. |
| 525 | :param dictionaries: Dictionaries contained in this glossary. Each |
| 526 | dictionary contains its language pair and the number of entries. |
| 527 | """ |
| 528 | |
| 529 | def __init__( |
| 530 | self, |
| 531 | glossary_id: str, |
| 532 | name: str, |
| 533 | creation_time: datetime.datetime, |
| 534 | dictionaries: List[MultilingualGlossaryDictionaryInfo], |
| 535 | ): |
| 536 | self._glossary_id = glossary_id |
| 537 | self._name = name |
| 538 | self._creation_time = creation_time |
| 539 | self._dictionaries = dictionaries |
| 540 | |
| 541 | def __str__(self) -> str: |
| 542 | return f'MultilingualGlossary "{self.name}" ({self.glossary_id})' |
| 543 | |
| 544 | @staticmethod |
| 545 | def from_json(json) -> "MultilingualGlossaryInfo": |
| 546 | """Create MultilingualGlossaryInfo from the given API JSON object.""" |
| 547 | return MultilingualGlossaryInfo( |
| 548 | json["glossary_id"], |
| 549 | json["name"], |
| 550 | parse_timestamp(json["creation_time"]), |
| 551 | list( |
| 552 | map( |
| 553 | lambda entry: MultilingualGlossaryDictionaryInfo.from_json( |
| 554 | entry |
| 555 | ), |
| 556 | json["dictionaries"], |
| 557 | ) |
| 558 | ), |
| 559 | ) |
| 560 | |
| 561 | @staticmethod |
| 562 | def to_json(self) -> dict: |
| 563 | """Create API JSON object from MultilingualGlossaryInfo.""" |
| 564 | return { |
| 565 | "glossary_id": self._glossary_id, |
| 566 | "name": self._name, |
| 567 | "creation_time": self._creation_time, |
| 568 | "dictionaries": self._dictionaries, |
| 569 | } |
| 570 | |
| 571 | @property |
| 572 | def glossary_id(self) -> str: |
| 573 | return self._glossary_id |
| 574 | |
| 575 | @property |