Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 48
configured_endpoints: 49
12 changes: 12 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ Methods:

- <code title="get /v1/accounts/usage">client.accounts.usage.<a href="./src/imagekitio/resources/accounts/usage.py">get</a>(\*\*<a href="src/imagekitio/types/accounts/usage_get_params.py">params</a>) -> <a href="./src/imagekitio/types/accounts/usage_get_response.py">UsageGetResponse</a></code>

## UsageAnalytics

Types:

```python
from imagekitio.types.accounts import RequestBandwidthEntry, UsageAnalyticsResponse
```

Methods:

- <code title="get /v1/accounts/usage-analytics">client.accounts.usage_analytics.<a href="./src/imagekitio/resources/accounts/usage_analytics.py">get</a>(\*\*<a href="src/imagekitio/types/accounts/usage_analytics_get_params.py">params</a>) -> <a href="./src/imagekitio/types/accounts/usage_analytics_response.py">UsageAnalyticsResponse</a></code>

## Origins

Types:
Expand Down
14 changes: 14 additions & 0 deletions src/imagekitio/resources/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
URLEndpointsResourceWithStreamingResponse,
AsyncURLEndpointsResourceWithStreamingResponse,
)
from .usage_analytics import (
UsageAnalyticsResource,
AsyncUsageAnalyticsResource,
UsageAnalyticsResourceWithRawResponse,
AsyncUsageAnalyticsResourceWithRawResponse,
UsageAnalyticsResourceWithStreamingResponse,
AsyncUsageAnalyticsResourceWithStreamingResponse,
)

__all__ = [
"UsageResource",
Expand All @@ -40,6 +48,12 @@
"AsyncUsageResourceWithRawResponse",
"UsageResourceWithStreamingResponse",
"AsyncUsageResourceWithStreamingResponse",
"UsageAnalyticsResource",
"AsyncUsageAnalyticsResource",
"UsageAnalyticsResourceWithRawResponse",
"AsyncUsageAnalyticsResourceWithRawResponse",
"UsageAnalyticsResourceWithStreamingResponse",
"AsyncUsageAnalyticsResourceWithStreamingResponse",
"OriginsResource",
"AsyncOriginsResource",
"OriginsResourceWithRawResponse",
Expand Down
32 changes: 32 additions & 0 deletions src/imagekitio/resources/accounts/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
URLEndpointsResourceWithStreamingResponse,
AsyncURLEndpointsResourceWithStreamingResponse,
)
from .usage_analytics import (
UsageAnalyticsResource,
AsyncUsageAnalyticsResource,
UsageAnalyticsResourceWithRawResponse,
AsyncUsageAnalyticsResourceWithRawResponse,
UsageAnalyticsResourceWithStreamingResponse,
AsyncUsageAnalyticsResourceWithStreamingResponse,
)

__all__ = ["AccountsResource", "AsyncAccountsResource"]

Expand All @@ -37,6 +45,10 @@ class AccountsResource(SyncAPIResource):
def usage(self) -> UsageResource:
return UsageResource(self._client)

@cached_property
def usage_analytics(self) -> UsageAnalyticsResource:
return UsageAnalyticsResource(self._client)

@cached_property
def origins(self) -> OriginsResource:
return OriginsResource(self._client)
Expand Down Expand Up @@ -70,6 +82,10 @@ class AsyncAccountsResource(AsyncAPIResource):
def usage(self) -> AsyncUsageResource:
return AsyncUsageResource(self._client)

@cached_property
def usage_analytics(self) -> AsyncUsageAnalyticsResource:
return AsyncUsageAnalyticsResource(self._client)

@cached_property
def origins(self) -> AsyncOriginsResource:
return AsyncOriginsResource(self._client)
Expand Down Expand Up @@ -106,6 +122,10 @@ def __init__(self, accounts: AccountsResource) -> None:
def usage(self) -> UsageResourceWithRawResponse:
return UsageResourceWithRawResponse(self._accounts.usage)

@cached_property
def usage_analytics(self) -> UsageAnalyticsResourceWithRawResponse:
return UsageAnalyticsResourceWithRawResponse(self._accounts.usage_analytics)

