openmeter 1.0.0b54__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of openmeter might be problematic. Click here for more details.
- openmeter/__init__.py +89 -15
- openmeter/_base_client.py +2041 -0
- openmeter/_client.py +518 -70
- openmeter/_compat.py +221 -0
- openmeter/_constants.py +14 -0
- openmeter/_exceptions.py +108 -0
- openmeter/_files.py +127 -0
- openmeter/_models.py +777 -0
- openmeter/_qs.py +150 -0
- openmeter/_resource.py +43 -0
- openmeter/_response.py +820 -0
- openmeter/_streaming.py +333 -0
- openmeter/_types.py +222 -0
- openmeter/_utils/__init__.py +56 -0
- openmeter/_utils/_logs.py +25 -0
- openmeter/_utils/_proxy.py +63 -0
- openmeter/_utils/_reflection.py +42 -0
- openmeter/_utils/_streams.py +12 -0
- openmeter/_utils/_sync.py +81 -0
- openmeter/_utils/_transform.py +387 -0
- openmeter/_utils/_typing.py +120 -0
- openmeter/_utils/_utils.py +419 -0
- openmeter/_version.py +4 -0
- openmeter/lib/.keep +4 -0
- openmeter/py.typed +0 -1
- openmeter/resources/__init__.py +103 -0
- openmeter/resources/debug/__init__.py +33 -0
- openmeter/resources/debug/debug.py +102 -0
- openmeter/resources/debug/metrics.py +146 -0
- openmeter/resources/entitlements/__init__.py +47 -0
- openmeter/resources/entitlements/entitlements.py +450 -0
- openmeter/resources/entitlements/features.py +578 -0
- openmeter/resources/entitlements/grants.py +389 -0
- openmeter/resources/events.py +442 -0
- openmeter/resources/meters/__init__.py +33 -0
- openmeter/resources/meters/meters.py +666 -0
- openmeter/resources/meters/subjects.py +163 -0
- openmeter/resources/notifications/__init__.py +75 -0
- openmeter/resources/notifications/channels.py +686 -0
- openmeter/resources/notifications/events.py +365 -0
- openmeter/resources/notifications/notifications.py +198 -0
- openmeter/resources/notifications/rules.py +781 -0
- openmeter/resources/notifications/webhook.py +208 -0
- openmeter/resources/portal/__init__.py +47 -0
- openmeter/resources/portal/meters.py +230 -0
- openmeter/resources/portal/portal.py +112 -0
- openmeter/resources/portal/tokens.py +359 -0
- openmeter/resources/subjects/entitlements/__init__.py +33 -0
- openmeter/resources/subjects/entitlements/entitlements.py +1881 -0
- openmeter/resources/subjects/entitlements/grants.py +453 -0
- openmeter/resources/subjects.py +419 -0
- openmeter/types/__init__.py +21 -0
- openmeter/types/debug/__init__.py +5 -0
- openmeter/types/debug/metric_list_response.py +7 -0
- openmeter/types/entitlement.py +238 -0
- openmeter/types/entitlements/__init__.py +11 -0
- openmeter/types/entitlements/feature.py +61 -0
- openmeter/types/entitlements/feature_create_params.py +43 -0
- openmeter/types/entitlements/feature_list_params.py +23 -0
- openmeter/types/entitlements/grant_list_params.py +57 -0
- openmeter/types/entitlements/grant_list_response.py +11 -0
- openmeter/types/entitlements/grant_paginated_response.py +24 -0
- openmeter/types/entitlements/list_features_result.py +28 -0
- openmeter/types/event_ingest_params.py +46 -0
- openmeter/types/event_ingest_response.py +43 -0
- openmeter/types/event_list_params.py +22 -0
- openmeter/types/event_list_response.py +9 -0
- openmeter/types/ingested_event.py +59 -0
- openmeter/types/list_entitlements_result.py +28 -0
- openmeter/types/meter.py +53 -0
- openmeter/types/meter_create_params.py +50 -0
- openmeter/types/meter_list_response.py +9 -0
- openmeter/types/meter_query_params.py +50 -0
- openmeter/types/meter_query_result.py +35 -0
- openmeter/types/meters/__init__.py +5 -0
- openmeter/types/meters/subject_list_response.py +8 -0
- openmeter/types/notifications/__init__.py +18 -0
- openmeter/types/notifications/channel_create_params.py +34 -0
- openmeter/types/notifications/channel_list_params.py +41 -0
- openmeter/types/notifications/channel_list_response.py +24 -0
- openmeter/types/notifications/channel_update_params.py +34 -0
- openmeter/types/notifications/event_list_params.py +61 -0
- openmeter/types/notifications/event_list_response.py +24 -0
- openmeter/types/notifications/notification_channel.py +47 -0
- openmeter/types/notifications/notification_event.py +215 -0
- openmeter/types/notifications/notification_rule.py +70 -0
- openmeter/types/notifications/rule_create_params.py +39 -0
- openmeter/types/notifications/rule_list_params.py +54 -0
- openmeter/types/notifications/rule_list_response.py +24 -0
- openmeter/types/notifications/rule_update_params.py +39 -0
- openmeter/types/notifications/webhook_svix_params.py +26 -0
- openmeter/types/portal/__init__.py +10 -0
- openmeter/types/portal/meter_query_params.py +44 -0
- openmeter/types/portal/portal_token.py +28 -0
- openmeter/types/portal/token_create_params.py +17 -0
- openmeter/types/portal/token_invalidate_params.py +15 -0
- openmeter/types/portal/token_list_params.py +12 -0
- openmeter/types/portal/token_list_response.py +9 -0
- openmeter/types/shared/__init__.py +3 -0
- openmeter/types/subject.py +37 -0
- openmeter/types/subject_list_response.py +9 -0
- openmeter/types/subject_param.py +27 -0
- openmeter/types/subject_upsert_params.py +39 -0
- openmeter/types/subject_upsert_response.py +10 -0
- openmeter/types/subjects/__init__.py +13 -0
- openmeter/types/subjects/entitlement_history_params.py +35 -0
- openmeter/types/subjects/entitlement_history_response.py +98 -0
- openmeter/types/subjects/entitlement_list_response.py +10 -0
- openmeter/types/subjects/entitlements/__init__.py +8 -0
- openmeter/types/subjects/entitlements/entitlement_grant.py +103 -0
- openmeter/types/subjects/entitlements/grant_list_response.py +10 -0
- openmeter-2.0.0.dist-info/METADATA +396 -0
- openmeter-2.0.0.dist-info/RECORD +115 -0
- {openmeter-1.0.0b54.dist-info → openmeter-2.0.0.dist-info}/WHEEL +1 -1
- openmeter-2.0.0.dist-info/licenses/LICENSE +201 -0
- openmeter/_configuration.py +0 -36
- openmeter/_operations/__init__.py +0 -17
- openmeter/_operations/_operations.py +0 -2105
- openmeter/_operations/_patch.py +0 -20
- openmeter/_patch.py +0 -20
- openmeter/_serialization.py +0 -2008
- openmeter/_vendor.py +0 -24
- openmeter/aio/__init__.py +0 -21
- openmeter/aio/_client.py +0 -83
- openmeter/aio/_configuration.py +0 -36
- openmeter/aio/_operations/__init__.py +0 -17
- openmeter/aio/_operations/_operations.py +0 -1778
- openmeter/aio/_operations/_patch.py +0 -20
- openmeter/aio/_patch.py +0 -20
- openmeter/aio/_vendor.py +0 -24
- openmeter-1.0.0b54.dist-info/METADATA +0 -92
- openmeter-1.0.0b54.dist-info/RECORD +0 -21
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .feature import Feature as Feature
|
|
6
|
+
from .grant_list_params import GrantListParams as GrantListParams
|
|
7
|
+
from .feature_list_params import FeatureListParams as FeatureListParams
|
|
8
|
+
from .grant_list_response import GrantListResponse as GrantListResponse
|
|
9
|
+
from .list_features_result import ListFeaturesResult as ListFeaturesResult
|
|
10
|
+
from .feature_create_params import FeatureCreateParams as FeatureCreateParams
|
|
11
|
+
from .grant_paginated_response import GrantPaginatedResponse as GrantPaginatedResponse
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from ..._models import BaseModel
|
|
9
|
+
|
|
10
|
+
__all__ = ["Feature"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Feature(BaseModel):
|
|
14
|
+
id: str
|
|
15
|
+
"""Readonly unique ULID identifier."""
|
|
16
|
+
|
|
17
|
+
created_at: datetime = FieldInfo(alias="createdAt")
|
|
18
|
+
"""The date and time the resource was created."""
|
|
19
|
+
|
|
20
|
+
key: str
|
|
21
|
+
"""
|
|
22
|
+
The key is an immutable unique identifier of the feature used throughout the
|
|
23
|
+
API, for example when interacting with a subject's entitlements. The key has to
|
|
24
|
+
be unique across all active features, but archived features can share the same
|
|
25
|
+
key. The key should consist of lowercase alphanumeric characters and dashes.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
name: str
|
|
29
|
+
"""The name of the feature."""
|
|
30
|
+
|
|
31
|
+
updated_at: datetime = FieldInfo(alias="updatedAt")
|
|
32
|
+
"""The date and time the resource was last updated.
|
|
33
|
+
|
|
34
|
+
The initial value is the same as createdAt.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
archived_at: Optional[datetime] = FieldInfo(alias="archivedAt", default=None)
|
|
38
|
+
"""If the feature is archived, no new entitlements can be created for it."""
|
|
39
|
+
|
|
40
|
+
deleted_at: Optional[datetime] = FieldInfo(alias="deletedAt", default=None)
|
|
41
|
+
"""The date and time the resource was deleted."""
|
|
42
|
+
|
|
43
|
+
metadata: Optional[Dict[str, str]] = None
|
|
44
|
+
"""
|
|
45
|
+
Additional metadata for the feature, useful for syncing with external systems
|
|
46
|
+
and annotating custom fields.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
meter_group_by_filters: Optional[Dict[str, str]] = FieldInfo(alias="meterGroupByFilters", default=None)
|
|
50
|
+
"""Optional meter group by filters.
|
|
51
|
+
|
|
52
|
+
Useful if the meter scope is broader than what feature tracks. Example scenario
|
|
53
|
+
would be a meter tracking all token use with groupBy fields for the model, then
|
|
54
|
+
the feature could filter for model=gpt-4.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
meter_slug: Optional[str] = FieldInfo(alias="meterSlug", default=None)
|
|
58
|
+
"""
|
|
59
|
+
The meter that the feature is associated with and and based on which usage is
|
|
60
|
+
calculated. The meter selected must have SUM or COUNT aggregation.
|
|
61
|
+
"""
|
|
@@ -0,0 +1,43 @@
|
|
|
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 Dict
|
|
6
|
+
from typing_extensions import Required, Annotated, TypedDict
|
|
7
|
+
|
|
8
|
+
from ..._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["FeatureCreateParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class FeatureCreateParams(TypedDict, total=False):
|
|
14
|
+
key: Required[str]
|
|
15
|
+
"""
|
|
16
|
+
The key is an immutable unique identifier of the feature used throughout the
|
|
17
|
+
API, for example when interacting with a subject's entitlements. The key has to
|
|
18
|
+
be unique across all active features, but archived features can share the same
|
|
19
|
+
key. The key should consist of lowercase alphanumeric characters and dashes.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
name: Required[str]
|
|
23
|
+
"""The name of the feature."""
|
|
24
|
+
|
|
25
|
+
metadata: Dict[str, str]
|
|
26
|
+
"""
|
|
27
|
+
Additional metadata for the feature, useful for syncing with external systems
|
|
28
|
+
and annotating custom fields.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
meter_group_by_filters: Annotated[Dict[str, str], PropertyInfo(alias="meterGroupByFilters")]
|
|
32
|
+
"""Optional meter group by filters.
|
|
33
|
+
|
|
34
|
+
Useful if the meter scope is broader than what feature tracks. Example scenario
|
|
35
|
+
would be a meter tracking all token use with groupBy fields for the model, then
|
|
36
|
+
the feature could filter for model=gpt-4.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
meter_slug: Annotated[str, PropertyInfo(alias="meterSlug")]
|
|
40
|
+
"""
|
|
41
|
+
The meter that the feature is associated with and and based on which usage is
|
|
42
|
+
calculated. The meter selected must have SUM or COUNT aggregation.
|
|
43
|
+
"""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal, Annotated, TypedDict
|
|
6
|
+
|
|
7
|
+
from ..._utils import PropertyInfo
|
|
8
|
+
|
|
9
|
+
__all__ = ["FeatureListParams"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FeatureListParams(TypedDict, total=False):
|
|
13
|
+
include_archived: Annotated[bool, PropertyInfo(alias="includeArchived")]
|
|
14
|
+
"""Include archived features."""
|
|
15
|
+
|
|
16
|
+
limit: int
|
|
17
|
+
"""Number of entries to return"""
|
|
18
|
+
|
|
19
|
+
offset: int
|
|
20
|
+
"""Number of entries to skip"""
|
|
21
|
+
|
|
22
|
+
order_by: Annotated[Literal["id", "createdAt", "updatedAt"], PropertyInfo(alias="orderBy")]
|
|
23
|
+
"""Order by field"""
|
|
@@ -0,0 +1,57 @@
|
|
|
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 List
|
|
6
|
+
from typing_extensions import Literal, Annotated, TypedDict
|
|
7
|
+
|
|
8
|
+
from ..._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["GrantListParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GrantListParams(TypedDict, total=False):
|
|
14
|
+
feature: List[str]
|
|
15
|
+
"""Filtering by multiple features.
|
|
16
|
+
|
|
17
|
+
Usage: `?feature=feature-1&feature=feature-2`
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
include_deleted: Annotated[bool, PropertyInfo(alias="includeDeleted")]
|
|
21
|
+
"""Include deleted"""
|
|
22
|
+
|
|
23
|
+
limit: int
|
|
24
|
+
"""Number of items to return.
|
|
25
|
+
|
|
26
|
+
Default is 100.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
offset: int
|
|
30
|
+
"""Number of items to skip.
|
|
31
|
+
|
|
32
|
+
Default is 0.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
order: Literal["ASC", "DESC"]
|
|
36
|
+
"""The order direction."""
|
|
37
|
+
|
|
38
|
+
order_by: Annotated[Literal["id", "createdAt", "updatedAt"], PropertyInfo(alias="orderBy")]
|
|
39
|
+
"""The order by field."""
|
|
40
|
+
|
|
41
|
+
page: int
|
|
42
|
+
"""Start date-time in RFC 3339 format.
|
|
43
|
+
|
|
44
|
+
Inclusive.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
page_size: Annotated[int, PropertyInfo(alias="pageSize")]
|
|
48
|
+
"""Number of items per page.
|
|
49
|
+
|
|
50
|
+
Default is 100.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
subject: List[str]
|
|
54
|
+
"""Filtering by multiple subjects.
|
|
55
|
+
|
|
56
|
+
Usage: `?subject=customer-1&subject=customer-2`
|
|
57
|
+
"""
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Union
|
|
4
|
+
from typing_extensions import TypeAlias
|
|
5
|
+
|
|
6
|
+
from .grant_paginated_response import GrantPaginatedResponse
|
|
7
|
+
from ..subjects.entitlements.entitlement_grant import EntitlementGrant
|
|
8
|
+
|
|
9
|
+
__all__ = ["GrantListResponse"]
|
|
10
|
+
|
|
11
|
+
GrantListResponse: TypeAlias = Union[List[EntitlementGrant], GrantPaginatedResponse]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
from pydantic import Field as FieldInfo
|
|
6
|
+
|
|
7
|
+
from ..._models import BaseModel
|
|
8
|
+
from ..subjects.entitlements.entitlement_grant import EntitlementGrant
|
|
9
|
+
|
|
10
|
+
__all__ = ["GrantPaginatedResponse"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GrantPaginatedResponse(BaseModel):
|
|
14
|
+
items: List[EntitlementGrant]
|
|
15
|
+
"""The items in the current page."""
|
|
16
|
+
|
|
17
|
+
page: int
|
|
18
|
+
"""The items in the current page."""
|
|
19
|
+
|
|
20
|
+
page_size: int = FieldInfo(alias="pageSize")
|
|
21
|
+
"""The items in the current page."""
|
|
22
|
+
|
|
23
|
+
total_count: int = FieldInfo(alias="totalCount")
|
|
24
|
+
"""The items in the current page."""
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Union
|
|
4
|
+
from typing_extensions import TypeAlias
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .feature import Feature
|
|
9
|
+
from ..._models import BaseModel
|
|
10
|
+
|
|
11
|
+
__all__ = ["ListFeaturesResult", "FeaturePaginatedResponse"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FeaturePaginatedResponse(BaseModel):
|
|
15
|
+
items: List[Feature]
|
|
16
|
+
"""The items in the current page."""
|
|
17
|
+
|
|
18
|
+
page: int
|
|
19
|
+
"""The items in the current page."""
|
|
20
|
+
|
|
21
|
+
page_size: int = FieldInfo(alias="pageSize")
|
|
22
|
+
"""The items in the current page."""
|
|
23
|
+
|
|
24
|
+
total_count: int = FieldInfo(alias="totalCount")
|
|
25
|
+
"""The items in the current page."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ListFeaturesResult: TypeAlias = Union[List[Feature], FeaturePaginatedResponse]
|
|
@@ -0,0 +1,46 @@
|
|
|
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, Optional
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from typing_extensions import Required, Annotated, TypedDict
|
|
8
|
+
|
|
9
|
+
from .._utils import PropertyInfo
|
|
10
|
+
|
|
11
|
+
__all__ = ["EventIngestParams"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class EventIngestParams(TypedDict, total=False):
|
|
15
|
+
id: Required[str]
|
|
16
|
+
"""Identifies the event."""
|
|
17
|
+
|
|
18
|
+
source: Required[str]
|
|
19
|
+
"""Identifies the context in which an event happened."""
|
|
20
|
+
|
|
21
|
+
specversion: Required[str]
|
|
22
|
+
"""The version of the CloudEvents specification which the event uses."""
|
|
23
|
+
|
|
24
|
+
subject: Required[str]
|
|
25
|
+
"""
|
|
26
|
+
Describes the subject of the event in the context of the event producer
|
|
27
|
+
(identified by source).
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
type: Required[str]
|
|
31
|
+
"""
|
|
32
|
+
Contains a value describing the type of event related to the originating
|
|
33
|
+
occurrence.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
data: Union[str, object, None]
|
|
37
|
+
"""The event payload."""
|
|
38
|
+
|
|
39
|
+
datacontenttype: Optional[str]
|
|
40
|
+
"""Content type of the data value. Must adhere to RFC 2046 format."""
|
|
41
|
+
|
|
42
|
+
dataschema: Optional[str]
|
|
43
|
+
"""Identifies the schema that data adheres to."""
|
|
44
|
+
|
|
45
|
+
time: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
|
|
46
|
+
"""Timestamp of when the occurrence happened. Must adhere to RFC 3339."""
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Union, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from .._models import BaseModel
|
|
7
|
+
|
|
8
|
+
__all__ = ["EventIngestResponse"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EventIngestResponse(BaseModel):
|
|
12
|
+
id: str
|
|
13
|
+
"""Identifies the event."""
|
|
14
|
+
|
|
15
|
+
source: str
|
|
16
|
+
"""Identifies the context in which an event happened."""
|
|
17
|
+
|
|
18
|
+
specversion: str
|
|
19
|
+
"""The version of the CloudEvents specification which the event uses."""
|
|
20
|
+
|
|
21
|
+
subject: str
|
|
22
|
+
"""
|
|
23
|
+
Describes the subject of the event in the context of the event producer
|
|
24
|
+
(identified by source).
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
type: str
|
|
28
|
+
"""
|
|
29
|
+
Contains a value describing the type of event related to the originating
|
|
30
|
+
occurrence.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
data: Union[str, object, None] = None
|
|
34
|
+
"""The event payload."""
|
|
35
|
+
|
|
36
|
+
datacontenttype: Optional[str] = None
|
|
37
|
+
"""Content type of the data value. Must adhere to RFC 2046 format."""
|
|
38
|
+
|
|
39
|
+
dataschema: Optional[str] = None
|
|
40
|
+
"""Identifies the schema that data adheres to."""
|
|
41
|
+
|
|
42
|
+
time: Optional[datetime] = None
|
|
43
|
+
"""Timestamp of when the occurrence happened. Must adhere to RFC 3339."""
|
|
@@ -0,0 +1,22 @@
|
|
|
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 datetime
|
|
7
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
|
+
|
|
9
|
+
from .._utils import PropertyInfo
|
|
10
|
+
|
|
11
|
+
__all__ = ["EventListParams"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class EventListParams(TypedDict, total=False):
|
|
15
|
+
from_: Annotated[Union[str, datetime], PropertyInfo(alias="from", format="iso8601")]
|
|
16
|
+
"""Start date-time in RFC 3339 format. Inclusive."""
|
|
17
|
+
|
|
18
|
+
limit: int
|
|
19
|
+
"""Number of events to return"""
|
|
20
|
+
|
|
21
|
+
to: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
|
|
22
|
+
"""End date-time in RFC 3339 format. Inclusive."""
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Union, Optional
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
|
|
10
|
+
__all__ = ["IngestedEvent", "Event"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Event(BaseModel):
|
|
14
|
+
id: str
|
|
15
|
+
"""Identifies the event."""
|
|
16
|
+
|
|
17
|
+
source: str
|
|
18
|
+
"""Identifies the context in which an event happened."""
|
|
19
|
+
|
|
20
|
+
specversion: str
|
|
21
|
+
"""The version of the CloudEvents specification which the event uses."""
|
|
22
|
+
|
|
23
|
+
subject: str
|
|
24
|
+
"""
|
|
25
|
+
Describes the subject of the event in the context of the event producer
|
|
26
|
+
(identified by source).
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
type: str
|
|
30
|
+
"""
|
|
31
|
+
Contains a value describing the type of event related to the originating
|
|
32
|
+
occurrence.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
data: Union[str, object, None] = None
|
|
36
|
+
"""The event payload."""
|
|
37
|
+
|
|
38
|
+
datacontenttype: Optional[str] = None
|
|
39
|
+
"""Content type of the data value. Must adhere to RFC 2046 format."""
|
|
40
|
+
|
|
41
|
+
dataschema: Optional[str] = None
|
|
42
|
+
"""Identifies the schema that data adheres to."""
|
|
43
|
+
|
|
44
|
+
time: Optional[datetime] = None
|
|
45
|
+
"""Timestamp of when the occurrence happened. Must adhere to RFC 3339."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class IngestedEvent(BaseModel):
|
|
49
|
+
event: Event
|
|
50
|
+
"""CloudEvents Specification JSON Schema"""
|
|
51
|
+
|
|
52
|
+
ingested_at: datetime = FieldInfo(alias="ingestedAt")
|
|
53
|
+
"""The date and time the event was ingested."""
|
|
54
|
+
|
|
55
|
+
stored_at: datetime = FieldInfo(alias="storedAt")
|
|
56
|
+
"""The date and time the event was stored."""
|
|
57
|
+
|
|
58
|
+
validation_error: Optional[str] = FieldInfo(alias="validationError", default=None)
|
|
59
|
+
"""The validation error if the event failed validation."""
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Union
|
|
4
|
+
from typing_extensions import TypeAlias
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
from .entitlement import Entitlement
|
|
10
|
+
|
|
11
|
+
__all__ = ["ListEntitlementsResult", "EntitlementPaginatedResponse"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class EntitlementPaginatedResponse(BaseModel):
|
|
15
|
+
items: List[Entitlement]
|
|
16
|
+
"""The items in the current page."""
|
|
17
|
+
|
|
18
|
+
page: int
|
|
19
|
+
"""The items in the current page."""
|
|
20
|
+
|
|
21
|
+
page_size: int = FieldInfo(alias="pageSize")
|
|
22
|
+
"""The items in the current page."""
|
|
23
|
+
|
|
24
|
+
total_count: int = FieldInfo(alias="totalCount")
|
|
25
|
+
"""The items in the current page."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ListEntitlementsResult: TypeAlias = Union[List[Entitlement], EntitlementPaginatedResponse]
|
openmeter/types/meter.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, Optional
|
|
4
|
+
from typing_extensions import Literal
|
|
5
|
+
|
|
6
|
+
from pydantic import Field as FieldInfo
|
|
7
|
+
|
|
8
|
+
from .._models import BaseModel
|
|
9
|
+
|
|
10
|
+
__all__ = ["Meter"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Meter(BaseModel):
|
|
14
|
+
id: str
|
|
15
|
+
"""A unique identifier for the meter."""
|
|
16
|
+
|
|
17
|
+
aggregation: Literal["SUM", "COUNT", "UNIQUE_COUNT", "AVG", "MIN", "MAX"]
|
|
18
|
+
"""The aggregation type to use for the meter."""
|
|
19
|
+
|
|
20
|
+
event_type: str = FieldInfo(alias="eventType")
|
|
21
|
+
"""The event type to aggregate."""
|
|
22
|
+
|
|
23
|
+
slug: str
|
|
24
|
+
"""
|
|
25
|
+
A unique, human-readable identifier for the meter. Must consist only
|
|
26
|
+
alphanumeric and underscore characters.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
window_size: Literal["MINUTE", "HOUR", "DAY"] = FieldInfo(alias="windowSize")
|
|
30
|
+
"""Aggregation window size."""
|
|
31
|
+
|
|
32
|
+
description: Optional[str] = None
|
|
33
|
+
"""A description of the meter."""
|
|
34
|
+
|
|
35
|
+
group_by: Optional[Dict[str, str]] = FieldInfo(alias="groupBy", default=None)
|
|
36
|
+
"""Named JSONPath expressions to extract the group by values from the event data.
|
|
37
|
+
|
|
38
|
+
Keys must be unique and consist only alphanumeric and underscore characters.
|
|
39
|
+
|
|
40
|
+
TODO: add key format enforcement
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
value_property: Optional[str] = FieldInfo(alias="valueProperty", default=None)
|
|
44
|
+
"""
|
|
45
|
+
JSONPath expression to extract the value from the ingested event's data
|
|
46
|
+
property.
|
|
47
|
+
|
|
48
|
+
The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a
|
|
49
|
+
string that can be parsed to a number.
|
|
50
|
+
|
|
51
|
+
For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT
|
|
52
|
+
aggregation the valueProperty is ignored.
|
|
53
|
+
"""
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Dict
|
|
6
|
+
from typing_extensions import Literal, Required, Annotated, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._utils import PropertyInfo
|
|
9
|
+
|
|
10
|
+
__all__ = ["MeterCreateParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MeterCreateParams(TypedDict, total=False):
|
|
14
|
+
aggregation: Required[Literal["SUM", "COUNT", "UNIQUE_COUNT", "AVG", "MIN", "MAX"]]
|
|
15
|
+
"""The aggregation type to use for the meter."""
|
|
16
|
+
|
|
17
|
+
event_type: Required[Annotated[str, PropertyInfo(alias="eventType")]]
|
|
18
|
+
"""The event type to aggregate."""
|
|
19
|
+
|
|
20
|
+
slug: Required[str]
|
|
21
|
+
"""
|
|
22
|
+
A unique, human-readable identifier for the meter. Must consist only
|
|
23
|
+
alphanumeric and underscore characters.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
window_size: Required[Annotated[Literal["MINUTE", "HOUR", "DAY"], PropertyInfo(alias="windowSize")]]
|
|
27
|
+
"""Aggregation window size."""
|
|
28
|
+
|
|
29
|
+
description: str
|
|
30
|
+
"""A description of the meter."""
|
|
31
|
+
|
|
32
|
+
group_by: Annotated[Dict[str, str], PropertyInfo(alias="groupBy")]
|
|
33
|
+
"""Named JSONPath expressions to extract the group by values from the event data.
|
|
34
|
+
|
|
35
|
+
Keys must be unique and consist only alphanumeric and underscore characters.
|
|
36
|
+
|
|
37
|
+
TODO: add key format enforcement
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
value_property: Annotated[str, PropertyInfo(alias="valueProperty")]
|
|
41
|
+
"""
|
|
42
|
+
JSONPath expression to extract the value from the ingested event's data
|
|
43
|
+
property.
|
|
44
|
+
|
|
45
|
+
The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a
|
|
46
|
+
string that can be parsed to a number.
|
|
47
|
+
|
|
48
|
+
For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT
|
|
49
|
+
aggregation the valueProperty is ignored.
|
|
50
|
+
"""
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Dict, List, Union
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from typing_extensions import Literal, Annotated, TypedDict
|
|
8
|
+
|
|
9
|
+
from .._utils import PropertyInfo
|
|
10
|
+
|
|
11
|
+
__all__ = ["MeterQueryParams"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MeterQueryParams(TypedDict, total=False):
|
|
15
|
+
filter_group_by: Annotated[Dict[str, str], PropertyInfo(alias="filterGroupBy")]
|
|
16
|
+
"""Simple filter for group bys with exact match.
|
|
17
|
+
|
|
18
|
+
Usage: `?filterGroupBy[type]=input&filterGroupBy[model]=gpt-4`
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from_: Annotated[Union[str, datetime], PropertyInfo(alias="from", format="iso8601")]
|
|
22
|
+
"""Start date-time in RFC 3339 format. Inclusive."""
|
|
23
|
+
|
|
24
|
+
group_by: Annotated[List[str], PropertyInfo(alias="groupBy")]
|
|
25
|
+
"""
|
|
26
|
+
If not specified a single aggregate will be returned for each subject and time
|
|
27
|
+
window. `subject` is a reserved group by value.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
subject: List[str]
|
|
31
|
+
"""Filtering by multiple subjects.
|
|
32
|
+
|
|
33
|
+
Usage: ?subject=customer-1&subject=customer-2
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
to: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
|
|
37
|
+
"""End date-time in RFC 3339 format. Inclusive."""
|
|
38
|
+
|
|
39
|
+
window_size: Annotated[Literal["MINUTE", "HOUR", "DAY"], PropertyInfo(alias="windowSize")]
|
|
40
|
+
"""
|
|
41
|
+
If not specified, a single usage aggregate will be returned for the entirety of
|
|
42
|
+
the specified period for each subject and group.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
window_time_zone: Annotated[str, PropertyInfo(alias="windowTimeZone")]
|
|
46
|
+
"""
|
|
47
|
+
The value is the name of the time zone as defined in the IANA Time Zone Database
|
|
48
|
+
(http://www.iana.org/time-zones). If not specified, the UTC timezone will be
|
|
49
|
+
used.
|
|
50
|
+
"""
|