feat(client): add Tag entity (get, create, save, dispatch)#442
Merged
Conversation
Adds ol.Tag as a first-class entity alongside Work, Edition, Author:
- Tag.get(olid) — fetches /tags/{olid}.json, returns None if not found
- Tag.create(name, tag_type, description, comment) — via save_many
- tag.save(comment) — PUT /tags/{olid}.json
- tag.json() — serializes for OL API (excludes read-only fields)
- ol.get('OL32T') dispatches to Tag.get() via the 'T' suffix
Also adds olclient/schemata/tag.schema.json with the Tag document shape
based on /type/tag and real OL Tag documents (e.g. OL32T cooking).
7 new unit tests covering init, json(), get(), get-not-found, dispatch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
ol.Tagas a first-class entity inopenlibrary-client, alongsideol.Work,ol.Edition, andol.Author.OL Tags are Infogami documents at
/tags/OLnTintroduced in GSoC 2023. They provide a controlled vocabulary for subject tagging.New API
What's included
ol.Tagproperty (dynamic class factory, same pattern as Work/Edition/Author)Tag.get(olid)— fetches/tags/{olid}.json, returnsNoneif not foundTag.create(name, tag_type, description, comment)— viasave_manytag.save(comment)—PUT /tags/{olid}.jsontag.json()— excludes read-only fields (olid,revision,latest_revision,created,last_modified), addskeyandtypeol.get('OL32TÈ')dispatch via theTsuffixolclient/schemata/tag.schema.json— based on/type/tagand real OL documentsTesting
New tests cover:
Tag.__init__,tag.json(),Tag.get(),Tag.get()returns None for missing tags,ol.get()dispatch to Tag.Related
Part of the openlibrary-client improvement series (PR 5 of 5):
get_many()(open)