@cached_property
def origins(self) -> OriginsResourceWithRawResponse:
return OriginsResourceWithRawResponse(self._accounts.origins)
Expand All @@ -123,6 +143,10 @@ def __init__(self, accounts: AsyncAccountsResource) -> None:
def usage(self) -> AsyncUsageResourceWithRawResponse:
return AsyncUsageResourceWithRawResponse(self._accounts.usage)

@cached_property
def usage_analytics(self) -> AsyncUsageAnalyticsResourceWithRawResponse:
return AsyncUsageAnalyticsResourceWithRawResponse(self._accounts.usage_analytics)

@cached_property
def origins(self) -> AsyncOriginsResourceWithRawResponse:
return AsyncOriginsResourceWithRawResponse(self._accounts.origins)
Expand All @@ -140,6 +164,10 @@ def __init__(self, accounts: AccountsResource) -> None:
def usage(self) -> UsageResourceWithStreamingResponse:
return UsageResourceWithStreamingResponse(self._accounts.usage)

@cached_property
def usage_analytics(self) -> UsageAnalyticsResourceWithStreamingResponse:
return UsageAnalyticsResourceWithStreamingResponse(self._accounts.usage_analytics)

@cached_property
def origins(self) -> OriginsResourceWithStreamingResponse:
return OriginsResourceWithStreamingResponse(self._accounts.origins)
Expand All @@ -157,6 +185,10 @@ def __init__(self, accounts: AsyncAccountsResource) -> None:
def usage(self) -> AsyncUsageResourceWithStreamingResponse:
return AsyncUsageResourceWithStreamingResponse(self._accounts.usage)

@cached_property
def usage_analytics(self) -> AsyncUsageAnalyticsResourceWithStreamingResponse:
return AsyncUsageAnalyticsResourceWithStreamingResponse(self._accounts.usage_analytics)

@cached_property
def origins(self) -> AsyncOriginsResourceWithStreamingResponse:
return AsyncOriginsResourceWithStreamingResponse(self._accounts.origins)
Expand Down
12 changes: 12 additions & 0 deletions src/imagekitio/resources/accounts/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def get(
other words, the data covers the period starting from the specified start date
up to, but not including, the end date.

For an agency account, the returned usage is aggregated across the agency and
all of its child accounts that are billed to it.

The response is cached for 6 hours per account, date range and requested
metrics.

Args:
end_date: Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`.
The difference between `startDate` and `endDate` should be less than 90 days.
Expand Down Expand Up @@ -136,6 +142,12 @@ async def get(
other words, the data covers the period starting from the specified start date
up to, but not including, the end date.

For an agency account, the returned usage is aggregated across the agency and
all of its child accounts that are billed to it.

The response is cached for 6 hours per account, date range and requested
metrics.

Args:
end_date: Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`.
The difference between `startDate` and `endDate` should be less than 90 days.
Expand Down
224 changes: 224 additions & 0 deletions src/imagekitio/resources/accounts/usage_analytics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Union
from datetime import date

import httpx

from ..._types import Body, Query, Headers, NotGiven, not_given
from ..._utils import maybe_transform, async_maybe_transform
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ..._base_client import make_request_options
from ...types.accounts import usage_analytics_get_params
from ...types.accounts.usage_analytics_response import UsageAnalyticsResponse

__all__ = ["UsageAnalyticsResource", "AsyncUsageAnalyticsResource"]


class UsageAnalyticsResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> UsageAnalyticsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/imagekit-developer/imagekit-python#accessing-raw-response-data-eg-headers
"""
return UsageAnalyticsResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> UsageAnalyticsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/imagekit-developer/imagekit-python#with_streaming_response
"""
return UsageAnalyticsResourceWithStreamingResponse(self)

def get(
self,
*,
end_date: Union[str, date],
start_date: Union[str, date],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UsageAnalyticsResponse:
"""
**Note:** This API is currently in beta.

Get the account analytics data between two dates. The response covers the period
from the start date to the end date, both dates inclusive. Both dates are
interpreted as UTC calendar days.

The returned data is scoped to the requesting account only. Unlike
`/v1/accounts/usage`, an agency account's analytics are not aggregated across
its child accounts.

The response is cached for 5 minutes per account and date range. Use
`generatedAt` to check how fresh the returned data is.

Args:
end_date: Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
It should be after the `startDate`. The difference between `startDate` and
`endDate` should be less than 90 days.

start_date: Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
It should be before the `endDate`. The difference between `startDate` and
`endDate` should be less than 90 days.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get(
"/v1/accounts/usage-analytics",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"end_date": end_date,
"start_date": start_date,
},
usage_analytics_get_params.UsageAnalyticsGetParams,
),
),
cast_to=UsageAnalyticsResponse,
)


class AsyncUsageAnalyticsResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncUsageAnalyticsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/imagekit-developer/imagekit-python#accessing-raw-response-data-eg-headers
"""
return AsyncUsageAnalyticsResourceWithRawResponse(self)

@cached_property
def with_streaming_response(self) -> AsyncUsageAnalyticsResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.

For more information, see https://www.github.com/imagekit-developer/imagekit-python#with_streaming_response
"""
return AsyncUsageAnalyticsResourceWithStreamingResponse(self)

async def get(
self,
*,
end_date: Union[str, date],
start_date: Union[str, date],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> UsageAnalyticsResponse:
"""
**Note:** This API is currently in beta.

Get the account analytics data between two dates. The response covers the period
from the start date to the end date, both dates inclusive. Both dates are
interpreted as UTC calendar days.

The returned data is scoped to the requesting account only. Unlike
`/v1/accounts/usage`, an agency account's analytics are not aggregated across
its child accounts.

The response is cached for 5 minutes per account and date range. Use
`generatedAt` to check how fresh the returned data is.

Args:
end_date: Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
It should be after the `startDate`. The difference between `startDate` and
`endDate` should be less than 90 days.

start_date: Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar day.
It should be before the `endDate`. The difference between `startDate` and
`endDate` should be less than 90 days.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._get(
"/v1/accounts/usage-analytics",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{
"end_date": end_date,
"start_date": start_date,
},
usage_analytics_get_params.UsageAnalyticsGetParams,
),
),
cast_to=UsageAnalyticsResponse,
)


