alpha-python 0.7.0__tar.gz → 0.7.1__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 (159) hide show
  1. {alpha_python-0.7.0 → alpha_python-0.7.1}/PKG-INFO +1 -1
  2. {alpha_python-0.7.0 → alpha_python-0.7.1}/pyproject.toml +1 -1
  3. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/__init__.py +3 -0
  4. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/__init__.py +5 -0
  5. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/api_repository.py +5 -5
  6. alpha_python-0.7.1/src/alpha/interfaces/http_client.py +61 -0
  7. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/models/token.py +2 -2
  8. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/refresh/cache_repository.py +6 -3
  9. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/refresh/database_repository.py +3 -3
  10. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/refresh/file_repository.py +3 -3
  11. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/refresh/memory_repository.py +3 -3
  12. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/rest_api_repository.py +72 -18
  13. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/PKG-INFO +1 -1
  14. alpha_python-0.7.0/src/alpha/interfaces/http_client.py +0 -26
  15. {alpha_python-0.7.0 → alpha_python-0.7.1}/LICENSE +0 -0
  16. {alpha_python-0.7.0 → alpha_python-0.7.1}/README.md +0 -0
  17. {alpha_python-0.7.0 → alpha_python-0.7.1}/setup.cfg +0 -0
  18. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/adapters/__init__.py +0 -0
  19. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/adapters/rest_api_unit_of_work.py +0 -0
  20. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/adapters/sqla_unit_of_work.py +0 -0
  21. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/cli.py +0 -0
  22. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/containers/__init__.py +0 -0
  23. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/containers/container.py +0 -0
  24. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/__init__.py +0 -0
  25. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/__init__.py +0 -0
  26. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/base_model.py +0 -0
  27. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/group.py +0 -0
  28. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/life_cycle_base.py +0 -0
  29. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/role.py +0 -0
  30. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/domain/models/user.py +0 -0
  31. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/encoder.py +0 -0
  32. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/exceptions.py +0 -0
  33. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/__init__.py +0 -0
  34. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/_type_conversion_matrix.py +0 -0
  35. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/_type_mapping.py +0 -0
  36. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/class_factories.py +0 -0
  37. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/default_field_factory.py +0 -0
  38. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/field_iterator.py +0 -0
  39. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/jwt_factory.py +0 -0
  40. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/logging_handler_factory.py +0 -0
  41. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/model_class_factory.py +0 -0
  42. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/models/__init__.py +0 -0
  43. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/models/factory_classes.py +0 -0
  44. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/password_factory.py +0 -0
  45. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/request_factory.py +0 -0
  46. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/response_factory.py +0 -0
  47. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/factories/type_factories.py +0 -0
  48. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/__init__.py +0 -0
  49. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/api_generate_handler.py +0 -0
  50. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/api_run_handler.py +0 -0
  51. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/base_handler.py +0 -0
  52. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/gen-code.sh +0 -0
  53. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/models/__init__.py +0 -0
  54. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/models/argument.py +0 -0
  55. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/models/command.py +0 -0
  56. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/models/section.py +0 -0
  57. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/models/subparser.py +0 -0
  58. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/run-api.sh +0 -0
  59. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/__init__.py +0 -0
  60. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/Dockerfile.mustache +0 -0
  61. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/README.mustache +0 -0
  62. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/__init__model.mustache +0 -0
  63. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/__init__test.mustache +0 -0
  64. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/__main__.mustache +0 -0
  65. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/base_model.mustache +0 -0
  66. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/controller.mustache +0 -0
  67. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/controller_test.mustache +0 -0
  68. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/dockerignore.mustache +0 -0
  69. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/encoder.mustache +0 -0
  70. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/git_push.sh.mustache +0 -0
  71. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/gitignore.mustache +0 -0
  72. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/model.mustache +0 -0
  73. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/openapi.mustache +0 -0
  74. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/param_type.mustache +0 -0
  75. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/requirements.mustache +0 -0
  76. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/security_controller_.mustache +0 -0
  77. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/setup.mustache +0 -0
  78. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/test-requirements.mustache +0 -0
  79. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/tox.mustache +0 -0
  80. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/travis.mustache +0 -0
  81. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/typing_utils.mustache +0 -0
  82. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/handlers/templates/python-flask/util.mustache +0 -0
  83. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/__init__.py +0 -0
  84. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/connectors/__init__.py +0 -0
  85. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/connectors/ldap_connector.py +0 -0
  86. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/connectors/oidc_connector.py +0 -0
  87. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/connectors/sql_alchemy.py +0 -0
  88. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/databases/__init__.py +0 -0
  89. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/databases/sql_alchemy.py +0 -0
  90. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/__init__.py +0 -0
  91. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/filter_operators.py +0 -0
  92. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/json_patch.py +0 -0
  93. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/order_by.py +0 -0
  94. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/query_clause.py +0 -0
  95. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/infra/models/search_filter.py +0 -0
  96. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/attrs_instance.py +0 -0
  97. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/dataclass_instance.py +0 -0
  98. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/factories.py +0 -0
  99. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/handler.py +0 -0
  100. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/openapi_model.py +0 -0
  101. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/patchable.py +0 -0
  102. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/providers.py +0 -0
  103. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/pydantic_instance.py +0 -0
  104. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/refresh_repository.py +0 -0
  105. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/sql_database.py +0 -0
  106. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/sql_mapper.py +0 -0
  107. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/sql_repository.py +0 -0
  108. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/token_factory.py +0 -0
  109. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/unit_of_work.py +0 -0
  110. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/interfaces/updatable.py +0 -0
  111. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/mixins/__init__.py +0 -0
  112. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/mixins/group_lifecycle.py +0 -0
  113. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/mixins/jwt_provider.py +0 -0
  114. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/mixins/user_lifecycle.py +0 -0
  115. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/__init__.py +0 -0
  116. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/api_key_provider.py +0 -0
  117. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/database_provider.py +0 -0
  118. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/ldap_provider.py +0 -0
  119. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/models/__init__.py +0 -0
  120. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/models/credentials.py +0 -0
  121. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/models/identity.py +0 -0
  122. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/providers/oidc_provider.py +0 -0
  123. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/py.typed +0 -0
  124. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/__init__.py +0 -0
  125. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/models/__init__.py +0 -0
  126. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/models/repository_model.py +0 -0
  127. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/refresh/__init__.py +0 -0
  128. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/repositories/sql_alchemy_repository.py +0 -0
  129. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/services/__init__.py +0 -0
  130. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/services/authentication_service.py +0 -0
  131. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/services/models/__init__.py +0 -0
  132. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/services/models/cookie.py +0 -0
  133. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/services/user_lifecycle_management.py +0 -0
  134. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/__init__.py +0 -0
  135. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/_http_codes.py +0 -0
  136. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/cookie.py +0 -0
  137. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/is_attrs.py +0 -0
  138. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/is_pydantic.py +0 -0
  139. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/logging_configurator.py +0 -0
  140. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/logging_level_checker.py +0 -0
  141. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/__init__.py +0 -0
  142. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/container.py +0 -0
  143. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/exceptions.py +0 -0
  144. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/models.py +0 -0
  145. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/orm.py +0 -0
  146. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/response.py +0 -0
  147. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/openapi_test/service.py +0 -0
  148. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/request_headers.py +0 -0
  149. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/response_object.py +0 -0
  150. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/secret_generator.py +0 -0
  151. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/verify_identity.py +0 -0
  152. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha/utils/version_checker.py +0 -0
  153. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/SOURCES.txt +0 -0
  154. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/dependency_links.txt +0 -0
  155. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/entry_points.txt +0 -0
  156. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/requires.txt +0 -0
  157. {alpha_python-0.7.0 → alpha_python-0.7.1}/src/alpha_python.egg-info/top_level.txt +0 -0
  158. {alpha_python-0.7.0 → alpha_python-0.7.1}/tests/test_cli.py +0 -0
  159. {alpha_python-0.7.0 → alpha_python-0.7.1}/tests/test_encoder.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpha-python
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
5
5
  Author-email: Bart Reijling <bart@reijling.eu>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "alpha-python"
