Python client library for Google Cloud Platform services including Datastore, Storage, and Pub/Sub
Overall
score
93%
Build a simple entity relationship manager that creates and validates hierarchical entity identifiers for a blog platform.
Your system should provide functions to:
The system should support two entity types:
All identifiers should be associated with a project named "test-project".
@generates
def create_root_key(post_id):
"""
Create a root-level key for a BlogPost entity.
Args:
post_id: The identifier for the blog post (string or integer)
Returns:
A key object representing the BlogPost entity
"""
pass
def create_child_key(parent_key, comment_id):
"""
Create a child key for a Comment entity under a parent BlogPost.
Args:
parent_key: The parent BlogPost key object
comment_id: The identifier for the comment (string or integer)
Returns:
A key object representing the Comment entity with the parent relationship
"""
pass
def extract_key_components(key):
"""
Extract the hierarchical components from a key.
Args:
key: A key object (possibly hierarchical)
Returns:
A list of tuples, where each tuple contains (kind, id) for each level
in the hierarchy from root to leaf
"""
pass
def is_ancestor(potential_ancestor_key, descendant_key):
"""
Check if one key is an ancestor of another in the entity hierarchy.
Args:
potential_ancestor_key: The key that might be an ancestor
descendant_key: The key that might be a descendant
Returns:
True if potential_ancestor_key is an ancestor of descendant_key, False otherwise
"""
passProvides Google Cloud Datastore client functionality.
Install with Tessl CLI
npx tessl i tessl/pypi-gcloudevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10