| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1ed70ec commit 7e3d4f7
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,9 +17,10 @@ Methods: | |||
| 17 | 17 | Types: | |
| 18 | 18 | ||
| 19 | 19 | ```python | |
| 20 | - from cloudflare.types.billing import UsagePaygoResponse | ||
| 20 | + from cloudflare.types.billing import UsageGetResponse, UsagePaygoResponse | ||
| 21 | 21 | ``` | |
| 22 | 22 | ||
| 23 | 23 | Methods: | |
| 24 | 24 | ||
| 25 | - - <code title="get /accounts/{account_id}/billing/usage/paygo">client.billing.usage.<a href="./src/cloudflare/resources/billing/usage.py">paygo</a>(\*, account_id, \*\*<a href="src/cloudflare/types/billing/usage_paygo_params.py">params</a>) -> <a href="./src/cloudflare/types/billing/usage_paygo_response.py">UsagePaygoResponse</a></code> | ||
| 25 | + - <code title="get /accounts/{account_id}/billable/usage">client.billing.usage.<a href="./src/cloudflare/resources/billing/usage.py">get</a>(\*, account_id, \*\*<a href="src/cloudflare/types/billing/usage_get_params.py">params</a>) -> <a href="./src/cloudflare/types/billing/usage_get_response.py">UsageGetResponse</a></code> | ||
| 26 | + - <code title="get /accounts/{account_id}/paygo-usage">client.billing.usage.<a href="./src/cloudflare/resources/billing/usage.py">paygo</a>(\*, account_id, \*\*<a href="src/cloudflare/types/billing/usage_paygo_params.py">params</a>) -> <a href="./src/cloudflare/types/billing/usage_paygo_response.py">UsagePaygoResponse</a></code> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,8 @@ | |||
| 19 | 19 | ) | |
| 20 | 20 | from ..._wrappers import ResultWrapper | |
| 21 | 21 | from ..._base_client import make_request_options | |
| 22 | - from ...types.billing import usage_paygo_params | ||
| 22 | + from ...types.billing import usage_get_params, usage_paygo_params | ||
| 23 | + from ...types.billing.usage_get_response import UsageGetResponse | ||
| 23 | 24 | from ...types.billing.usage_paygo_response import UsagePaygoResponse | |
| 24 | 25 | ||
| 25 | 26 | __all__ = ["UsageResource", "AsyncUsageResource"] | |
@@ -45,6 +46,79 @@ def with_streaming_response(self) -> UsageResourceWithStreamingResponse: | |||
| 45 | 46 | """ | |
| 46 | 47 | return UsageResourceWithStreamingResponse(self) | |
| 47 | 48 | ||
| 49 | + def get( | ||
| 50 | + self, | ||
| 51 | + *, | ||
| 52 | + account_id: str, | ||
| 53 | + from_: Union[str, date] | Omit = omit, | ||
| 54 | + metric: str | Omit = omit, | ||
| 55 | + to: Union[str, date] | Omit = omit, | ||
| 56 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | ||
| 57 | + # The extra values given here take precedence over values defined on the client or passed to this method. | ||
| 58 | + extra_headers: Headers | None = None, | ||
| 59 | + extra_query: Query | None = None, | ||
| 60 | + extra_body: Body | None = None, | ||
| 61 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, | ||
| 62 | + ) -> UsageGetResponse: | ||
| 63 | + """ | ||
| 64 | + Returns cost and usage data for a single Cloudflare account, aligned with the | ||
| 65 | + [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and | ||
| 66 | + Usage dataset specification. | ||
| 67 | + | ||
| 68 | + Each record represents one billable metric for one account on one day. This | ||
| 69 | + includes all metered usage, including usage that falls within free-tier | ||
| 70 | + allowances and may result in zero cost. | ||
| 71 | + | ||
| 72 | + **Note:** Cost and pricing fields are not yet populated and will be absent from | ||
| 73 | + responses until billing integration is complete. | ||
| 74 | + | ||
| 75 | + When `from` and `to` are omitted, defaults to the start of the current month | ||
| 76 | + through today. The maximum date range is 31 days. | ||
| 77 | + | ||
| 78 | + Args: | ||
| 79 | + account_id: Represents a Cloudflare resource identifier tag. | ||
| 80 | + | ||
| 81 | + from_: Start date for the usage query (ISO 8601). Required if `to` is set. When omitted | ||
| 82 | + along with `to`, defaults to the start of the current month. Filters by charge | ||
| 83 | + period (when consumption happened), not billing period. The maximum date range | ||
| 84 | + is 31 days. | ||
| 85 | + | ||
| 86 | + metric: Filter results by billable metric id (e.g., workers_standard_requests). | ||
| 87 | + | ||
| 88 | + to: End date for the usage query (ISO 8601). Required if `from` is set. When omitted | ||
| 89 | + along with `from`, defaults to today. Filters by charge period (when consumption | ||
| 90 | + happened), not billing period. The maximum date range is 31 days. | ||
| 91 | + | ||
| 92 | + extra_headers: Send extra headers | ||
| 93 | + | ||
| 94 | + extra_query: Add additional query parameters to the request | ||
| 95 | + | ||
| 96 | + extra_body: Add additional JSON properties to the request | ||
| 97 | + | ||
| 98 | + timeout: Override the client-level default timeout for this request, in seconds | ||
| 99 | + """ | ||
| 100 | + if not account_id: | ||
| 101 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") | ||
| 102 | + return self._get( | ||
| 103 | + path_template("/accounts/{account_id}/billable/usage", account_id=account_id), | ||
| 104 | + options=make_request_options( | ||
| 105 | + extra_headers=extra_headers, | ||
| 106 | + extra_query=extra_query, | ||
| 107 | + extra_body=extra_body, | ||
| 108 | + timeout=timeout, | ||
| 109 | + query=maybe_transform( | ||
| 110 | + { | ||
| 111 | + "from_": from_, | ||
| 112 | + "metric": metric, | ||
| 113 | + "to": to, | ||
| 114 | + }, | ||
| 115 | + usage_get_params.UsageGetParams, | ||
| 116 | + ), | ||
| 117 | + post_parser=ResultWrapper[UsageGetResponse]._unwrapper, | ||
| 118 | + ), | ||
| 119 | + cast_to=cast(Type[UsageGetResponse], ResultWrapper[UsageGetResponse]), | ||
| 120 | + ) | ||
| 121 | + | ||
| 48 | 122 | def paygo( | |
| 49 | 123 | self, | |
| 50 | 124 | *, | |
@@ -68,9 +142,9 @@ def paygo( | |||
| 68 | 142 | Args: | |
| 69 | 143 | account_id: Represents a Cloudflare resource identifier tag. | |
| 70 | 144 | ||
| 71 | - from_: Defines the start date for the usage query (e.g., 2025-02-01). | ||
| 145 | + from_: Start date for the usage query (ISO 8601). | ||
| 72 | 146 | ||
| 73 | - to: Defines the end date for the usage query (e.g., 2025-03-01). | ||
| 147 | + to: End date for the usage query (ISO 8601). | ||
| 74 | 148 | ||
| 75 | 149 | extra_headers: Send extra headers | |
| 76 | 150 | ||
@@ -83,7 +157,7 @@ def paygo( | |||
| 83 | 157 | if not account_id: | |
| 84 | 158 | raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") | |
| 85 | 159 | return self._get( | |
| 86 | - path_template("/accounts/{account_id}/billing/usage/paygo", account_id=account_id), | ||
| 160 | + path_template("/accounts/{account_id}/paygo-usage", account_id=account_id), | ||
| 87 | 161 | options=make_request_options( | |
| 88 | 162 | extra_headers=extra_headers, | |
| 89 | 163 | extra_query=extra_query, | |
@@ -122,6 +196,79 @@ def with_streaming_response(self) -> AsyncUsageResourceWithStreamingResponse: | |||
| 122 | 196 | """ | |
| 123 | 197 | return AsyncUsageResourceWithStreamingResponse(self) | |
| 124 | 198 | ||
| 199 | + async def get( | ||
| 200 | + self, | ||
| 201 | + *, | ||
| 202 | + account_id: str, | ||
| 203 | + from_: Union[str, date] | Omit = omit, | ||
| 204 | + metric: str | Omit = omit, | ||
| 205 | + to: Union[str, date] | Omit = omit, | ||
| 206 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. | ||
| 207 | + # The extra values given here take precedence over values defined on the client or passed to this method. | ||
| 208 | + extra_headers: Headers | None = None, | ||
| 209 | + extra_query: Query | None = None, | ||
| 210 | + extra_body: Body | None = None, | ||
| 211 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, | ||
| 212 | + ) -> UsageGetResponse: | ||
| 213 | + """ | ||
| 214 | + Returns cost and usage data for a single Cloudflare account, aligned with the | ||
| 215 | + [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and | ||
| 216 | + Usage dataset specification. | ||
| 217 | + | ||
| 218 | + Each record represents one billable metric for one account on one day. This | ||
| 219 | + includes all metered usage, including usage that falls within free-tier | ||
| 220 | + allowances and may result in zero cost. | ||
| 221 | + | ||
| 222 | + **Note:** Cost and pricing fields are not yet populated and will be absent from | ||
| 223 | + responses until billing integration is complete. | ||
| 224 | + | ||
| 225 | + When `from` and `to` are omitted, defaults to the start of the current month | ||
| 226 | + through today. The maximum date range is 31 days. | ||
| 227 | + | ||
| 228 | + Args: | ||
| 229 | + account_id: Represents a Cloudflare resource identifier tag. | ||
| 230 | + | ||
| 231 | + from_: Start date for the usage query (ISO 8601). Required if `to` is set. When omitted | ||
| 232 | + along with `to`, defaults to the start of the current month. Filters by charge | ||
| 233 | + period (when consumption happened), not billing period. The maximum date range | ||
| 234 | + is 31 days. | ||
| 235 | + | ||
| 236 | + metric: Filter results by billable metric id (e.g., workers_standard_requests). | ||
| 237 | + | ||
| 238 | + to: End date for the usage query (ISO 8601). Required if `from` is set. When omitted | ||
| 239 | + along with `from`, defaults to today. Filters by charge period (when consumption | ||
| 240 | + happened), not billing period. The maximum date range is 31 days. | ||
| 241 | + | ||
| 242 | + extra_headers: Send extra headers | ||
| 243 | + | ||
| 244 | + extra_query: Add additional query parameters to the request | ||
| 245 | + | ||
| 246 | + extra_body: Add additional JSON properties to the request | ||
| 247 | + | ||
| 248 | + timeout: Override the client-level default timeout for this request, in seconds | ||
| 249 | + """ | ||
| 250 | + if not account_id: | ||
| 251 | + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") | ||
| 252 | + return await self._get( | ||
| 253 | + path_template("/accounts/{account_id}/billable/usage", account_id=account_id), | ||
| 254 | + options=make_request_options( | ||
| 255 | + extra_headers=extra_headers, | ||
| 256 | + extra_query=extra_query, | ||
| 257 | + extra_body=extra_body, | ||
| 258 | + timeout=timeout, | ||
| 259 | + query=await async_maybe_transform( | ||
| 260 | + { | ||
| 261 | + "from_": from_, | ||
| 262 | + "metric": metric, | ||
| 263 | + "to": to, | ||
| 264 | + }, | ||
| 265 | + usage_get_params.UsageGetParams, | ||
| 266 | + ), | ||
| 267 | + post_parser=ResultWrapper[UsageGetResponse]._unwrapper, | ||
| 268 | + ), | ||
| 269 | + cast_to=cast(Type[UsageGetResponse], ResultWrapper[UsageGetResponse]), | ||
| 270 | + ) | ||
| 271 | + | ||
| 125 | 272 | async def paygo( | |
| 126 | 273 | self, | |
| 127 | 274 | *, | |
@@ -145,9 +292,9 @@ async def paygo( | |||
| 145 | 292 | Args: | |
| 146 | 293 | account_id: Represents a Cloudflare resource identifier tag. | |
| 147 | 294 | ||
| 148 | - from_: Defines the start date for the usage query (e.g., 2025-02-01). | ||
| 295 | + from_: Start date for the usage query (ISO 8601). | ||
| 149 | 296 | ||
| 150 | - to: Defines the end date for the usage query (e.g., 2025-03-01). | ||
| 297 | + to: End date for the usage query (ISO 8601). | ||
| 151 | 298 | ||
| 152 | 299 | extra_headers: Send extra headers | |
| 153 | 300 | ||
@@ -160,7 +307,7 @@ async def paygo( | |||
| 160 | 307 | if not account_id: | |
| 161 | 308 | raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") | |
| 162 | 309 | return await self._get( | |
| 163 | - path_template("/accounts/{account_id}/billing/usage/paygo", account_id=account_id), | ||
| 310 | + path_template("/accounts/{account_id}/paygo-usage", account_id=account_id), | ||
| 164 | 311 | options=make_request_options( | |
| 165 | 312 | extra_headers=extra_headers, | |
| 166 | 313 | extra_query=extra_query, | |
@@ -183,6 +330,9 @@ class UsageResourceWithRawResponse: | |||
| 183 | 330 | def __init__(self, usage: UsageResource) -> None: | |
| 184 | 331 | self._usage = usage | |
| 185 | 332 | ||
| 333 | + self.get = to_raw_response_wrapper( | ||
| 334 | + usage.get, | ||
| 335 | + ) | ||
| 186 | 336 | self.paygo = to_raw_response_wrapper( | |
| 187 | 337 | usage.paygo, | |
| 188 | 338 | ) | |
@@ -192,6 +342,9 @@ class AsyncUsageResourceWithRawResponse: | |||
| 192 | 342 | def __init__(self, usage: AsyncUsageResource) -> None: | |
| 193 | 343 | self._usage = usage | |
| 194 | 344 | ||
| 345 | + self.get = async_to_raw_response_wrapper( | ||
| 346 | + usage.get, | ||
| 347 | + ) | ||
| 195 | 348 | self.paygo = async_to_raw_response_wrapper( | |
| 196 | 349 | usage.paygo, | |
| 197 | 350 | ) | |
@@ -201,6 +354,9 @@ class UsageResourceWithStreamingResponse: | |||
| 201 | 354 | def __init__(self, usage: UsageResource) -> None: | |
| 202 | 355 | self._usage = usage | |
| 203 | 356 | ||
| 357 | + self.get = to_streamed_response_wrapper( | ||
| 358 | + usage.get, | ||
| 359 | + ) | ||
| 204 | 360 | self.paygo = to_streamed_response_wrapper( | |
| 205 | 361 | usage.paygo, | |
| 206 | 362 | ) | |
@@ -210,6 +366,9 @@ class AsyncUsageResourceWithStreamingResponse: | |||
| 210 | 366 | def __init__(self, usage: AsyncUsageResource) -> None: | |
| 211 | 367 | self._usage = usage | |
| 212 | 368 | ||
| 369 | + self.get = async_to_streamed_response_wrapper( | ||
| 370 | + usage.get, | ||
| 371 | + ) | ||
| 213 | 372 | self.paygo = async_to_streamed_response_wrapper( | |
| 214 | 373 | usage.paygo, | |
| 215 | 374 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | from __future__ import annotations | |
| 4 | 4 | ||
| 5 | + from .usage_get_params import UsageGetParams as UsageGetParams | ||
| 6 | + from .usage_get_response import UsageGetResponse as UsageGetResponse | ||
| 5 | 7 | from .usage_paygo_params import UsagePaygoParams as UsagePaygoParams | |
| 6 | 8 | from .profile_get_response import ProfileGetResponse as ProfileGetResponse | |
| 7 | 9 | from .usage_paygo_response import UsagePaygoResponse as UsagePaygoResponse | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
| 2 | + | ||
| 3 | + from __future__ import annotations | ||
| 4 | + | ||
| 5 | + from typing import Union | ||
| 6 | + from datetime import date | ||
| 7 | + from typing_extensions import Required, Annotated, TypedDict | ||
| 8 | + | ||
| 9 | + from ..._utils import PropertyInfo | ||
| 10 | + | ||
| 11 | + __all__ = ["UsageGetParams"] | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + class UsageGetParams(TypedDict, total=False): | ||
| 15 | + account_id: Required[str] | ||
| 16 | + """Represents a Cloudflare resource identifier tag.""" | ||
| 17 | + | ||
| 18 | + from_: Annotated[Union[str, date], PropertyInfo(alias="from", format="iso8601")] | ||
| 19 | + """Start date for the usage query (ISO 8601). | ||
| 20 | + | ||
| 21 | + Required if `to` is set. When omitted along with `to`, defaults to the start of | ||
| 22 | + the current month. Filters by charge period (when consumption happened), not | ||
| 23 | + billing period. The maximum date range is 31 days. | ||
| 24 | + """ | ||
| 25 | + | ||
| 26 | + metric: str | ||
| 27 | + """Filter results by billable metric id (e.g., workers_standard_requests).""" | ||
| 28 | + | ||
| 29 | + to: Annotated[Union[str, date], PropertyInfo(format="iso8601")] | ||
| 30 | + """End date for the usage query (ISO 8601). | ||
| 31 | + | ||
| 32 | + Required if `from` is set. When omitted along with `from`, defaults to today. | ||
| 33 | + Filters by charge period (when consumption happened), not billing period. The | ||
| 34 | + maximum date range is 31 days. | ||
| 35 | + """ | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments