-
-
Notifications
You must be signed in to change notification settings - Fork 260
Api v2 get paginated customers #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
c8y3
wants to merge
128
commits into
develop
Choose a base branch
from
api_v2_get_paginated_customers
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 125 commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
9a33abf
Started implementation of POST /api/v2/alerts-filters
Elise17 b7088fd
Fixed analysis check
Elise17 103ed2c
Added function _load
Elise17 82bfec6
Deprecated endpoint POST /filters/add in favor of POST /api/v2/alerts…
Elise17 5b1290e
Added test create alert when filter data is missing
Elise17 ea45b99
Added test test_create_alert_filter_should_return_filter_type
Elise17 4c5ddd6
Added test_create_alert_filter_should_return_filter_name
Elise17 0a0f63d
Added test_create_alert_filter_should_return_in_filter_data_alert_title
Elise17 af0bf2b
Started implementation of GET /api/v2/alerts-filters/{identifier}
Elise17 0c911fe
Fixed check analysis
Elise17 8559ad7
Fixed importation problem
Elise17 7440b09
Fixed static analysis
Elise17 0690eb0
Removed user in test
Elise17 1129b73
Added test_get_alert_filter_should_return_filter_name
Elise17 97a89e5
Deprecated endpoint GET /filters/{identifier}
Elise17 622b46a
Added test_get_alert_filter_should_return_404
Elise17 9a1fffd
Added test_get_alert_filter_should_return_404_when_user_has_not_creat…
Elise17 e4b4998
Fixed static analysis
Elise17 69e38c8
Started implementation of PUT /api/v2/alerts-filters/{identifier}
Elise17 ec809ef
Fixed static analysis
Elise17 f438d3b
Added test_update_alert_filter_should_return_filter_name
Elise17 930e94c
Added test_update_alert_filter_should_return_filter_description
Elise17 120bed5
Added test_update_alert_filter_should_return_filter_type
Elise17 48c0957
Added test_update_alert_filter_should_return_filter_data_alert_title
Elise17 657d441
Added test_update_alert_filter_should_return_404_when_alert_filter_is…
Elise17 1008f29
Removed identifietr in test_update_alert_filter_should_return_404_whe…
Elise17 78234ef
Deprecated endpoint POST /filters/update/{identifier}
Elise17 eb541cb
Started implmentation of endpoint DELETE /api/v2/alerts-filters/{iden…
Elise17 745739c
Added test_delete_alert_filter_should_return_404_when_alert_not_found
Elise17 74bf4ea
test_get_alert_filter_should_return_404_after_delete_alert_filter
Elise17 157d749
Deprecated endpoint DELETE /api/v2/alerts-filters/{identifier}
Elise17 9a5a4c7
Fixed check analysis
Elise17 cb3ec88
Changed indentation and added ValidationError
Elise17 8d345f3
Changed indentation and added ValidationError
Elise17 b68b34c
Added new test test_update_alert_filter_should_return_400
Elise17 2dbfb95
Renamed method
c8y3 d1986e9
Renamed method
c8y3 7a8cfc5
Aligned method call
c8y3 ddef892
Started implementation of GET /api/v2/manage/customers/{identifier}
c8y3 6096f3b
Moved code down into persistence layer
c8y3 c7c77d0
Removed unused imports
c8y3 115d9ae
Added tow new import constraints: do not import marshables and do not…
c8y3 497135d
One import per line
c8y3 2651462
Removed dead code
c8y3 358d2d1
One import per line
c8y3 2c041aa
Following calling conventions
c8y3 3a6204b
Moved code down into the business and persistence layers
c8y3 acd242b
Early return
c8y3 cef2751
Simple quotes
c8y3 3fe05d1
Introduced method to get a customer by its name
c8y3 99842fc
Ruff warning
c8y3 50b4982
Added method to create a customer in the business layer
c8y3 3282472
Added a TODO
c8y3 7791840
Do not import iris_current_user from app.business.cases
c8y3 573a842
Removed unnecessary method parameter
c8y3 5411f32
Parameter need not be optional
c8y3 c1a2036
Extracted method
c8y3 410cdac
Extracted method
c8y3 f009aba
Removed one call to iris_current_user from iris_engine
c8y3 e1e3691
Moved code down into models
c8y3 1754dbf
Moved test .env file at the top level as .env.tests.model
c8y3 7ceee59
Renamed method to follow conventions
c8y3 e73af4d
GET /api/v2/customers/{identifier} should return 404 when it doesn't …
c8y3 30f49e2
Renamed test
c8y3 31e8495
Deprecate GET /manage/customers/{client_id}
c8y3 f3163c8
GET /api/v2/manage/customers/{identifier} returns 403 when user has n…
c8y3 df5de76
Removed methods which seem to be dead
c8y3 d912cac
Added rule RUF100
c8y3 74b9866
Added ruff rule RUF029
c8y3 e0ba692
Added ruff rules FURB14*
c8y3 405e758
Added ruff rule ARG003 and ARG005
c8y3 0d4f59f
Added ruff rules PYI*
c8y3 86e556b
Fixed and added all ruff B00* rules
c8y3 0329817
Set ruff rules FURB142, FURB145 and FURB148 rather than RUF14* (I am …
c8y3 4070b55
Removed PYI rules: we do not seem to use pyi
c8y3 535556f
Added dead code check with vulture
c8y3 9cc46da
Renamed vulture ignore file so that ruff does not parse it as a pytho…
c8y3 3fb283a
Removed validate_asset_type from vulture ignore list to check it fail…
c8y3 13bb46c
Removed seemingly dead methods
c8y3 e89de9e
Commented seemingly dead code which is used by iris-module-interface
c8y3 e080126
Started implementation of PUT /api/v2/manage/customers/{identifier}
c8y3 b400f72
PUT /api/v2/manage/customers/{identifier} should return 400 when anot…
c8y3 e6625f1
Moved database code out of marshables into the persistence layer
c8y3 39ac885
Added some ignored files to vulture
c8y3 33a4a4e
Improved configuration of vulture somewhat
c8y3 de86e58
Improved configuration of vulture somewhat
c8y3 f25c442
Improved configuration of vulture somewhat
c8y3 de3b44e
Organized vulture ignore file a bit more
c8y3 c4a4881
Simplified vulture ignore file somewhat
c8y3 97ee448
Deprecated PUT /manage/customers/update/<int:client_id>
c8y3 48c1209
Removed one occurence of ElementNotFoundException (use ObjectNotFound…
c8y3 ee14b4a
Removed unnecessary parameter
c8y3 ed60317
Removed exception ElementNotFoundException
c8y3 c5c4dd1
Fixed some deepsource warnings
c8y3 2105ca1
Added E20* ruff rules, and fixed warnings
c8y3 e25ba98
Added ruff rule W391
c8y3 20b074c
Fixed ruff warnings
c8y3 6a55d46
Started implmentation of DELETE /api/v2/manage/customers/{identifier}
c8y3 2f01f79
DELETE /api/v2/manage/customers/{identifier} should return 400 when c…
c8y3 2c4925d
Renamed test
c8y3 5cbdaf1
Moved business error definitions out of business into model
c8y3 9ab53e4
Fixed import constraint
c8y3 c7c3a0f
Use annotations to define endpoints on groups
c8y3 20bb8d9
Fixed ruff warnings
c8y3 a9079a7
Added import constraint: Do not import marshmallow from the persisten…
c8y3 ab8c8ee
Tyring to move dependence to marshmallow up in the API layer
c8y3 c1fc3a2
Fixed incorrect typing
c8y3 2c76991
Removed an marshable import from the persistence layer
c8y3 197de4f
Fixed ruff warning
c8y3 5b308a0
Deprecated POST /manage/customers/delete/<int:client_id>
c8y3 901098b
Removed unnecessary file
c8y3 0b2b15f
Removed all unit tests which have not been run in a long time. Added …
c8y3 c099fef
Started implementation of GET /api/v2/manage/customers
c8y3 4ae9af9
Fixed ruff warning
c8y3 7eb8971
Moved method into API layer
c8y3 704bb07
app.datamgmt.alerts.alerts_db should not import app.blueprints.access…
c8y3 cc14de1
Fixed ruff warning
c8y3 221ea9d
Removed seemingly dead method
c8y3 dcc4830
Factored code somewhat
c8y3 76acb33
Removed cycle
c8y3 5244279
Use method from the business layer
c8y3 0f4319e
Use method from the API layer
c8y3 8f3bf8e
Fixed incorrect retrieval of identifier
c8y3 88d09a3
Import db directly from app.db rather than from app
c8y3 ebe8870
Deprecated GET /manage/customers/list
c8y3 08db0cd
Fixed deepsource warning
c8y3 be022b8
Fixed missing parameters
c8y3 6fe4364
Fixed bug when checking for permission
c8y3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,4 +27,3 @@ | |
|
|
||
| def worker_exit(server, worker): | ||
| sys.exit(4) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,4 +42,3 @@ def upgrade(): | |
|
|
||
| def downgrade(): | ||
| pass | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,4 +57,3 @@ def upgrade(): | |
|
|
||
| def downgrade(): | ||
| pass | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,4 +61,3 @@ def downgrade(): | |
|
|
||
| # Drop AlertSimilarity table | ||
| op.drop_table('alert_similarity') | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,3 @@ def __getitem__(self, index: slice) -> any: | |
|
|
||
| def __len__(self) -> int: | ||
| return self._total | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent KeyError when checking permissions outside session auth
Calling
ac_current_user_has_permissionduring token-authenticated requests blows up becausesession['permissions']is never populated in that flow—wrap_with_permission_checkscaches permissions ong, not in the session cookie. This raises aKeyError, causing 500 responses for routes that use the new helper (e.g., GET /api/v2/manage/customers with a Bearer token). We need to reuse the same guards as_user_has_at_least_a_required_permission, falling back tog.auth_user_permissionsand lazily loading the session flag. (search.google.com)def ac_current_user_has_permission(permission): """ Return True if current user has permission """ - return ac_flag_match_mask(session['permissions'], permission.value) + if hasattr(g, 'auth_token_user_id'): + if hasattr(g, 'auth_user_permissions'): + permissions_flag = g.auth_user_permissions + else: + user = get_user(g.auth_token_user_id) + if not user: + return False + permissions_flag = ac_get_effective_permissions_of_user(user) + g.auth_user_permissions = permissions_flag + return ac_flag_match_mask(permissions_flag, permission.value) + + if 'permissions' not in session: + session['permissions'] = ac_get_effective_permissions_of_user(current_user) + + return ac_flag_match_mask(session['permissions'], permission.value)📝 Committable suggestion
🤖 Prompt for AI Agents