Add AdditionalProperties access example for GetUsageSummary#3688
Draft
charlie-zhang109 wants to merge 3 commits into
Draft
Add AdditionalProperties access example for GetUsageSummary#3688charlie-zhang109 wants to merge 3 commits into
charlie-zhang109 wants to merge 3 commits into
Conversation
Demonstrates how to call the v2 GetUsageSummaryAvailableFields endpoint to obtain the canonical field lists, then walk all three response levels of the v1 GetUsageSummary response (UsageSummaryResponse, UsageSummaryDate, UsageSummaryDateOrg) reading every non-None value via .get(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… all layers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/v1/usage-metering/GetUsageSummary_additional_properties.pydemonstrating how to read every field at all three response levels ofGET /api/v1/usage/summaryusingadditionalProperties.GetUsageSummaryAvailableFieldsendpoint first to retrieveresponse_fields,date_fields, anddate_org_fields— the authoritative list of keys emitted by the v1 endpoint.UsageSummaryResponse→UsageSummaryDate→UsageSummaryDateOrg) using.get()and prints non-None values.Three layers covered
UsageSummaryResponse(top-level)response_fieldsUsageSummaryDate(usage[])date_fieldsUsageSummaryDateOrg(usage[].orgs[])date_org_fieldsTest plan
python examples/v1/usage-metering/GetUsageSummary_additional_properties.pywith validDD_API_KEY/DD_APP_KEYcredentials to verify all three layers print correctly.Configuration(),ApiClientcontext manager).🤖 Generated with Claude Code