hfortix-core 0.5.88__tar.gz

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.
Files changed (40) hide show
  1. hfortix_core-0.5.88/PKG-INFO +186 -0
  2. hfortix_core-0.5.88/README.md +166 -0
  3. hfortix_core-0.5.88/hfortix_core/__init__.py +124 -0
  4. hfortix_core-0.5.88/hfortix_core/__init__.pyi +244 -0
  5. hfortix_core-0.5.88/hfortix_core/audit/__init__.py +80 -0
  6. hfortix_core-0.5.88/hfortix_core/audit/base.py +97 -0
  7. hfortix_core-0.5.88/hfortix_core/audit/formatters.py +296 -0
  8. hfortix_core-0.5.88/hfortix_core/audit/handlers.py +667 -0
  9. hfortix_core-0.5.88/hfortix_core/cache.py +128 -0
  10. hfortix_core-0.5.88/hfortix_core/debug/__init__.py +29 -0
  11. hfortix_core-0.5.88/hfortix_core/debug/base.py +123 -0
  12. hfortix_core-0.5.88/hfortix_core/debug/formatters.py +134 -0
  13. hfortix_core-0.5.88/hfortix_core/debug/handlers.py +313 -0
  14. hfortix_core-0.5.88/hfortix_core/deprecation.py +82 -0
  15. hfortix_core-0.5.88/hfortix_core/exceptions.py +1376 -0
  16. hfortix_core-0.5.88/hfortix_core/fmt.py +873 -0
  17. hfortix_core-0.5.88/hfortix_core/hooks/__init__.py +136 -0
  18. hfortix_core-0.5.88/hfortix_core/http/__init__.py +9 -0
  19. hfortix_core-0.5.88/hfortix_core/http/async_client.py +1343 -0
  20. hfortix_core-0.5.88/hfortix_core/http/async_client.pyi +168 -0
  21. hfortix_core-0.5.88/hfortix_core/http/base.py +693 -0
  22. hfortix_core-0.5.88/hfortix_core/http/client.py +1894 -0
  23. hfortix_core-0.5.88/hfortix_core/http/client.pyi +212 -0
  24. hfortix_core-0.5.88/hfortix_core/http/fmg_client.py +438 -0
  25. hfortix_core-0.5.88/hfortix_core/http/fmg_client.pyi +73 -0
  26. hfortix_core-0.5.88/hfortix_core/http/interface.py +326 -0
  27. hfortix_core-0.5.88/hfortix_core/logging/__init__.py +22 -0
  28. hfortix_core-0.5.88/hfortix_core/logging/base.py +76 -0
  29. hfortix_core-0.5.88/hfortix_core/logging/formatters.py +236 -0
  30. hfortix_core-0.5.88/hfortix_core/logging/handlers.py +120 -0
  31. hfortix_core-0.5.88/hfortix_core/py.typed +0 -0
  32. hfortix_core-0.5.88/hfortix_core/types.py +210 -0
  33. hfortix_core-0.5.88/hfortix_core/utils/__init__.py +38 -0
  34. hfortix_core-0.5.88/hfortix_core.egg-info/PKG-INFO +186 -0
  35. hfortix_core-0.5.88/hfortix_core.egg-info/SOURCES.txt +38 -0
  36. hfortix_core-0.5.88/hfortix_core.egg-info/dependency_links.txt +1 -0
  37. hfortix_core-0.5.88/hfortix_core.egg-info/requires.txt +2 -0
  38. hfortix_core-0.5.88/hfortix_core.egg-info/top_level.txt +1 -0
  39. hfortix_core-0.5.88/pyproject.toml +29 -0
  40. hfortix_core-0.5.88/setup.cfg +4 -0
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: hfortix-core
3
+ Version: 0.5.88
4
+ Summary: Core foundation for HFortix - Fortinet SDK
5
+ Author-email: "Herman W. Jacobsen" <herman@wjacobsen.fo>
6
+ License: Proprietary
7
+ Project-URL: Homepage, https://github.com/hermanwjacobsen/hfortix
8
+ Project-URL: Repository, https://github.com/hermanwjacobsen/hfortix
9
+ Keywords: fortinet,fortigate,fortios,api,sdk
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: httpx[http2]>=0.27.0
19
+ Requires-Dist: typing_extensions>=4.0.0
20
+
21
+ # HFortix Core
22
+
23
+ Core foundation for HFortix - Python SDK for Fortinet products.
24
+
25
+ [![PyPI version](https://badge.fury.io/py/hfortix-core.svg)](https://pypi.org/project/hfortix-core/)
26
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
27
+
28
+ > **⚠️ BETA STATUS - Version 0.5.57 (January 14, 2026)**
29
+ >
30
+ > Production-ready but in beta. All packages remain in beta until v1.0 with comprehensive unit tests.
31
+
32
+ ## Overview
33
+
34
+ `hfortix-core` provides the shared foundation for all HFortix Fortinet SDKs. It includes exception handling, HTTP client framework, formatting utilities, and common types used across FortiOS, FortiManager, and FortiAnalyzer clients.
35
+
36
+ **This package is typically used as a dependency.** For most users, install a product-specific package like `hfortix-fortios` or the meta-package `hfortix[all]`.
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install hfortix-core
42
+ ```
43
+
44
+ ## What's Included
45
+
46
+ ### Formatting Utilities (`fmt` module) - NEW in v0.5.44!
47
+
48
+ 13 data formatting functions for converting FortiOS data:
49
+
50
+ ```python
51
+ from hfortix_core import fmt
52
+
53
+ # Convert to various formats
54
+ fmt.to_json(data) # Formatted JSON string
55
+ fmt.to_csv(data) # Comma-separated string
56
+ fmt.to_dict(data) # Dictionary
57
+ fmt.to_list(data) # List (auto-splits "80 443" → ['80', '443'])
58
+ fmt.to_multiline(data) # Newline-separated string
59
+ fmt.to_quoted(data) # Quoted string representation
60
+ fmt.to_table(data) # ASCII table format
61
+ fmt.to_yaml(data) # YAML-like output (no dependencies)
62
+ fmt.to_xml(data) # Simple XML format
63
+ fmt.to_key_value(data) # Config file format
64
+ fmt.to_markdown_table(data) # Markdown table
65
+ fmt.to_dictlist(data) # Columnar → row format
66
+ fmt.to_listdict(data) # Row → columnar format
67
+ ```
68
+
69
+ **Features:**
70
+ - Zero external dependencies
71
+ - Handles any input gracefully (never raises exceptions)
72
+ - Auto-split for space-delimited strings (perfect for FortiOS `tcp_portrange`)
73
+ - Works with objects, dicts, lists, primitives
74
+
75
+ ### Exception System
76
+
77
+ Comprehensive exception hierarchy with 403+ FortiOS error codes:
78
+
79
+ ```python
80
+ from hfortix_core import (
81
+ FortinetError, # Base exception
82
+ APIError, # API-specific errors
83
+ AuthenticationError,
84
+ ResourceNotFoundError,
85
+ DuplicateEntryError,
86
+ # ... and 380+ more
87
+ )
88
+
89
+ try:
90
+ # Your Fortinet API code
91
+ pass
92
+ except DuplicateEntryError as e:
93
+ print(f"Object already exists: {e}")
94
+ except ResourceNotFoundError as e:
95
+ print(f"Not found: {e}")
96
+ except APIError as e:
97
+ print(f"API Error: {e.message} (code: {e.error_code})")
98
+ ```
99
+
100
+ **Features:**
101
+ - 403+ specific error codes with detailed descriptions
102
+ - Intelligent error classification
103
+ - Built-in recovery suggestions
104
+ - Request correlation tracking
105
+
106
+ ### Type Definitions
107
+
108
+ Shared TypedDict definitions and protocols for type safety:
109
+
110
+ ```python
111
+ from hfortix_core import (
112
+ APIResponse,
113
+ MutationResponse,
114
+ RawAPIResponse,
115
+ ListResponse,
116
+ ObjectResponse,
117
+ ErrorResponse,
118
+ ConnectionStats,
119
+ RequestInfo,
120
+ )
121
+
122
+ # Protocol interface for extensibility
123
+ from hfortix_core.http.interface import IHTTPClient
124
+
125
+ class MyCustomClient:
126
+ def get(self, api_type: str, path: str, **kwargs) -> dict: ...
127
+ def post(self, api_type: str, path: str, data: dict, **kwargs) -> dict: ...
128
+ # ... implement IHTTPClient protocol
129
+ ```
130
+
131
+ ## When to Use This Package
132
+
133
+ **Use `hfortix-core` directly if:**
134
+ - Building custom Fortinet integrations
135
+ - Creating specialized HTTP clients
136
+ - Extending exception handling
137
+ - Implementing custom protocols
138
+
139
+ **For most users:**
140
+ ```bash
141
+ # Install FortiOS client (includes core automatically)
142
+ pip install hfortix-fortios
143
+
144
+ # Or install everything
145
+ pip install hfortix[all]
146
+ ```
147
+
148
+ ## Product Packages
149
+
150
+ This core is used by:
151
+ - **hfortix-fortios** - FortiOS/FortiGate API client (1,348 endpoints)
152
+ - **hfortix-fortimanager** - FortiManager client (planned)
153
+ - **hfortix-fortianalyzer** - FortiAnalyzer client (planned)
154
+
155
+ ## Key Features
156
+
157
+ - 🔒 **Type-Safe**: Full PEP 561 compliance with type hints
158
+ - ⚡ **High Performance**: HTTP/2 support with connection pooling
159
+ - 🔄 **Resilient**: Automatic retry logic and circuit breaker
160
+ - 🎯 **Async Ready**: Full async/await support
161
+ - 📊 **Observable**: Request tracking and structured logging
162
+ - 🛡️ **Enterprise Grade**: Production-ready reliability features
163
+ - 📝 **Formatting**: 13 data conversion utilities in `fmt` module
164
+
165
+ ## Requirements
166
+
167
+ - Python 3.10+
168
+ - httpx[http2] >= 0.27.0
169
+
170
+ ## Documentation
171
+
172
+ For complete documentation, see the [main repository](https://github.com/hermanwjacobsen/hfortix):
173
+
174
+ - [Quick Start Guide](https://github.com/hermanwjacobsen/hfortix/blob/main/QUICKSTART.md)
175
+ - [API Reference](https://github.com/hermanwjacobsen/hfortix/blob/main/docs/fortios/ENDPOINT_METHODS.md)
176
+ - [Async Guide](https://github.com/hermanwjacobsen/hfortix/blob/main/docs/fortios/ASYNC_GUIDE.md)
177
+
178
+ ## License
179
+
180
+ Proprietary - See LICENSE file
181
+
182
+ ## Support
183
+
184
+ - 📖 [Documentation](https://github.com/hermanwjacobsen/hfortix)
185
+ - 🐛 [Report Issues](https://github.com/hermanwjacobsen/hfortix/issues)
186
+ - 💬 [Discussions](https://github.com/hermanwjacobsen/hfortix/discussions)
@@ -0,0 +1,166 @@
1
+ # HFortix Core
2
+
3
+ Core foundation for HFortix - Python SDK for Fortinet products.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/hfortix-core.svg)](https://pypi.org/project/hfortix-core/)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
7
+
8
+ > **⚠️ BETA STATUS - Version 0.5.57 (January 14, 2026)**
9
+ >
10
+ > Production-ready but in beta. All packages remain in beta until v1.0 with comprehensive unit tests.
11
+
12
+ ## Overview
13
+
14
+ `hfortix-core` provides the shared foundation for all HFortix Fortinet SDKs. It includes exception handling, HTTP client framework, formatting utilities, and common types used across FortiOS, FortiManager, and FortiAnalyzer clients.
15
+
16
+ **This package is typically used as a dependency.** For most users, install a product-specific package like `hfortix-fortios` or the meta-package `hfortix[all]`.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install hfortix-core
22
+ ```
23
+
24
+ ## What's Included
25
+
26
+ ### Formatting Utilities (`fmt` module) - NEW in v0.5.44!
27
+
28
+ 13 data formatting functions for converting FortiOS data:
29
+
30
+ ```python
31
+ from hfortix_core import fmt
32
+
33
+ # Convert to various formats
34
+ fmt.to_json(data) # Formatted JSON string
35
+ fmt.to_csv(data) # Comma-separated string
36
+ fmt.to_dict(data) # Dictionary
37
+ fmt.to_list(data) # List (auto-splits "80 443" → ['80', '443'])
38
+ fmt.to_multiline(data) # Newline-separated string
39
+ fmt.to_quoted(data) # Quoted string representation
40
+ fmt.to_table(data) # ASCII table format
41
+ fmt.to_yaml(data) # YAML-like output (no dependencies)
42
+ fmt.to_xml(data) # Simple XML format
43
+ fmt.to_key_value(data) # Config file format
44
+ fmt.to_markdown_table(data) # Markdown table
45
+ fmt.to_dictlist(data) # Columnar → row format
46
+ fmt.to_listdict(data) # Row → columnar format
47
+ ```
48
+
49
+ **Features:**
50
+ - Zero external dependencies
51
+ - Handles any input gracefully (never raises exceptions)
52
+ - Auto-split for space-delimited strings (perfect for FortiOS `tcp_portrange`)
53
+ - Works with objects, dicts, lists, primitives
54
+
55
+ ### Exception System
56
+
57
+ Comprehensive exception hierarchy with 403+ FortiOS error codes:
58
+
59
+ ```python
60
+ from hfortix_core import (
61
+ FortinetError, # Base exception
62
+ APIError, # API-specific errors
63
+ AuthenticationError,
64
+ ResourceNotFoundError,
65
+ DuplicateEntryError,
66
+ # ... and 380+ more
67
+ )
68
+
69
+ try:
70
+ # Your Fortinet API code
71
+ pass
72
+ except DuplicateEntryError as e:
73
+ print(f"Object already exists: {e}")
74
+ except ResourceNotFoundError as e:
75
+ print(f"Not found: {e}")
76
+ except APIError as e:
77
+ print(f"API Error: {e.message} (code: {e.error_code})")
78
+ ```
79
+
80
+ **Features:**
81
+ - 403+ specific error codes with detailed descriptions
82
+ - Intelligent error classification
83
+ - Built-in recovery suggestions
84
+ - Request correlation tracking
85
+
86
+ ### Type Definitions
87
+
88
+ Shared TypedDict definitions and protocols for type safety:
89
+
90
+ ```python
91
+ from hfortix_core import (
92
+ APIResponse,
93
+ MutationResponse,
94
+ RawAPIResponse,
95
+ ListResponse,
96
+ ObjectResponse,
97
+ ErrorResponse,
98
+ ConnectionStats,
99
+ RequestInfo,
100
+ )
101
+
102
+ # Protocol interface for extensibility
103
+ from hfortix_core.http.interface import IHTTPClient
104
+
105
+ class MyCustomClient:
106
+ def get(self, api_type: str, path: str, **kwargs) -> dict: ...
107
+ def post(self, api_type: str, path: str, data: dict, **kwargs) -> dict: ...
108
+ # ... implement IHTTPClient protocol
109
+ ```
110
+
111
+ ## When to Use This Package
112
+
113
+ **Use `hfortix-core` directly if:**
114
+ - Building custom Fortinet integrations
115
+ - Creating specialized HTTP clients
116
+ - Extending exception handling
117
+ - Implementing custom protocols
118
+
119
+ **For most users:**
120
+ ```bash
121
+ # Install FortiOS client (includes core automatically)
122
+ pip install hfortix-fortios
123
+
124
+ # Or install everything
125
+ pip install hfortix[all]
126
+ ```
127
+
128
+ ## Product Packages
129
+
130
+ This core is used by:
131
+ - **hfortix-fortios** - FortiOS/FortiGate API client (1,348 endpoints)
132
+ - **hfortix-fortimanager** - FortiManager client (planned)
133
+ - **hfortix-fortianalyzer** - FortiAnalyzer client (planned)
134
+
135
+ ## Key Features
136
+
137
+ - 🔒 **Type-Safe**: Full PEP 561 compliance with type hints
138
+ - ⚡ **High Performance**: HTTP/2 support with connection pooling
139
+ - 🔄 **Resilient**: Automatic retry logic and circuit breaker
140
+ - 🎯 **Async Ready**: Full async/await support
141
+ - 📊 **Observable**: Request tracking and structured logging
142
+ - 🛡️ **Enterprise Grade**: Production-ready reliability features
143
+ - 📝 **Formatting**: 13 data conversion utilities in `fmt` module
144
+
145
+ ## Requirements
146
+
147
+ - Python 3.10+
148
+ - httpx[http2] >= 0.27.0
149
+
150
+ ## Documentation
151
+
152
+ For complete documentation, see the [main repository](https://github.com/hermanwjacobsen/hfortix):
153
+
154
+ - [Quick Start Guide](https://github.com/hermanwjacobsen/hfortix/blob/main/QUICKSTART.md)
155
+ - [API Reference](https://github.com/hermanwjacobsen/hfortix/blob/main/docs/fortios/ENDPOINT_METHODS.md)
156
+ - [Async Guide](https://github.com/hermanwjacobsen/hfortix/blob/main/docs/fortios/ASYNC_GUIDE.md)
157
+
158
+ ## License
159
+
160
+ Proprietary - See LICENSE file
161
+
162
+ ## Support
163
+
164
+ - 📖 [Documentation](https://github.com/hermanwjacobsen/hfortix)
165
+ - 🐛 [Report Issues](https://github.com/hermanwjacobsen/hfortix/issues)
166
+ - 💬 [Discussions](https://github.com/hermanwjacobsen/hfortix/discussions)
@@ -0,0 +1,124 @@
1
+ """
2
+ HFortix Core - Shared foundation for Fortinet SDKs
3
+
4
+ Provides:
5
+ - Common exception hierarchy
6
+ - HTTP client framework (sync and async)
7
+ - Shared utilities and type definitions
8
+ """
9
+
10
+ from . import fmt
11
+ from .cache import (
12
+ TTLCache,
13
+ readonly_cache,
14
+ )
15
+ from .debug import (
16
+ DebugSession,
17
+ debug_timer,
18
+ format_connection_stats,
19
+ format_request_info,
20
+ print_debug_info,
21
+ )
22
+ from .deprecation import (
23
+ check_deprecated_fields,
24
+ warn_deprecated_field,
25
+ )
26
+ from .http import HTTPClientFMG
27
+ from .exceptions import (
28
+ APIError,
29
+ AuthenticationError,
30
+ AuthorizationError,
31
+ BadRequestError,
32
+ CircuitBreakerOpenError,
33
+ ConfigurationError,
34
+ DuplicateEntryError,
35
+ EntryInUseError,
36
+ FortinetError,
37
+ InvalidValueError,
38
+ MethodNotAllowedError,
39
+ NonRetryableError,
40
+ OperationNotSupportedError,
41
+ PermissionDeniedError,
42
+ RateLimitError,
43
+ ReadOnlyModeError,
44
+ ResourceNotFoundError,
45
+ RetryableError,
46
+ ServerError,
47
+ ServiceUnavailableError,
48
+ TimeoutError,
49
+ ValidationError,
50
+ VDOMError,
51
+ )
52
+ from .logging import (
53
+ RequestLogger,
54
+ StructuredFormatter,
55
+ TextFormatter,
56
+ log_operation,
57
+ )
58
+ from .types import (
59
+ APIResponse,
60
+ CircuitBreakerState,
61
+ ConnectionStats,
62
+ ErrorResponse,
63
+ ListResponse,
64
+ ObjectResponse,
65
+ RequestInfo,
66
+ )
67
+
68
+ __version__ = "0.5.84"
69
+
70
+ __all__ = [
71
+ # Cache utilities
72
+ "TTLCache",
73
+ "readonly_cache",
74
+ # Deprecation utilities
75
+ "check_deprecated_fields",
76
+ "warn_deprecated_field",
77
+ # Formatting utilities
78
+ "fmt",
79
+ # Exceptions
80
+ "FortinetError",
81
+ "APIError",
82
+ "AuthenticationError",
83
+ "AuthorizationError",
84
+ "ValidationError",
85
+ "RetryableError",
86
+ "NonRetryableError",
87
+ "ConfigurationError",
88
+ "VDOMError",
89
+ "OperationNotSupportedError",
90
+ "ReadOnlyModeError",
91
+ "BadRequestError",
92
+ "ResourceNotFoundError",
93
+ "MethodNotAllowedError",
94
+ "RateLimitError",
95
+ "ServerError",
96
+ "ServiceUnavailableError",
97
+ "CircuitBreakerOpenError",
98
+ "TimeoutError",
99
+ "DuplicateEntryError",
100
+ "EntryInUseError",
101
+ "InvalidValueError",
102
+ "PermissionDeniedError",
103
+ # Type definitions
104
+ "APIResponse",
105
+ "ListResponse",
106
+ "ObjectResponse",
107
+ "ErrorResponse",
108
+ "ConnectionStats",
109
+ "RequestInfo",
110
+ "CircuitBreakerState",
111
+ # Logging utilities
112
+ "RequestLogger",
113
+ "log_operation",
114
+ "StructuredFormatter",
115
+ "TextFormatter",
116
+ # Debug utilities
117
+ "DebugSession",
118
+ "debug_timer",
119
+ "format_connection_stats",
120
+ "format_request_info",
121
+ "print_debug_info",
122
+ # HTTP clients
123
+ "HTTPClientFMG",
124
+ ]