"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

from __future__ import annotations
import dataclasses
import requests as requests_http
from ..shared import groupedsubscriptionusage as shared_groupedsubscriptionusage
from ..shared import ungroupedsubscriptionusage as shared_ungroupedsubscriptionusage
from datetime import datetime
from enum import Enum
from typing import Optional, Union

class FetchSubscriptionUsageGranularityGranularity(str, Enum):
    r"""This determines the windowing of usage reporting."""
    DAY = 'day'

class FetchSubscriptionUsageViewModeViewMode(str, Enum):
    r"""Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior."""
    PERIODIC = 'periodic'
    CUMULATIVE = 'cumulative'



@dataclasses.dataclass
class FetchSubscriptionUsageRequest:
    subscription_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'subscription_id', 'style': 'simple', 'explode': False }})
    billable_metric_id: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'billable_metric_id', 'style': 'form', 'explode': True }})
    cursor: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'cursor', 'style': 'form', 'explode': True }})
    first_dimension_key: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'first_dimension_key', 'style': 'form', 'explode': True }})
    first_dimension_value: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'first_dimension_value', 'style': 'form', 'explode': True }})
    granularity: Optional[FetchSubscriptionUsageGranularityGranularity] = dataclasses.field(default=FetchSubscriptionUsageGranularityGranularity.DAY, metadata={'query_param': { 'field_name': 'granularity', 'style': 'form', 'explode': True }})
    r"""This determines the windowing of usage reporting."""
    group_by: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'group_by', 'style': 'form', 'explode': True }})
    limit: Optional[int] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'limit', 'style': 'form', 'explode': True }})
    second_dimension_key: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'second_dimension_key', 'style': 'form', 'explode': True }})
    second_dimension_value: Optional[str] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'second_dimension_value', 'style': 'form', 'explode': True }})
    timeframe_end: Optional[datetime] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'timeframe_end', 'style': 'form', 'explode': True }})
    timeframe_start: Optional[datetime] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'timeframe_start', 'style': 'form', 'explode': True }})
    view_mode: Optional[FetchSubscriptionUsageViewModeViewMode] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'view_mode', 'style': 'form', 'explode': True }})
    r"""Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior."""
    




@dataclasses.dataclass
class FetchSubscriptionUsageResponse:
    content_type: str = dataclasses.field()
    r"""HTTP response content type for this operation"""
    status_code: int = dataclasses.field()
    r"""HTTP response status code for this operation"""
    raw_response: Optional[requests_http.Response] = dataclasses.field(default=None)
    r"""Raw HTTP response; suitable for custom response parsing"""
    subscription_usage: Optional[Union[shared_ungroupedsubscriptionusage.UngroupedSubscriptionUsage, shared_groupedsubscriptionusage.GroupedSubscriptionUsage]] = dataclasses.field(default=None)
    r"""OK"""
    

