- The
requestsmodule is already available in scope. - The following variables are available:
client_id→ stringmetric_filters→ filter configuration object
- Secrets are available through:
secrets["SECRET_NAME"]
- The final output must be assigned to a variable named
result. - The output must be:
- an array of objects
- or a list of dictionaries
Metric Filters Structure
Use the following structure when working with metric filters in your query:Formatting Instructions
- Use consistent indentation (4 spaces).
- Follow PEP8 naming conventions.
- Use descriptive variable names.
- Avoid hardcoded values; use variables and secrets instead.
- Add whitespace between logical blocks.
- Use helper variables to improve readability.
- Handle filters dynamically instead of hardcoding them.
- Avoid unnecessary global variables.
- Use exception handling for API calls when possible.
- Always assign output to the
resultvariable.
Core Usage Guidelines
Guideline 1: Import requests
The requests module is already available and does not need installation, but you should still import it for clarity:
Guideline 2: Use Runtime Variables
Use the available runtime variables instead of hardcoding values:Guideline 3: Use Metric Filters Dynamically
Handlemetric_filters generically based on type to support both date ranges and simple values:
Guideline 4: Use Secrets Securely
Always retrieve sensitive information usingsecrets:
Guideline 5: Structure API Calls Clearly
Build headers and API calls in a clear, readable way:Guideline 6: Transform Data Before Returning
Ensure your output matches the required format before assigning it toresult:
Output Requirements
Your script must end by assigning toresult using one of the following patterns:

