Python client library for Google Cloud Platform services including Datastore, Storage, and Pub/Sub
Overall
score
93%
A bank account transfer system that uses Cloud Datastore transactions to safely transfer money between accounts with automatic rollback on failures.
@generates
def transfer_money(client, from_account_id, to_account_id, amount):
"""
Transfer money from one account to another using a transaction.
Args:
client: A gcloud datastore Client instance
from_account_id: String ID of the source account
to_account_id: String ID of the destination account
amount: Numeric amount to transfer (must be positive)
Returns:
dict: Contains 'success' boolean and 'message' string
Example: {'success': True, 'message': 'Transfer completed'}
Raises:
ValueError: If amount is not positive
Exception: If accounts don't exist or insufficient balance
"""
pass
def create_account(client, account_id, initial_balance):
"""
Create a new bank account in the datastore.
Args:
client: A gcloud datastore Client instance
account_id: String ID for the account
initial_balance: Numeric starting balance
Returns:
Key: The datastore Key of the created account
"""
pass
def get_balance(client, account_id):
"""
Get the current balance of an account.
Args:
client: A gcloud datastore Client instance
account_id: String ID of the account
Returns:
Numeric: Current account balance
Raises:
Exception: If account doesn't exist
"""
passProvides Cloud Datastore client for transactional data operations.
@satisfied-by
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