domain-api-limiter 0.1.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.
- domain_api_limiter/__init__.py +29 -0
- domain_api_limiter/config/__init__.py +1 -0
- domain_api_limiter/config/_version.py +3 -0
- domain_api_limiter/decorators/__init__.py +1 -0
- domain_api_limiter/decorators/throttled/__init__.py +8 -0
- domain_api_limiter/decorators/throttled/throttled_client.py +51 -0
- domain_api_limiter/errors/__init__.py +1 -0
- domain_api_limiter/errors/api_limiter_errors.py +33 -0
- domain_api_limiter/errors/constants/__init__.py +1 -0
- domain_api_limiter/errors/constants/api_limiter_errors.py +11 -0
- domain_api_limiter/py.typed +0 -0
- domain_api_limiter/services/__init__.py +1 -0
- domain_api_limiter/services/constants/__init__.py +0 -0
- domain_api_limiter/services/constants/policy.py +27 -0
- domain_api_limiter/services/policy/__init__.py +11 -0
- domain_api_limiter/services/policy/policy_client.py +28 -0
- domain_api_limiter/services/policy/policy_objects.py +116 -0
- domain_api_limiter-0.1.0.dist-info/METADATA +250 -0
- domain_api_limiter-0.1.0.dist-info/RECORD +21 -0
- domain_api_limiter-0.1.0.dist-info/WHEEL +4 -0
- domain_api_limiter-0.1.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Rate-limit declaration toolkit: throttle policies, tier rates, and declaration decorators."""
|
|
2
|
+
|
|
3
|
+
from domain_api_limiter.config._version import __version__
|
|
4
|
+
from domain_api_limiter.decorators.throttled.throttled_client import throttled
|
|
5
|
+
from domain_api_limiter.errors.api_limiter_errors import (
|
|
6
|
+
RateLimitExceeded,
|
|
7
|
+
ThrottleDeclarationError,
|
|
8
|
+
ThrottleError,
|
|
9
|
+
)
|
|
10
|
+
from domain_api_limiter.services.policy.policy_client import PolicyRegistry
|
|
11
|
+
from domain_api_limiter.services.policy.policy_objects import (
|
|
12
|
+
Period,
|
|
13
|
+
RateLimit,
|
|
14
|
+
ThrottlePolicy,
|
|
15
|
+
TierRate,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Period",
|
|
20
|
+
"PolicyRegistry",
|
|
21
|
+
"RateLimit",
|
|
22
|
+
"RateLimitExceeded",
|
|
23
|
+
"ThrottleDeclarationError",
|
|
24
|
+
"ThrottleError",
|
|
25
|
+
"ThrottlePolicy",
|
|
26
|
+
"TierRate",
|
|
27
|
+
"__version__",
|
|
28
|
+
"throttled",
|
|
29
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Package configuration."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Declarative rate-limit decorators."""
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Declarative rate-limit policy attachment for service callables."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable, Mapping
|
|
6
|
+
from typing import Any, TypeVar
|
|
7
|
+
|
|
8
|
+
from domain_api_limiter.services.constants import policy as const
|
|
9
|
+
from domain_api_limiter.services.policy.policy_objects import (
|
|
10
|
+
RateLimit,
|
|
11
|
+
ThrottlePolicy,
|
|
12
|
+
TierRate,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
Decorated = TypeVar("Decorated", bound=Callable[..., Any])
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Throttled:
|
|
19
|
+
"""Decorator factory attaching a validated ThrottlePolicy to a callable."""
|
|
20
|
+
|
|
21
|
+
def __call__(
|
|
22
|
+
self,
|
|
23
|
+
scope: str,
|
|
24
|
+
rate: str,
|
|
25
|
+
tiers: Mapping[str, str] | None = None,
|
|
26
|
+
) -> Callable[[Decorated], Decorated]:
|
|
27
|
+
"""Return a declaration decorator for the scope, rate, and tier overrides."""
|
|
28
|
+
policy = ThrottlePolicy(
|
|
29
|
+
scope=scope,
|
|
30
|
+
rate=RateLimit.from_rate(rate),
|
|
31
|
+
tier_rates=self._tier_rates(tiers),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def declare(func: Decorated) -> Decorated:
|
|
35
|
+
setattr(func, const.THROTTLE_POLICY_ATTR, policy)
|
|
36
|
+
return func
|
|
37
|
+
|
|
38
|
+
return declare
|
|
39
|
+
|
|
40
|
+
@staticmethod
|
|
41
|
+
def _tier_rates(tiers: Mapping[str, str] | None) -> tuple[TierRate, ...]:
|
|
42
|
+
"""Build tier overrides from a tier-to-rate mapping."""
|
|
43
|
+
if not tiers:
|
|
44
|
+
return ()
|
|
45
|
+
return tuple(
|
|
46
|
+
TierRate(tier=tier, rate=RateLimit.from_rate(rate))
|
|
47
|
+
for tier, rate in tiers.items()
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
throttled = Throttled()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Rate-limit error hierarchy."""
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Typed rate-limit error hierarchy for declaration and enforcement mapping."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from domain_errors import DomainError
|
|
6
|
+
|
|
7
|
+
from domain_api_limiter.errors.constants import api_limiter_errors as const
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ThrottleError(DomainError):
|
|
11
|
+
"""Base error for all rate-limit domain failures."""
|
|
12
|
+
|
|
13
|
+
domain = "api_limiter"
|
|
14
|
+
code = "throttle_error"
|
|
15
|
+
http_status = 429
|
|
16
|
+
retryable = True
|
|
17
|
+
default_message = const.ERR_API_LIMITER_CONSTRAINT_VIOLATED
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RateLimitExceeded(ThrottleError):
|
|
21
|
+
"""Request rejected because a rate limit was exceeded."""
|
|
22
|
+
|
|
23
|
+
code = "rate_limit_exceeded"
|
|
24
|
+
default_message = const.ERR_API_LIMITER_RATE_EXCEEDED
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ThrottleDeclarationError(ThrottleError):
|
|
28
|
+
"""Invalid throttle declaration detected at import time."""
|
|
29
|
+
|
|
30
|
+
code = "throttle_declaration_invalid"
|
|
31
|
+
http_status = 500
|
|
32
|
+
retryable = False
|
|
33
|
+
default_message = const.ERR_API_LIMITER_DECLARATION_INVALID
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Error constants for the rate-limit domain."""
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Rate-limit error messages. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Error messages raised at the API surface (source-side; tests match against these via const.ERR_*)."""
|
|
8
|
+
|
|
9
|
+
ERR_API_LIMITER_CONSTRAINT_VIOLATED: Final = "Rate limit constraint violated."
|
|
10
|
+
ERR_API_LIMITER_RATE_EXCEEDED: Final = "Rate limit exceeded."
|
|
11
|
+
ERR_API_LIMITER_DECLARATION_INVALID: Final = "Invalid throttle declaration."
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Rate-limit policy services."""
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Throttle policy constants. Imported as const."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
"""Declaration attribute key attached by the throttled decorator and read by the registry."""
|
|
8
|
+
|
|
9
|
+
THROTTLE_POLICY_ATTR: Final = "__throttle_policy__"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
"""Error messages raised during policy declaration (source-side; tests match against these via const.ERR_*)."""
|
|
13
|
+
|
|
14
|
+
ERR_POLICY_REQUESTS_NOT_POSITIVE: Final = "rate requests must be positive"
|
|
15
|
+
ERR_POLICY_RATE_FORMAT: Final = "rate must use the N/period form"
|
|
16
|
+
ERR_POLICY_UNKNOWN_PERIOD: Final = "unknown rate period"
|
|
17
|
+
ERR_POLICY_EMPTY_TIER: Final = "tier label must be non-empty"
|
|
18
|
+
ERR_POLICY_EMPTY_SCOPE: Final = "scope must be non-empty"
|
|
19
|
+
ERR_POLICY_DUPLICATE_TIERS: Final = "tier labels must be unique"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
"""Period length in seconds for throttle-rate calculations."""
|
|
23
|
+
|
|
24
|
+
SECONDS_PER_SECOND: Final = 1
|
|
25
|
+
SECONDS_PER_MINUTE: Final = 60
|
|
26
|
+
SECONDS_PER_HOUR: Final = 3600
|
|
27
|
+
SECONDS_PER_DAY: Final = 86400
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Throttle policy: value objects and the declaration introspection registry."""
|
|
2
|
+
|
|
3
|
+
from domain_api_limiter.services.policy.policy_client import PolicyRegistry
|
|
4
|
+
from domain_api_limiter.services.policy.policy_objects import (
|
|
5
|
+
Period,
|
|
6
|
+
RateLimit,
|
|
7
|
+
ThrottlePolicy,
|
|
8
|
+
TierRate,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = ["Period", "PolicyRegistry", "RateLimit", "ThrottlePolicy", "TierRate"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Declaration introspection: read and collect attached throttle policies."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from types import ModuleType
|
|
7
|
+
|
|
8
|
+
from domain_api_limiter.services.constants import policy as const
|
|
9
|
+
from domain_api_limiter.services.policy import policy_objects as objs
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PolicyRegistry:
|
|
13
|
+
"""Read and collect throttle declarations attached by the throttled decorator."""
|
|
14
|
+
|
|
15
|
+
def policy_of(self, target: Callable[..., object]) -> objs.ThrottlePolicy | None:
|
|
16
|
+
"""Return the policy declared on the target, or None."""
|
|
17
|
+
policy = getattr(target, const.THROTTLE_POLICY_ATTR, None)
|
|
18
|
+
return policy if isinstance(policy, objs.ThrottlePolicy) else None
|
|
19
|
+
|
|
20
|
+
def collect(self, container: type | ModuleType) -> tuple[objs.ThrottlePolicy, ...]:
|
|
21
|
+
"""Return the policies declared on a class or module's members, in definition order."""
|
|
22
|
+
policies = []
|
|
23
|
+
for member in vars(container).values():
|
|
24
|
+
if callable(member):
|
|
25
|
+
policy = self.policy_of(member)
|
|
26
|
+
if policy is not None:
|
|
27
|
+
policies.append(policy)
|
|
28
|
+
return tuple(policies)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Throttle policy value objects: periods, rates, tier overrides, and the policy payload."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import StrEnum
|
|
7
|
+
from typing import Self
|
|
8
|
+
|
|
9
|
+
from domain_api_limiter.errors.api_limiter_errors import ThrottleDeclarationError
|
|
10
|
+
from domain_api_limiter.services.constants import policy as const
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Period(StrEnum):
|
|
14
|
+
"""Rate period vocabulary, mirroring framework rate strings."""
|
|
15
|
+
|
|
16
|
+
SECOND = "second"
|
|
17
|
+
MINUTE = "minute"
|
|
18
|
+
HOUR = "hour"
|
|
19
|
+
DAY = "day"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True, slots=True)
|
|
23
|
+
class RateLimit:
|
|
24
|
+
"""Parsed rate: allowed request count per period."""
|
|
25
|
+
|
|
26
|
+
requests: int
|
|
27
|
+
period: Period
|
|
28
|
+
|
|
29
|
+
def __post_init__(self) -> None:
|
|
30
|
+
"""Reject non-positive request counts."""
|
|
31
|
+
if self.requests <= 0:
|
|
32
|
+
raise ThrottleDeclarationError(
|
|
33
|
+
message=const.ERR_POLICY_REQUESTS_NOT_POSITIVE,
|
|
34
|
+
requests=self.requests,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def from_rate(cls, rate: str) -> Self:
|
|
39
|
+
"""Parse an N/period rate string into a RateLimit."""
|
|
40
|
+
head, separator, tail = rate.partition("/")
|
|
41
|
+
if not separator or not head.isdigit():
|
|
42
|
+
raise ThrottleDeclarationError(
|
|
43
|
+
message=const.ERR_POLICY_RATE_FORMAT,
|
|
44
|
+
rate=rate,
|
|
45
|
+
)
|
|
46
|
+
try:
|
|
47
|
+
period = Period(tail)
|
|
48
|
+
except ValueError as error:
|
|
49
|
+
raise ThrottleDeclarationError(
|
|
50
|
+
message=const.ERR_POLICY_UNKNOWN_PERIOD,
|
|
51
|
+
rate=rate,
|
|
52
|
+
period=tail,
|
|
53
|
+
) from error
|
|
54
|
+
return cls(requests=int(head), period=period)
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def period_seconds(self) -> int:
|
|
58
|
+
"""Return the period length in seconds."""
|
|
59
|
+
match self.period:
|
|
60
|
+
case Period.SECOND:
|
|
61
|
+
return const.SECONDS_PER_SECOND
|
|
62
|
+
case Period.MINUTE:
|
|
63
|
+
return const.SECONDS_PER_MINUTE
|
|
64
|
+
case Period.HOUR:
|
|
65
|
+
return const.SECONDS_PER_HOUR
|
|
66
|
+
case Period.DAY:
|
|
67
|
+
return const.SECONDS_PER_DAY
|
|
68
|
+
|
|
69
|
+
def as_rate(self) -> str:
|
|
70
|
+
"""Serialize back to the N/period form."""
|
|
71
|
+
return f"{self.requests}/{self.period.value}"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@dataclass(frozen=True, slots=True)
|
|
75
|
+
class TierRate:
|
|
76
|
+
"""Per-tier rate override keyed by a consumer-defined tier label."""
|
|
77
|
+
|
|
78
|
+
tier: str
|
|
79
|
+
rate: RateLimit
|
|
80
|
+
|
|
81
|
+
def __post_init__(self) -> None:
|
|
82
|
+
"""Reject empty tier labels."""
|
|
83
|
+
if not self.tier:
|
|
84
|
+
raise ThrottleDeclarationError(message=const.ERR_POLICY_EMPTY_TIER)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass(frozen=True, slots=True)
|
|
88
|
+
class ThrottlePolicy:
|
|
89
|
+
"""Complete throttle declaration: scope, base rate, and tier overrides."""
|
|
90
|
+
|
|
91
|
+
scope: str
|
|
92
|
+
rate: RateLimit
|
|
93
|
+
tier_rates: tuple[TierRate, ...] = ()
|
|
94
|
+
|
|
95
|
+
def __post_init__(self) -> None:
|
|
96
|
+
"""Reject empty scopes and duplicate tier labels."""
|
|
97
|
+
if not self.scope:
|
|
98
|
+
raise ThrottleDeclarationError(message=const.ERR_POLICY_EMPTY_SCOPE)
|
|
99
|
+
tiers = [tier_rate.tier for tier_rate in self.tier_rates]
|
|
100
|
+
if len(tiers) != len(set(tiers)):
|
|
101
|
+
raise ThrottleDeclarationError(
|
|
102
|
+
message=const.ERR_POLICY_DUPLICATE_TIERS,
|
|
103
|
+
scope=self.scope,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def has_tiers(self) -> bool:
|
|
108
|
+
"""Return True when tier overrides are declared."""
|
|
109
|
+
return bool(self.tier_rates)
|
|
110
|
+
|
|
111
|
+
def rate_for(self, tier: str) -> RateLimit:
|
|
112
|
+
"""Return the tier override when declared, otherwise the base rate."""
|
|
113
|
+
for tier_rate in self.tier_rates:
|
|
114
|
+
if tier_rate.tier == tier:
|
|
115
|
+
return tier_rate.rate
|
|
116
|
+
return self.rate
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: domain-api-limiter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rate-limit declaration toolkit: throttle policies, tier rates, and declaration decorators for Python services
|
|
5
|
+
Project-URL: Homepage, https://pypi.org/project/domain-api-limiter/
|
|
6
|
+
Project-URL: Repository, https://github.com/jekhator/domain-api-limiter
|
|
7
|
+
Project-URL: Issues, https://github.com/jekhator/domain-api-limiter/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/jekhator/domain-api-limiter/blob/main/CHANGELOG.md
|
|
9
|
+
Author: James Ekhator
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,declaration,policy,rate-limit,throttle
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: domain-errors>=0.1.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# domain-api-limiter
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/domain-api-limiter/)
|
|
27
|
+
[](https://github.com/jekhator/domain-api-limiter/actions)
|
|
28
|
+
[](LICENSE)
|
|
29
|
+
[](https://www.python.org/downloads/)
|
|
30
|
+
|
|
31
|
+
Declarative rate-limit policy toolkit for Python services. Attach throttle policies to methods, parse rates, define tier overrides, and collect policies for consumption by framework-level throttling adapters.
|
|
32
|
+
|
|
33
|
+
## Why domain-api-limiter?
|
|
34
|
+
|
|
35
|
+
Rate-limiting policies are declarations: they define *what* throttle rules apply to a service method, but they never enforce the limit themselves. Enforcement belongs in the consuming framework's vetted throttling logic (Django REST Framework throttles, Starlette middleware, etc.). domain-api-limiter keeps the declaration layer simple, immutable, and composable. Policies are frozen dataclasses, validated at import time so malformed rates fail fast. The `@throttled` decorator attaches policy metadata to any method without changing its signature. PolicyRegistry collects declared policies from a service class or module, returning them in definition order so an adapter can build the framework's real throttle classes. Tier overrides let you apply different rate limits by customer plan (free/pro/enterprise) without duplicating policy declarations.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install domain-api-limiter
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or with uv:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv add domain-api-limiter
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires Python 3.11+. Depends on domain-errors >= 0.1.0.
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Declare throttle policies with @throttled
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from domain_api_limiter import throttled
|
|
57
|
+
|
|
58
|
+
class DocumentService:
|
|
59
|
+
@throttled("docs:list", "100/hour", tiers={"free": "10/day", "pro": "1000/hour"})
|
|
60
|
+
def list_documents(self, tenant_id: str) -> list:
|
|
61
|
+
"""List all documents for a tenant."""
|
|
62
|
+
return []
|
|
63
|
+
|
|
64
|
+
@throttled("docs:upload", "20/minute")
|
|
65
|
+
def upload(self, tenant_id: str) -> None:
|
|
66
|
+
"""Upload a document."""
|
|
67
|
+
pass
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The decorator validates the rate and tier strings at decoration time and attaches a ThrottlePolicy to the method without changing its behavior.
|
|
71
|
+
|
|
72
|
+
### 2. Collect policies for your adapter
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from domain_api_limiter import PolicyRegistry
|
|
76
|
+
|
|
77
|
+
registry = PolicyRegistry()
|
|
78
|
+
policies = registry.collect(DocumentService)
|
|
79
|
+
print(f"Collected {len(policies)} policies:")
|
|
80
|
+
# Output: Collected 2 policies:
|
|
81
|
+
# docs:list: 100/hour (tiers: free=10/day, pro=1000/hour)
|
|
82
|
+
# docs:upload: 20/minute
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Your adapter then walks the policies and builds the framework's real throttle classes (DRF throttles, middleware, etc.).
|
|
86
|
+
|
|
87
|
+
### 3. Parse rates and inspect tier overrides
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from domain_api_limiter import RateLimit, Period
|
|
91
|
+
|
|
92
|
+
# Parse rate strings
|
|
93
|
+
rate = RateLimit.from_rate("100/hour")
|
|
94
|
+
print(rate.requests) # 100
|
|
95
|
+
print(rate.period) # Period.HOUR
|
|
96
|
+
print(rate.period_seconds) # 3600
|
|
97
|
+
print(rate.as_rate()) # "100/hour"
|
|
98
|
+
|
|
99
|
+
# Create rates directly
|
|
100
|
+
rate = RateLimit(requests=50, period=Period.MINUTE)
|
|
101
|
+
|
|
102
|
+
# Inspect tier overrides on a collected policy
|
|
103
|
+
policy = policies[0]
|
|
104
|
+
if policy.has_tiers:
|
|
105
|
+
free_rate = policy.rate_for("free") # Returns RateLimit for "free" tier
|
|
106
|
+
pro_rate = policy.rate_for("pro") # Returns RateLimit for "pro" tier
|
|
107
|
+
default_rate = policy.rate_for("unknown") # Returns the base rate
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 4. Handle declaration errors
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from domain_api_limiter import ThrottleDeclarationError
|
|
114
|
+
|
|
115
|
+
# Errors are raised at decoration time, not at runtime.
|
|
116
|
+
try:
|
|
117
|
+
@throttled("scope", "invalid") # Malformed rate
|
|
118
|
+
def bad_method():
|
|
119
|
+
pass
|
|
120
|
+
except ThrottleDeclarationError as e:
|
|
121
|
+
print(f"Invalid policy: {e.message}")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Service Class Example
|
|
125
|
+
|
|
126
|
+
A typical service class with throttled methods:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from domain_api_limiter import throttled, PolicyRegistry
|
|
130
|
+
|
|
131
|
+
class DocumentService:
|
|
132
|
+
@throttled("docs:list", "100/hour", tiers={"free": "10/day", "pro": "1000/hour"})
|
|
133
|
+
def list_documents(self, tenant_id: str) -> list:
|
|
134
|
+
"""List all documents for a tenant."""
|
|
135
|
+
return []
|
|
136
|
+
|
|
137
|
+
@throttled("docs:upload", "20/minute")
|
|
138
|
+
def upload(self, tenant_id: str) -> None:
|
|
139
|
+
"""Upload a document."""
|
|
140
|
+
pass
|
|
141
|
+
|
|
142
|
+
# An adapter collects policies and builds throttle classes
|
|
143
|
+
registry = PolicyRegistry()
|
|
144
|
+
policies = registry.collect(DocumentService)
|
|
145
|
+
|
|
146
|
+
for policy in policies:
|
|
147
|
+
print(f"Scope: {policy.scope}")
|
|
148
|
+
print(f"Base rate: {policy.rate.as_rate()}")
|
|
149
|
+
if policy.has_tiers:
|
|
150
|
+
for tier_rate in policy.tier_rates:
|
|
151
|
+
print(f" {tier_rate.tier}: {tier_rate.rate.as_rate()}")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Output:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
Scope: docs:list
|
|
158
|
+
Base rate: 100/hour
|
|
159
|
+
free: 10/day
|
|
160
|
+
pro: 1000/hour
|
|
161
|
+
Scope: docs:upload
|
|
162
|
+
Base rate: 20/minute
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Public API
|
|
166
|
+
|
|
167
|
+
### Throttle Declaration
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from domain_api_limiter import throttled, ThrottlePolicy, RateLimit, TierRate, Period
|
|
171
|
+
|
|
172
|
+
# Decorator: attach a policy to a method
|
|
173
|
+
@throttled(scope: str, rate: str, tiers: dict[str, str] | None = None)
|
|
174
|
+
def my_method() -> None:
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
# Value objects (immutable, validated at creation)
|
|
178
|
+
policy = ThrottlePolicy(
|
|
179
|
+
scope: str, # Policy identifier (e.g., "docs:list")
|
|
180
|
+
rate: RateLimit, # Base rate for all tiers
|
|
181
|
+
tier_rates: tuple[TierRate, ...] # Per-tier rate overrides (default: ())
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
rate = RateLimit(
|
|
185
|
+
requests: int, # Positive count of allowed requests
|
|
186
|
+
period: Period # Period enum: SECOND, MINUTE, HOUR, DAY
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
tier_rate = TierRate(
|
|
190
|
+
tier: str, # Non-empty tier label (e.g., "free", "pro")
|
|
191
|
+
rate: RateLimit # Rate override for this tier
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Period enumeration
|
|
195
|
+
from domain_api_limiter import Period
|
|
196
|
+
period = Period.HOUR # or SECOND, MINUTE, DAY
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Policy Registry
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from domain_api_limiter import PolicyRegistry
|
|
203
|
+
|
|
204
|
+
registry = PolicyRegistry()
|
|
205
|
+
|
|
206
|
+
# Retrieve the policy from a single callable
|
|
207
|
+
policy = registry.policy_of(my_method) # Returns ThrottlePolicy | None
|
|
208
|
+
|
|
209
|
+
# Collect all policies from a class or module
|
|
210
|
+
policies = registry.collect(DocumentService) # Returns tuple[ThrottlePolicy, ...]
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Error Types
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from domain_api_limiter import ThrottleError, RateLimitExceeded, ThrottleDeclarationError
|
|
217
|
+
|
|
218
|
+
# Base error for all rate-limit domain failures
|
|
219
|
+
# domain="api_limiter", code="throttle_error", http_status=429, retryable=True
|
|
220
|
+
class ThrottleError(DomainError):
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
# Request rejected because a rate limit was exceeded
|
|
224
|
+
# code="rate_limit_exceeded", http_status=429, retryable=True
|
|
225
|
+
class RateLimitExceeded(ThrottleError):
|
|
226
|
+
pass
|
|
227
|
+
|
|
228
|
+
# Invalid throttle declaration detected at import time
|
|
229
|
+
# code="throttle_declaration_invalid", http_status=500, retryable=False
|
|
230
|
+
class ThrottleDeclarationError(ThrottleError):
|
|
231
|
+
pass
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
All errors inherit from `domain-errors` DomainError and integrate with structured logging and error tracking systems.
|
|
235
|
+
|
|
236
|
+
## Documentation
|
|
237
|
+
|
|
238
|
+
For detailed documentation on each feature, see:
|
|
239
|
+
|
|
240
|
+
- [Throttle Policy Objects](docs/apps/policy.md)
|
|
241
|
+
- [@throttled Decorator](docs/apps/throttled.md)
|
|
242
|
+
- [Error Types and Semantics](docs/apps/api_limiter_errors.md)
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
|
|
247
|
+
|
|
248
|
+
## Contributing
|
|
249
|
+
|
|
250
|
+
This library is maintained by [James Ekhator](https://github.com/jekhator). Contributions welcome via pull requests. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
domain_api_limiter/__init__.py,sha256=4b6Mbr3ciFp-X_GatJGGghVnZlk_kmhqqnJy-BgdChE,792
|
|
2
|
+
domain_api_limiter/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
domain_api_limiter/config/__init__.py,sha256=GIjb9cYcaJ1Q9vRzF7_daH_S5KLOeg_oLGfPIhmn7A0,29
|
|
4
|
+
domain_api_limiter/config/_version.py,sha256=GtsljaQReBaQusaK0Zmip2AM7BWtdesXvaMQz35Aiic,60
|
|
5
|
+
domain_api_limiter/decorators/__init__.py,sha256=hOPP2ibHErHtYyNY2jn-zTF4CRjHBZ_bS2yFdzgVwlk,41
|
|
6
|
+
domain_api_limiter/decorators/throttled/__init__.py,sha256=kyWIy5FN9JdVavJAwQJP2Kn3uMwR3mD5B9SkjYlF24k,182
|
|
7
|
+
domain_api_limiter/decorators/throttled/throttled_client.py,sha256=jcUP60RfbH0KiyQQykk3GEJkIJxYtklCQr_PTcSUQJc,1468
|
|
8
|
+
domain_api_limiter/errors/__init__.py,sha256=4l2nJXBePj9yyLylAK7qPrMb67IwB6TB_GSjn3yw28k,34
|
|
9
|
+
domain_api_limiter/errors/api_limiter_errors.py,sha256=JTefbJ13kxPMZA8xmTZl5zbiWexFsL7XFt7GDYwRtww,948
|
|
10
|
+
domain_api_limiter/errors/constants/__init__.py,sha256=mn0SJDpVtAWVDoS5CIkJLaLIa_CeeDykPedh_mLEdM0,49
|
|
11
|
+
domain_api_limiter/errors/constants/api_limiter_errors.py,sha256=L0Vue-pd2rKwfjmmvreGz9M80sQ0eqb9v0RAbCmF8TU,439
|
|
12
|
+
domain_api_limiter/services/__init__.py,sha256=y4ZGd_JhLodFyhF0EqLs2LUghDROhgmaeI70pORIKtQ,34
|
|
13
|
+
domain_api_limiter/services/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
domain_api_limiter/services/constants/policy.py,sha256=nPdaRszLbpHIzVhtfpcTc-wOX4bdDw4BBhR9UFZNBUg,949
|
|
15
|
+
domain_api_limiter/services/policy/__init__.py,sha256=0aRCQBvdIT0cikDnS-c0GUuuOrjA66-1oGD6UnKjBJs,368
|
|
16
|
+
domain_api_limiter/services/policy/policy_client.py,sha256=ewyDKRqOAjNuei1TqMaB2YbH17AocGFSBbPQoQbio4s,1172
|
|
17
|
+
domain_api_limiter/services/policy/policy_objects.py,sha256=ZQLMpnUP5cvfwaLnQ04X4O2HMT-FUIukAwx_9c98oeo,3667
|
|
18
|
+
domain_api_limiter-0.1.0.dist-info/METADATA,sha256=B4KhoP1OFLpeDy1czzSuLCVI_6BJlJPj8ZKpJPVVngM,8609
|
|
19
|
+
domain_api_limiter-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
20
|
+
domain_api_limiter-0.1.0.dist-info/licenses/LICENSE,sha256=afJnNvtqk-WIQDM8aNaqfuYQifp27Wa0Q5j5P_Aj_gQ,11343
|
|
21
|
+
domain_api_limiter-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 James Ekhator
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|