Pricing

block_check

Diagram
The provided Python script, , is designed to ensure that no booking blocks are inadvertently removed by another script, specifically , within an Airbnb project context. It interacts with various data sources and targets, primarily focusing on Google Sheets, BigQuery, and the Guesty API. Below is a high-level overview of the data sources and targets identified in the script:

Data Sources:

Google Sheets: The script loads listings and block date ranges from two specific Google Sheets identified by their keys:
for listings.
for block date ranges.
BigQuery: It fetches listing calendars from a BigQuery table named listing_calendars within the Pricing dataset.
Guesty API: The script retrieves calendar data for listings from the Guesty API, focusing on availability and pricing information.
Secret Manager: It accesses secrets, such as service account keys, from Google Cloud Secret Manager to authenticate and interact with Google Sheets and BigQuery.

Data Targets:

Guesty API: The script updates the Guesty calendar by applying missing blocks or correcting notes for listings based on the comparison between the data fetched from BigQuery and Google Sheets against the Guesty calendar data.
Logging: While not a data storage target per se, the script logs its operations, which can be considered as outputting data to the console or potentially to a logging service when deployed in a cloud environment.

Operations:

The script performs data manipulation and comparison operations to identify discrepancies between the listing calendars in BigQuery and the Guesty calendar data.
It generates a list of missing blocks or incorrect notes that need to be updated in the Guesty calendar.
The script uses concurrent requests to update the Guesty calendar in batches, adhering to API rate limits.

Dependencies and External Interactions:

The script interacts with Google Sheets and BigQuery using respective client libraries (pygsheets for Google Sheets and google.cloud.bigquery for BigQuery).
It uses the requests library to interact with the Guesty API.
Authentication and authorization with Google Cloud services are handled using google.oauth2.id_token and google.auth.transport.requests for generating ID tokens and making authenticated requests.
The script also uses standard Python libraries for data manipulation (pandas, numpy), date and time handling (datetime, pytz), and concurrency (concurrent.futures).
This overview excludes class methods, logging, error handling, and dependencies as per the instruction.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.