Skip to content

FavoriteResource

Reference

FavoriteResource

Bookmark frequently used resources

5 min Beginner
ReferenceAPI

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.

1

Setup

Connect to the platform and find a mapping to favorite

# Cell 1 — Parameters
USERNAME = "_FILL_ME_IN_" # Set your email before running
# Cell 2 — Connect
from graph_olap import GraphOLAPClient
client = GraphOLAPClient(username=USERNAME)
# Cell 3 — Provision
from notebook_setup import provision, CUSTOMER_NODE, SHARES_ACCOUNT_EDGE
personas, _ = provision(USERNAME)
analyst = personas["analyst"]
admin = personas["admin"]
ops = personas["ops"]
client = analyst
# Create a mapping to use as favorite target
ref_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 setup
mapping_id = ref_mapping.id
print(f"Favoriting mapping: [{mapping_id}]")
2

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.

ParameterTypeDescription
resource_typestr"mapping" or "instance"
resource_idintID 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}")
3

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.

ParameterTypeDefaultDescription
resource_typestr | NoneNoneFilter by "mapping" or "instance"

Returns: List of Favorite objects.

# List all favorites
favorites = 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 type
mapping_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)}")
4

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.

ParameterTypeDescription
resource_typestr"mapping" or "instance"
resource_idintID 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 gone
favorites = client.favorites.list()
print(f"Remaining favorites: {len(favorites)}")

Key Takeaways

  • client.favorites manages per-user bookmarks for mappings and instances
  • add() returns a Favorite object with the resource name and timestamp
  • list() accepts an optional resource_type filter
  • remove() deletes a bookmark -- it does not affect the underlying resource