switchly 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.
- switchly/__init__.py +169 -0
- switchly/admin/__init__.py +11 -0
- switchly/admin/api.py +1190 -0
- switchly/admin/app.py +598 -0
- switchly/admin/auth.py +259 -0
- switchly/cli/__init__.py +0 -0
- switchly/cli/client.py +567 -0
- switchly/cli/config.py +253 -0
- switchly/cli/main.py +2608 -0
- switchly/core/__init__.py +0 -0
- switchly/core/backends/__init__.py +0 -0
- switchly/core/backends/base.py +413 -0
- switchly/core/backends/file.py +425 -0
- switchly/core/backends/memory.py +183 -0
- switchly/core/backends/redis.py +472 -0
- switchly/core/backends/server.py +794 -0
- switchly/core/config.py +281 -0
- switchly/core/engine.py +2497 -0
- switchly/core/exceptions.py +145 -0
- switchly/core/feature_flags/__init__.py +153 -0
- switchly/core/feature_flags/_context.py +65 -0
- switchly/core/feature_flags/_guard.py +26 -0
- switchly/core/feature_flags/client.py +171 -0
- switchly/core/feature_flags/evaluator.py +443 -0
- switchly/core/feature_flags/hooks.py +168 -0
- switchly/core/feature_flags/models.py +590 -0
- switchly/core/feature_flags/provider.py +199 -0
- switchly/core/feature_flags/scheduler.py +233 -0
- switchly/core/models.py +100 -0
- switchly/core/rate_limit/__init__.py +11 -0
- switchly/core/rate_limit/keys.py +229 -0
- switchly/core/rate_limit/limiter.py +250 -0
- switchly/core/rate_limit/models.py +324 -0
- switchly/core/rate_limit/storage.py +689 -0
- switchly/core/scheduler.py +225 -0
- switchly/core/webhooks.py +60 -0
- switchly/dashboard/__init__.py +5 -0
- switchly/dashboard/app.py +151 -0
- switchly/dashboard/auth.py +61 -0
- switchly/dashboard/routes.py +2161 -0
- switchly/dashboard/static/switchly.min.css +2 -0
- switchly/dashboard/templates/audit.html +90 -0
- switchly/dashboard/templates/base.html +689 -0
- switchly/dashboard/templates/flag_detail.html +773 -0
- switchly/dashboard/templates/flags.html +136 -0
- switchly/dashboard/templates/index.html +142 -0
- switchly/dashboard/templates/login.html +107 -0
- switchly/dashboard/templates/partials/audit_row.html +107 -0
- switchly/dashboard/templates/partials/audit_rows.html +3 -0
- switchly/dashboard/templates/partials/flag_eval_result.html +137 -0
- switchly/dashboard/templates/partials/flag_row.html +131 -0
- switchly/dashboard/templates/partials/flag_rows.html +34 -0
- switchly/dashboard/templates/partials/global_maintenance.html +79 -0
- switchly/dashboard/templates/partials/global_rl_card.html +133 -0
- switchly/dashboard/templates/partials/modal.html +115 -0
- switchly/dashboard/templates/partials/modal_env_gate.html +71 -0
- switchly/dashboard/templates/partials/modal_flag_create.html +105 -0
- switchly/dashboard/templates/partials/modal_flag_eval.html +112 -0
- switchly/dashboard/templates/partials/modal_global_disable.html +51 -0
- switchly/dashboard/templates/partials/modal_global_enable.html +114 -0
- switchly/dashboard/templates/partials/modal_global_rl.html +129 -0
- switchly/dashboard/templates/partials/modal_global_rl_delete.html +39 -0
- switchly/dashboard/templates/partials/modal_global_rl_reset.html +39 -0
- switchly/dashboard/templates/partials/modal_rl_add.html +120 -0
- switchly/dashboard/templates/partials/modal_rl_delete.html +56 -0
- switchly/dashboard/templates/partials/modal_rl_edit.html +109 -0
- switchly/dashboard/templates/partials/modal_rl_reset.html +45 -0
- switchly/dashboard/templates/partials/modal_segment_create.html +86 -0
- switchly/dashboard/templates/partials/modal_segment_detail.html +118 -0
- switchly/dashboard/templates/partials/modal_segment_view.html +151 -0
- switchly/dashboard/templates/partials/modal_service_disable.html +51 -0
- switchly/dashboard/templates/partials/modal_service_enable.html +95 -0
- switchly/dashboard/templates/partials/modal_service_rl.html +131 -0
- switchly/dashboard/templates/partials/modal_service_rl_delete.html +41 -0
- switchly/dashboard/templates/partials/modal_service_rl_reset.html +41 -0
- switchly/dashboard/templates/partials/pagination.html +63 -0
- switchly/dashboard/templates/partials/rate_limit_hits.html +16 -0
- switchly/dashboard/templates/partials/rate_limit_rows.html +61 -0
- switchly/dashboard/templates/partials/route_row.html +179 -0
- switchly/dashboard/templates/partials/routes_table.html +4 -0
- switchly/dashboard/templates/partials/segment_row.html +96 -0
- switchly/dashboard/templates/partials/segment_rows.html +34 -0
- switchly/dashboard/templates/partials/segment_rules_section.html +172 -0
- switchly/dashboard/templates/partials/service_maintenance.html +75 -0
- switchly/dashboard/templates/partials/service_rl_card.html +135 -0
- switchly/dashboard/templates/rate_limits.html +166 -0
- switchly/dashboard/templates/rl_hits.html +50 -0
- switchly/dashboard/templates/segments.html +112 -0
- switchly/fastapi/__init__.py +51 -0
- switchly/fastapi/decorators.py +762 -0
- switchly/fastapi/dependencies.py +123 -0
- switchly/fastapi/middleware.py +506 -0
- switchly/fastapi/openapi.py +633 -0
- switchly/fastapi/router.py +250 -0
- switchly/sdk/__init__.py +254 -0
- switchly/sdk/flag_provider.py +176 -0
- switchly/server/__init__.py +115 -0
- switchly-0.1.0.dist-info/METADATA +427 -0
- switchly-0.1.0.dist-info/RECORD +102 -0
- switchly-0.1.0.dist-info/WHEEL +4 -0
- switchly-0.1.0.dist-info/entry_points.txt +2 -0
- switchly-0.1.0.dist-info/licenses/LICENSE +21 -0
switchly/__init__.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""switchly — route lifecycle management for Python APIs.
|
|
2
|
+
|
|
3
|
+
All public symbols are available directly from this package::
|
|
4
|
+
|
|
5
|
+
from switchly import (
|
|
6
|
+
SwitchlyEngine,
|
|
7
|
+
make_engine,
|
|
8
|
+
MemoryBackend,
|
|
9
|
+
FileBackend,
|
|
10
|
+
RouteState,
|
|
11
|
+
AuditEntry,
|
|
12
|
+
MaintenanceWindow,
|
|
13
|
+
RateLimitPolicy,
|
|
14
|
+
SwitchlyException,
|
|
15
|
+
SlackWebhookFormatter,
|
|
16
|
+
default_formatter,
|
|
17
|
+
# feature flag models (requires switchly[flags])
|
|
18
|
+
FeatureFlag,
|
|
19
|
+
EvaluationContext,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
Framework adapters live in their own namespaces::
|
|
23
|
+
|
|
24
|
+
from switchly.fastapi import SwitchlyAdmin, SwitchlyMiddleware, SwitchlyRouter, ...
|
|
25
|
+
from switchly.sdk import SwitchlySDK
|
|
26
|
+
from switchly.server import SwitchlyServer
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
# ---------------------------------------------------------------------------
|
|
30
|
+
# Engine & config
|
|
31
|
+
# ---------------------------------------------------------------------------
|
|
32
|
+
# ---------------------------------------------------------------------------
|
|
33
|
+
# Backends
|
|
34
|
+
# ---------------------------------------------------------------------------
|
|
35
|
+
from switchly.core.backends.base import SwitchlyBackend
|
|
36
|
+
from switchly.core.backends.file import FileBackend
|
|
37
|
+
from switchly.core.backends.memory import MemoryBackend
|
|
38
|
+
from switchly.core.config import make_backend, make_engine
|
|
39
|
+
from switchly.core.engine import SwitchlyEngine
|
|
40
|
+
|
|
41
|
+
# ---------------------------------------------------------------------------
|
|
42
|
+
# Exceptions
|
|
43
|
+
# ---------------------------------------------------------------------------
|
|
44
|
+
from switchly.core.exceptions import (
|
|
45
|
+
AmbiguousRouteError,
|
|
46
|
+
EnvGatedException,
|
|
47
|
+
MaintenanceException,
|
|
48
|
+
RateLimitExceededException,
|
|
49
|
+
RouteDisabledException,
|
|
50
|
+
RouteNotFoundException,
|
|
51
|
+
RouteProtectedException,
|
|
52
|
+
SwitchlyException,
|
|
53
|
+
SwitchlyProductionWarning,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# ---------------------------------------------------------------------------
|
|
57
|
+
# Feature flag models (pure Pydantic — safe without the [flags] extra)
|
|
58
|
+
# ---------------------------------------------------------------------------
|
|
59
|
+
from switchly.core.feature_flags.evaluator import FlagEvaluator
|
|
60
|
+
from switchly.core.feature_flags.models import (
|
|
61
|
+
EvaluationContext,
|
|
62
|
+
EvaluationReason,
|
|
63
|
+
FeatureFlag,
|
|
64
|
+
FlagStatus,
|
|
65
|
+
FlagType,
|
|
66
|
+
FlagVariation,
|
|
67
|
+
Operator,
|
|
68
|
+
Prerequisite,
|
|
69
|
+
ResolutionDetails,
|
|
70
|
+
RolloutVariation,
|
|
71
|
+
RuleClause,
|
|
72
|
+
Segment,
|
|
73
|
+
SegmentRule,
|
|
74
|
+
TargetingRule,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# ---------------------------------------------------------------------------
|
|
78
|
+
# Models
|
|
79
|
+
# ---------------------------------------------------------------------------
|
|
80
|
+
from switchly.core.models import (
|
|
81
|
+
AuditEntry,
|
|
82
|
+
GlobalMaintenanceConfig,
|
|
83
|
+
MaintenanceWindow,
|
|
84
|
+
RouteState,
|
|
85
|
+
RouteStatus,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# ---------------------------------------------------------------------------
|
|
89
|
+
# Rate limiting models
|
|
90
|
+
# ---------------------------------------------------------------------------
|
|
91
|
+
from switchly.core.rate_limit.models import (
|
|
92
|
+
GlobalRateLimitPolicy,
|
|
93
|
+
OnMissingKey,
|
|
94
|
+
RateLimitAlgorithm,
|
|
95
|
+
RateLimitHit,
|
|
96
|
+
RateLimitKeyStrategy,
|
|
97
|
+
RateLimitPolicy,
|
|
98
|
+
RateLimitResult,
|
|
99
|
+
RateLimitTier,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# ---------------------------------------------------------------------------
|
|
103
|
+
# Webhooks
|
|
104
|
+
# ---------------------------------------------------------------------------
|
|
105
|
+
from switchly.core.webhooks import SlackWebhookFormatter, default_formatter
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------------
|
|
108
|
+
# RedisBackend — available only when the [redis] extra is installed
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
try:
|
|
111
|
+
from switchly.core.backends.redis import RedisBackend
|
|
112
|
+
except ImportError:
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
__all__ = [
|
|
116
|
+
# Engine & config
|
|
117
|
+
"SwitchlyEngine",
|
|
118
|
+
"make_engine",
|
|
119
|
+
"make_backend",
|
|
120
|
+
# Backends
|
|
121
|
+
"SwitchlyBackend",
|
|
122
|
+
"MemoryBackend",
|
|
123
|
+
"FileBackend",
|
|
124
|
+
"RedisBackend",
|
|
125
|
+
# Models
|
|
126
|
+
"RouteStatus",
|
|
127
|
+
"RouteState",
|
|
128
|
+
"AuditEntry",
|
|
129
|
+
"MaintenanceWindow",
|
|
130
|
+
"GlobalMaintenanceConfig",
|
|
131
|
+
# Exceptions
|
|
132
|
+
"SwitchlyException",
|
|
133
|
+
"MaintenanceException",
|
|
134
|
+
"EnvGatedException",
|
|
135
|
+
"RouteDisabledException",
|
|
136
|
+
"RouteNotFoundException",
|
|
137
|
+
"AmbiguousRouteError",
|
|
138
|
+
"RouteProtectedException",
|
|
139
|
+
"RateLimitExceededException",
|
|
140
|
+
"SwitchlyProductionWarning",
|
|
141
|
+
# Webhooks
|
|
142
|
+
"default_formatter",
|
|
143
|
+
"SlackWebhookFormatter",
|
|
144
|
+
# Rate limiting
|
|
145
|
+
"RateLimitAlgorithm",
|
|
146
|
+
"OnMissingKey",
|
|
147
|
+
"RateLimitKeyStrategy",
|
|
148
|
+
"RateLimitTier",
|
|
149
|
+
"RateLimitPolicy",
|
|
150
|
+
"RateLimitResult",
|
|
151
|
+
"GlobalRateLimitPolicy",
|
|
152
|
+
"RateLimitHit",
|
|
153
|
+
# Feature flags
|
|
154
|
+
"FlagEvaluator",
|
|
155
|
+
"EvaluationContext",
|
|
156
|
+
"EvaluationReason",
|
|
157
|
+
"FeatureFlag",
|
|
158
|
+
"FlagStatus",
|
|
159
|
+
"FlagType",
|
|
160
|
+
"FlagVariation",
|
|
161
|
+
"Operator",
|
|
162
|
+
"Prerequisite",
|
|
163
|
+
"ResolutionDetails",
|
|
164
|
+
"RolloutVariation",
|
|
165
|
+
"RuleClause",
|
|
166
|
+
"Segment",
|
|
167
|
+
"SegmentRule",
|
|
168
|
+
"TargetingRule",
|
|
169
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Switchly Admin — unified admin interface for switchly.
|
|
2
|
+
|
|
3
|
+
Exposes both the HTMX dashboard UI *and* a REST API that the ``switchly`` CLI
|
|
4
|
+
uses as its HTTP back-end. Mount a single :func:`SwitchlyAdmin` instance on
|
|
5
|
+
your FastAPI / Starlette application and both interfaces are available
|
|
6
|
+
immediately.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from switchly.admin.app import SwitchlyAdmin
|
|
10
|
+
|
|
11
|
+
__all__ = ["SwitchlyAdmin"]
|