class UsageAnalyticsResourceWithRawResponse:
def __init__(self, usage_analytics: UsageAnalyticsResource) -> None:
self._usage_analytics = usage_analytics

self.get = to_raw_response_wrapper(
usage_analytics.get,
)


class AsyncUsageAnalyticsResourceWithRawResponse:
def __init__(self, usage_analytics: AsyncUsageAnalyticsResource) -> None:
self._usage_analytics = usage_analytics

self.get = async_to_raw_response_wrapper(
usage_analytics.get,
)


class UsageAnalyticsResourceWithStreamingResponse:
def __init__(self, usage_analytics: UsageAnalyticsResource) -> None:
self._usage_analytics = usage_analytics

self.get = to_streamed_response_wrapper(
usage_analytics.get,
)


class AsyncUsageAnalyticsResourceWithStreamingResponse:
def __init__(self, usage_analytics: AsyncUsageAnalyticsResource) -> None:
self._usage_analytics = usage_analytics

self.get = async_to_streamed_response_wrapper(
usage_analytics.get,
)
3 changes: 3 additions & 0 deletions src/imagekitio/types/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from .origin_request_param import OriginRequestParam as OriginRequestParam
from .origin_update_params import OriginUpdateParams as OriginUpdateParams
from .url_endpoint_response import URLEndpointResponse as URLEndpointResponse
from .request_bandwidth_entry import RequestBandwidthEntry as RequestBandwidthEntry
from .usage_analytics_response import UsageAnalyticsResponse as UsageAnalyticsResponse
from .url_endpoint_create_params import URLEndpointCreateParams as URLEndpointCreateParams
from .url_endpoint_list_response import URLEndpointListResponse as URLEndpointListResponse
from .url_endpoint_update_params import URLEndpointUpdateParams as URLEndpointUpdateParams
from .usage_analytics_get_params import UsageAnalyticsGetParams as UsageAnalyticsGetParams
Loading
Loading