FavoriteResource
FavoriteResource
Bookmark frequently used resources
FavoriteResource
Section titled “FavoriteResource”Accessed via client.favorites, this resource lets users bookmark frequently
used mappings or instances for quick access.
Favorites are per-user and support two resource types: mapping and instance.
Setup
Connect to the platform and find a mapping to favorite
# Cell 1 — ParametersUSERNAME = "_FILL_ME_IN_" # Set your email before running# Cell 2 — Connectfrom graph_olap import GraphOLAPClientclient = GraphOLAPClient(username=USERNAME)# Cell 3 — Provisionfrom notebook_setup import provision, CUSTOMER_NODE, SHARES_ACCOUNT_EDGEpersonas, _ = provision(USERNAME)analyst = personas["analyst"]admin = personas["admin"]ops = personas["ops"]client = analyst
# Create a mapping to use as favorite targetref_mapping = client.mappings.create( name="ref-fav-target", node_definitions=[CUSTOMER_NODE], edge_definitions=[SHARES_ACCOUNT_EDGE],)print(f"Using mapping [{ref_mapping.id}] as favorite target")# Use the tracked mapping created in setupmapping_id = ref_mapping.idprint(f"Favoriting mapping: [{mapping_id}]")Adding Favorites
Bookmark a resource
add(resource_type, resource_id) -> Favorite
Section titled “add(resource_type, resource_id) -> Favorite”Add a resource to the current user’s favorites.
| Parameter | Type | Description |
|---|---|---|
resource_type | str | "mapping" or "instance" |
resource_id | int | ID of the resource to bookmark |
Returns: Favorite object with resource_type, resource_id, resource_name, and created_at.
Raises: NotFoundError if the resource does not exist. ConflictError if already favorited.
fav = client.favorites.add("mapping", mapping_id)
print(f"Type: {fav.resource_type}")print(f"ID: {fav.resource_id}")print(f"Name: {fav.resource_name}")print(f"Added: {fav.created_at}")Listing Favorites
View bookmarked resources
list(resource_type=None) -> list[Favorite]
Section titled “list(resource_type=None) -> list[Favorite]”List the current user’s favorites, optionally filtered by resource type.
| Parameter | Type | Default | Description |
|---|---|---|---|
resource_type | str | None | None | Filter by "mapping" or "instance" |
Returns: List of Favorite objects.
# List all favoritesfavorites = client.favorites.list()print(f"Total favorites: {len(favorites)}\n")
for fav in favorites: print(f" {fav.resource_type}: {fav.resource_name} (id={fav.resource_id})")# Filter by resource typemapping_favs = client.favorites.list(resource_type="mapping")instance_favs = client.favorites.list(resource_type="instance")
print(f"Mapping favorites: {len(mapping_favs)}")print(f"Instance favorites: {len(instance_favs)}")Removing Favorites
Un-bookmark a resource
remove(resource_type, resource_id) -> None
Section titled “remove(resource_type, resource_id) -> None”Remove a resource from the current user’s favorites.
| Parameter | Type | Description |
|---|---|---|
resource_type | str | "mapping" or "instance" |
resource_id | int | ID of the resource to un-bookmark |
Raises: NotFoundError if the favorite does not exist.
client.favorites.remove("mapping", mapping_id)print("Favorite removed.")
# Verify it is gonefavorites = client.favorites.list()print(f"Remaining favorites: {len(favorites)}")Key Takeaways
client.favoritesmanages per-user bookmarks for mappings and instancesadd()returns aFavoriteobject with the resource name and timestamplist()accepts an optionalresource_typefilterremove()deletes a bookmark -- it does not affect the underlying resource