3
- version = "0.7.0"
3
+ version = "0.7.1"
4
4
  description = "Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -30,6 +30,7 @@ from alpha.interfaces.pydantic_instance import PydanticInstance
30
30
  from alpha.interfaces.openapi_model import OpenAPIModel
31
31
  from alpha.interfaces.updatable import Updatable
32
32
  from alpha.interfaces.patchable import Patchable
33
+ from alpha.interfaces.http_client import HTTPClient, HTTPResponse
33
34
  from alpha.interfaces.api_repository import ApiRepository
34
35
  from alpha.interfaces.sql_repository import SqlRepository
35
36
  from alpha.interfaces.sql_mapper import SqlMapper
@@ -140,6 +141,8 @@ __all__ = [
140
141
  "OpenAPIModel",
141
142
  "Updatable",
142
143
  "Patchable",
144
+ "HTTPClient",
145
+ "HTTPResponse",
143
146
  "ApiRepository",
144
147
  "SqlRepository",
145
148
  "SqlMapper",
@@ -6,6 +6,9 @@ from alpha.interfaces.openapi_model import OpenAPIModel
6
6
  from alpha.interfaces.updatable import Updatable
7
7
  from alpha.interfaces.patchable import Patchable
8
8
 
9
+ # import all http client related interfaces
10
+ from alpha.interfaces.http_client import HTTPClient, HTTPResponse
11
+
9
12
  # import all repository related interfaces
10
13
  from alpha.interfaces.api_repository import ApiRepository
11
14
  from alpha.interfaces.sql_repository import SqlRepository
@@ -34,6 +37,8 @@ __all__ = [
34
37
  "OpenAPIModel",
35
38
  "Updatable",
36
39
  "Patchable",
40
+ "HTTPClient",
41
+ "HTTPResponse",
37
42
  "ApiRepository",
38
43
  "SqlRepository",
39
44
  "RefreshRepository",
@@ -263,7 +263,7 @@ class ApiRepository(Protocol[DomainModel]):
263
263
  Whether to use the model factory method for creating models from
264
264
  response data.
265
265
  endpoint
266
- The API endpoint to which the object should be added.
266
+ The API endpoint from which the object should be retrieved.
267
267
  parent_endpoint
268
268
  The parent API endpoint, if the resource is nested under a parent
269
269
  resource.
@@ -340,7 +340,7 @@ class ApiRepository(Protocol[DomainModel]):
340
340
  Whether to use the model factory method for creating models from
341
341
  response data.
342
342
  endpoint
343
- The API endpoint to which the object should be added.
343
+ The API endpoint from which the objects should be retrieved.
344
344
  parent_endpoint
345
345
  The parent API endpoint, if the resource is nested under a parent
346
346
  resource.
@@ -441,7 +441,7 @@ class ApiRepository(Protocol[DomainModel]):
441
441
  Whether to use the model factory method for creating models from
442
442
  response data.
443
443
  endpoint
444
- The API endpoint to which the object should be added.
444
+ The API endpoint to which the patch should be applied.
445
445
  parent_endpoint
446
446
  The parent API endpoint, if the resource is nested under a parent
447
447
  resource.
@@ -485,7 +485,7 @@ class ApiRepository(Protocol[DomainModel]):
485
485
  Parameters
486
486
  ----------
487
487
  endpoint
488
- The API endpoint to which the object should be added.
488
+ The API endpoint from which the object should be removed.
489
489
  parent_endpoint
490
490
  The parent API endpoint, if the resource is nested under a parent
491
491
  resource.
@@ -585,7 +585,7 @@ class ApiRepository(Protocol[DomainModel]):
585
585
  Whether to use the model factory method for creating models from
586
586
  response data.
587
587
  endpoint
588
- The API endpoint to which the object should be added.
588
+ The API endpoint to which the object should be updated.
589
589
  parent_endpoint
590
590
  The parent API endpoint, if the resource is nested under a parent
591
591
  resource.
@@ -0,0 +1,61 @@
1
+ from typing import MutableMapping, Protocol, Any, runtime_checkable
2
+
3
+
4
+ @runtime_checkable
5
+ class HTTPResponse(Protocol):
6
+ """Interface for HTTP response objects returned by HTTP clients.
7
+
8
+ This interface is compatible with the response objects returned by popular
9
+ synchronous HTTP client libraries, for example, the `requests` library,
10
+ `httpx` library or any custom implementation that follows the same
11
+ attributes and method signatures.
12
+
13
+ This interface defines the attributes and methods that an HTTP response
14
+ object should have to be compatible with the REST API repository. It
15
+ includes attributes for accessing the response status code, headers, and
16
+ content, as well as a method for parsing the response content as JSON.
17
+ """
18
+
19
+ status_code: int
20
+ headers: dict[str, str]
21
+ content: bytes
22
+ text: str
23
+
24
+ def json(self) -> Any: ...
25
+ def raise_for_status(self) -> None: ...
26
+
27
+
28
+ @runtime_checkable
29
+ class HTTPClient(Protocol):
30
+ """Interface for HTTP clients like requests, httpx or a custom
31
+ implementation.
32
+
33
+ This interface is compatible with the popular synchronous HTTP client
34
+ libraries, for example, the `requests` library, `httpx` library or any
35
+ custom implementation that follows the same method signatures.
36
+
37
+ This interface defines the methods that an HTTP client should implement to
38
+ be compatible with the REST API repository. It includes methods for making
39
+ HTTP requests (POST, GET, DELETE, PUT, PATCH) and allows for additional
40
+ parameters to be passed as needed.
41
+ """
42
+
43
+ cookies: MutableMapping[str, str]
44
+ headers: MutableMapping[str, str]
45
+
46
+ def request(
47
+ self, method: str, url: str, **kwargs: Any
48
+ ) -> HTTPResponse: ...
49
+ def close(self) -> None: ...
50
+
51
+ def post(
52
+ self, url: str, json: Any = None, **kwargs: Any
53
+ ) -> HTTPResponse: ...
54
+ def get(self, url: str, **kwargs: Any) -> HTTPResponse: ...
55
+ def delete(self, url: str, **kwargs: Any) -> HTTPResponse: ...
56
+ def put(
57
+ self, url: str, json: Any = None, **kwargs: Any
58
+ ) -> HTTPResponse: ...
59
+ def patch(
60
+ self, url: str, json: Any = None, **kwargs: Any
61
+ ) -> HTTPResponse: ...
@@ -93,11 +93,11 @@ class Token(BaseDomainModel):
93
93
  ----------
94
94
  subject
95
95
  The subject or user associated with the token.
96
- max_age_seconds, optional
96
+ max_age_seconds
97
97
  Optional maximum age of the token in seconds. Defaults to 7 days.
98
98
  If provided, the expires_at will be set to created_at +
99
99
  max_age_seconds.
100
- token_length, optional
100
+ token_length
101
101
  Optional length of the token value. Defaults to 32.
102
102
 
103
103
  Returns
@@ -13,11 +13,14 @@ class CacheRefreshRepository:
13
13
  ):
14
14
  """Initialize the CacheRefreshRepository with the given cache connector.
15
15
 
16
+ *** This class is not fully implemented yet. The methods are defined
17
+ but not implemented. ***
18
+
16
19
  Parameters
17
20
  ----------
18
21
  cache_connector
19
22
  The cache connector instance to use for cache operations.
20
- token_model, optional
23
+ token_model
21
24
  The model class for tokens, by default Token. The model class
22
25
  should have a `from_dict` class method that takes a dictionary and
23
26
  returns an instance of the model. The dictionary will have the same
@@ -26,10 +29,10 @@ class CacheRefreshRepository:
26
29
  the model to a dictionary with the same structure as the token data
27
30
  in the JSON file. The model class should also have a
28
31
  `create_refresh` class method that creates a new refresh token.
29
- token_max_age_seconds, optional
32
+ token_max_age_seconds
30
33
  The maximum age of a token in seconds, by default the equivalent of
31
34
  7 days in seconds
32
- token_length, optional
35
+ token_length
33
36
  The length of the generated token string, by default 32 characters
34
37
  """
35
38
  self._cache_connector = cache_connector
@@ -27,7 +27,7 @@ class DatabaseRefreshRepository:
27
27
  ----------
28
28
  database_connector
29
29
  The database connector instance to use for database operations.
30
- token_model, optional
30
+ token_model
31
31
  The model class for tokens, by default Token. The model class
32
32
  should have a `from_dict` class method that takes a dictionary and
33
33
  returns an instance of the model. The dictionary will have the same
@@ -36,10 +36,10 @@ class DatabaseRefreshRepository:
36
36
  the model to a dictionary with the same structure as the token data
37
37
  in the JSON file. The model class should also have a
38
38
  `create_refresh` class method that creates a new refresh token.
39
- token_max_age_seconds, optional
39
+ token_max_age_seconds
40
40
  The maximum age of a token in seconds, by default the equivalent of
41
41
  7 days in seconds
42
- token_length, optional
42
+ token_length
43
43
  The length of the generated token string, by default 32 characters
44
44
  """
45
45
  self._database_connector = database_connector
@@ -36,7 +36,7 @@ class FileRefreshRepository:
36
36
  ...
37
37
  }
38
38
  ```
39
- token_model, optional
39
+ token_model
40
40
  The model class for tokens, by default Token. The model class
41
41
  should have a `from_dict` class method that takes a dictionary and
42
42
  returns an instance of the model. The dictionary will have the same
@@ -45,10 +45,10 @@ class FileRefreshRepository:
45
45
  the model to a dictionary with the same structure as the token data
46
46
  in the JSON file. The model class should also have a
47
47
  `create_refresh` class method that creates a new refresh token.
48
- token_max_age_seconds, optional
48
+ token_max_age_seconds
49
49
  The maximum age of a token in seconds, by default the equivalent of
50
50
  7 days in seconds
51
- token_length, optional
51
+ token_length
52
52
  The length of the generated token string, by default 32 characters
53
53
  """
54
54
  self._file_path = file_path or "refresh_tokens.json"
@@ -18,7 +18,7 @@ class MemoryRefreshRepository:
18
18
 
19
19
  Parameters
20
20
  ----------
21
- token_model, optional
21
+ token_model
22
22
  The model class for tokens, by default Token. The model class
23
23
  should have a `from_dict` class method that takes a dictionary and
24
24
  returns an instance of the model. The dictionary will have the same
@@ -27,10 +27,10 @@ class MemoryRefreshRepository:
27
27
  the model to a dictionary with the same structure as the token data
28
28
  in the JSON file. The model class should also have a
29
29
  `create_refresh` class method that creates a new refresh token.
30
- token_max_age_seconds, optional
30
+ token_max_age_seconds
31
31
  The maximum age of a token in seconds, by default the equivalent of
32
32
  7 days in seconds
33
- token_length, optional
33
+ token_length
34
34
  The length of the generated token string, by default 32 characters
35
35
  """
36
36
  self._token_model = token_model
@@ -4,14 +4,13 @@ from urllib.parse import urlencode, urljoin
4
4
  from uuid import UUID
5
5
 
6
6
  import requests
7
- from requests.cookies import cookiejar_from_dict # type: ignore
8
- from requests.models import Response
7
+ from requests.cookies import cookiejar_from_dict, RequestsCookieJar # type: ignore
9
8
  from typing import Any, Generic, TypeVar, cast
10
9
 
11
10
  from alpha import exceptions
12
11
  from alpha.domain.models.base_model import BaseDomainModel, DomainModel
13
12
  from alpha.infra.models.json_patch import JsonPatch
14
- from alpha.interfaces.http_client import HTTPClient
13
+ from alpha.interfaces.http_client import HTTPClient, HTTPResponse
15
14
 
16
15
  T = TypeVar("T", bound=BaseDomainModel)
17
16
 
@@ -108,7 +107,9 @@ class RestApiRepository(Generic[DomainModel]):
108
107
  self._model_factory_method_name = model_factory_method_name
109
108
  self._model_serialization_method_name = model_serialization_method_name
110
109
 
111
- client_obj = client or session or requests.sessions.Session()
110
+ client_obj = cast(
111
+ HTTPClient, client or session or requests.sessions.Session()
112
+ )
112
113
  # Expose the underlying client publicly for consistency with other
113
114
  # repositories
114
115
  self.client = client_obj
@@ -123,12 +124,65 @@ class RestApiRepository(Generic[DomainModel]):
123
124
  self._response_data_attribute = response_data_attribute
124
125
  # Update client with default headers and cookies
125
126
  self.client.headers.update(request_headers or {})
126
- cookiejar_from_dict(
127
- request_cookies or {},
128
- cookiejar=self.client.cookies,
129
- overwrite=True,
127
+ if request_cookies:
128
+ cookies = self.client.cookies
129
+ # If the client's cookies object supports the `update` method and
130
+ # is not a `RequestsCookieJar`, use `update`. Otherwise, if it's a
131
+ # `RequestsCookieJar`, use `cookiejar_from_dict` to update it.
132
+ # This ensures compatibility with different types of cookie
133
+ # implementations that may be used by various HTTP clients.
134
+ if hasattr(cookies, "update") and not isinstance(
135
+ cookies, RequestsCookieJar
136
+ ):
137
+ cookies.update(request_cookies)
138
+ elif isinstance(cookies, RequestsCookieJar):
139
+ cookiejar_from_dict(
140
+ request_cookies,
141
+ cookiejar=cookies,
142
+ overwrite=True,
143
+ )
144
+
145
+ def request(
146
+ self,
147
+ method: str,
148
+ url: str,
149
+ **kwargs: Any,
150
+ ) -> Any | None:
151
+ """Make a custom API request.
152
+
153
+ This method allows for making custom API requests using any HTTP method
154
+ supported by the underlying HTTP client. It provides flexibility for
155
+ making requests that may not fit the standard CRUD operations defined
156
+ in the repository. The method accepts the HTTP method, URL, and any
157
+ additional parameters that should be passed to the HTTP client's
158
+ request method.
159
+
160
+ Parameters
161
+ ----------
162
+ method
163
+ The HTTP method to use for the request (e.g., "GET", "POST", "PUT",
164
+ "DELETE", etc.).
165
+ url
166
+ The URL to which the request should be sent. This has to be a fully
167
+ constructed URL.
168
+ **kwargs
169
+ Additional parameters to include in the function call which handles
170
+ the API request. This allows for flexibility in specifying
171
+ parameters such as headers, authentication tokens, or other request
172
+ options that may be needed for the API call.
173
+
174
+ Returns
175
+ -------
176
+ The data retrieved from the API response.
177
+ """
178
+ response = self.client.request(
179
+ method=method.upper(),
180
+ url=url,
181
+ **kwargs,
130
182
  )
131
183
 
184
+ return self._handle_response(response)
185
+
132
186
  def add(
133
187
  self,
134
188
  obj: DomainModel,
@@ -324,7 +378,7 @@ class RestApiRepository(Generic[DomainModel]):
324
378
  Whether to use the model factory method for creating models from
325
379
  response data.
326
380
  endpoint
327
- The API endpoint to which the object should be added.
381
+ The API endpoint from which the object should be retrieved.
328
382
  parent_endpoint
329
383
  The parent API endpoint, if the resource is nested under a parent
330
384
  resource.
@@ -390,7 +444,7 @@ class RestApiRepository(Generic[DomainModel]):
390
444
  Whether to use the model factory method for creating models from
391
445
  response data.
392
446
  endpoint
393
- The API endpoint to which the object should be added.
447
+ The API endpoint from which the objects should be retrieved.
394
448
  parent_endpoint
395
449
  The parent API endpoint, if the resource is nested under a parent
396
450
  resource.
@@ -462,7 +516,7 @@ class RestApiRepository(Generic[DomainModel]):
462
516
  Whether to use the model factory method for creating models from
463
517
  response data.
464
518
  endpoint
465
- The API endpoint to which the object should be added.
519
+ The API endpoint to which the patch should be applied.
466
520
  parent_endpoint
467
521
  The parent API endpoint, if the resource is nested under a parent
468
522
  resource.
@@ -474,7 +528,7 @@ class RestApiRepository(Generic[DomainModel]):
474
528
  param
475
529
  The parameter to identify the specific resource. This could be an
476
530
  ID or a unique identifier. The parameter will be appended to the
477
- endpoint to form the full URL for the GET request.
531
+ endpoint to form the full URL for the PATCH request.
478
532
  model
479
533
  The model to use for serialization/deserialization.
480
534
  additional_request_params
@@ -525,7 +579,7 @@ class RestApiRepository(Generic[DomainModel]):
525
579
  Parameters
526
580
  ----------
527
581
  endpoint
528
- The API endpoint to which the object should be added.
582
+ The API endpoint from which the object should be removed.
529
583
  parent_endpoint
530
584
  The parent API endpoint, if the resource is nested under a parent
531
585
  resource.
@@ -537,7 +591,7 @@ class RestApiRepository(Generic[DomainModel]):
537
591
  param
538
592
  The parameter to identify the specific resource. This could be an
539
593
  ID or a unique identifier. The parameter will be appended to the
540
- endpoint to form the full URL for the GET request.
594
+ endpoint to form the full URL for the DELETE request.
541
595
  additional_request_params
542
596
  Additional parameters to include in the function call which handles
543
597
  the API request. This allows for flexibility in specifying
@@ -588,7 +642,7 @@ class RestApiRepository(Generic[DomainModel]):
588
642
  Whether to use the model factory method for creating models from
589
643
  response data.
590
644
  endpoint
591
- The API endpoint to which the object should be added.
645
+ The API endpoint to which the object should be updated.
592
646
  parent_endpoint
593
647
  The parent API endpoint, if the resource is nested under a parent
594
648
  resource.
@@ -600,7 +654,7 @@ class RestApiRepository(Generic[DomainModel]):
600
654
  param
601
655
  The parameter to identify the specific resource. This could be an
602
656
  ID or a unique identifier. The parameter will be appended to the
603
- endpoint to form the full URL for the GET request.
657
+ endpoint to form the full URL for the PUT request.
604
658
  model
605
659
  The model to use for serialization/deserialization.
606
660
  additional_request_params
@@ -943,7 +997,7 @@ class RestApiRepository(Generic[DomainModel]):
943
997
  return obj
944
998
 
945
999
  def _get_data_from_response(
946
- self, response: Response
1000
+ self, response: HTTPResponse
947
1001
  ) -> dict[str, Any] | None:
948
1002
  """Extract data from the API response. If the response_data_attribute
949
1003
  is configured, it will return the value of that attribute. Otherwise,
@@ -1044,7 +1098,7 @@ class RestApiRepository(Generic[DomainModel]):
1044
1098
 
1045
1099
  return model_to_use
1046
1100
 
1047
- def _handle_response(self, response: Response) -> Any | None:
1101
+ def _handle_response(self, response: HTTPResponse) -> Any | None:
1048
1102
  """Handle the API response and extract the relevant data.
1049
1103
 
1050
1104
  In addition to extracting data from successful responses, this method
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alpha-python
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
5
5
  Author-email: Bart Reijling <bart@reijling.eu>
6
6
  License-Expression: MIT
@@ -1,26 +0,0 @@
1
- from typing import Protocol, Any, runtime_checkable
2
-
3
-
4
- @runtime_checkable
5
- class HTTPClient(Protocol):
6
- """Interface for HTTP clients like requests, httpx or a custom
7
- implementation.
8
-
9
- This interface is compatible with the popular synchronous HTTP client
10
- libraries, for example, the `requests` library, `httpx` library or any
11
- custom implementation that follows the same method signatures.
12
-
13
- This interface defines the methods that an HTTP client should implement to
14
- be compatible with the REST API repository. It includes methods for making
15
- HTTP requests (POST, GET, DELETE, PUT, PATCH) and allows for additional
16
- parameters to be passed as needed.
17
- """
18
-
19
- cookies: Any
20
- headers: Any
21
-
22
- def post(self, url: str, json: Any = None, **kwargs: Any) -> Any: ...
23
- def get(self, url: str, **kwargs: Any) -> Any: ...
24
- def delete(self, url: str, **kwargs: Any) -> Any: ...
25
- def put(self, url: str, json: Any = None, **kwargs: Any) -> Any: ...
26
- def patch(self, url: str, json: Any = None, **kwargs: Any) -> Any: ...
File without changes
File without changes
File without changes