-
Notifications
You must be signed in to change notification settings - Fork 1
Cognition integration provider #167
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
Merged
Merged
Changes from 120 commits
Commits
Show all changes
143 commits
Select commit
Hold shift + click to select a range
551c995
build: third party integration first commit
andhreljaKern e115cac
chore: update enums
andhreljaKern 4d9970a
perf: add integration acess
andhreljaKern 80712fc
perf: rename to integration
andhreljaKern fbd5a85
perf: add last_extraction column to integration
andhreljaKern 0dbad39
perf: update integration delta
andhreljaKern 458e4dc
perf: update integration access to list types
andhreljaKern 7d70cd4
perf: add integration_types to integration access
andhreljaKern bbf643e
perf: add integration_types to integration access
andhreljaKern cc57cb4
perf: rename last_extraction to extract_history
andhreljaKern 2da4e15
fix: store enum.value instead of enum
andhreljaKern edad963
fix: integration.project_id nullable
andhreljaKern 4e52cb8
fix: nulable column instead of foreignkey
andhreljaKern 03842fd
fix: enum values
andhreljaKern 0386f6c
perf: task cancellation
andhreljaKern 90debd4
fix: keyword arguments
andhreljaKern d099974
perf: integration record
andhreljaKern 6fd3656
perf: add tokenizer
andhreljaKern 76fd2ff
perf: add update integration access
andhreljaKern 23099d3
perf: update integration endpoints
andhreljaKern 5d2d503
perf: add get endpoint
andhreljaKern a2aa966
Oidc field in the users table
lumburovskalina 4cd321f
perf: add org_id to integration provider
andhreljaKern 0b6a9fa
Merge branch 'dev' into cognition-integration-provider
andhreljaKern 0467f29
perf: add org_id support to integration
andhreljaKern 888a542
perf: add record delta criteria
andhreljaKern 8af9e39
fix: task execution finish on failed integration
andhreljaKern 99494f8
perf: add integration finished_at
andhreljaKern 5989801
perf: add started_at
andhreljaKern bec5f20
fix: started_at - finished_at syntax error
andhreljaKern 8898a3c
perf: add integration records
andhreljaKern 4aeea83
Merge branch 'cognition-integration-provider' of github.com:code-kern…
andhreljaKern 66e8a0c
perf: add integration tables
andhreljaKern 2ec00db
perf: update integrations delta
andhreljaKern 614d706
perf: add sharepoint integration
andhreljaKern d7c8d6b
perf: update integration objects
andhreljaKern 359187e
perf: expand IntegrationSharepoint
andhreljaKern 3f774d1
fix: integration.started_at
andhreljaKern 03169de
perf: integration data types
andhreljaKern 18990bb
perf: unique constraint names
andhreljaKern 25b039a
Reset finished at for new integrations
lumburovskalina aa4416e
perf: update integration objects
andhreljaKern 1093257
Merge branch 'cognition-integration-provider' of https://github.com/c…
andhreljaKern 40cbf2f
perf: add integration delta deletion
andhreljaKern ac935a0
Merge branch 'dev' into cognition-integration-provider
andhreljaKern 6b7bc0b
Merge branch 'dev' into cognition-integration-provider
andhreljaKern 515e01a
basic models
LennartSchmidtKern 6c6f4de
perf: last_synced_at integration column
andhreljaKern 5e52d26
Merge branch 'cognition-integration-provider' of https://github.com/c…
andhreljaKern c18a6eb
perf: add is_synced column
andhreljaKern d5afe9b
chore: add typing
andhreljaKern dc1e5e8
perf: add sync columns
andhreljaKern 5a35116
fix model
LennartSchmidtKern 00c46d6
perf: add get_all integrations
andhreljaKern 08e04a6
chore: add todo comment
andhreljaKern d0d5bd3
Merge remote-tracking branch 'origin/dev' into access-management
LennartSchmidtKern 299a4aa
permission test
LennartSchmidtKern 995612b
projects with access management
LennartSchmidtKern fad5cc4
perf: add sharepoint db bo
andhreljaKern 264d0fe
deactivate mock up
LennartSchmidtKern f8db2cf
get by user id
LennartSchmidtKern 2b86f5e
enable list payload
LennartSchmidtKern 19768dd
perf: integration update
andhreljaKern 7231952
perf: tech discussion feedback
andhreljaKern 91fe108
merge integration
LennartSchmidtKern 7e88d90
perf: get integrations updates
andhreljaKern 57bfe5d
perf: integration updates
andhreljaKern 1fd2127
Merge branch 'cognition-integration-provider' of https://github.com/c…
LennartSchmidtKern c67bae4
perf: introduce managers
andhreljaKern 0373a58
chore: typing
andhreljaKern 0bdebd5
perf: access + check for updates
andhreljaKern ffa35bf
perf: update integration
andhreljaKern 342b221
perf: add delta url to sharepoint integration
andhreljaKern c9f4791
fix: move delta_url to cognitionintegration
andhreljaKern 02ad8cc
perf: integration updates
andhreljaKern 7c023ee
perf: add updated_by + delta_criteria
andhreljaKern 9db6027
Merge remote-tracking branch 'origin/cognition-integration-provider' …
LennartSchmidtKern 5969ab9
perf: add delta_criteria field
andhreljaKern a6f6ba2
perf: check for status improvement
andhreljaKern 789e79e
Merge remote-tracking branch 'origin/cognition-integration-provider' …
LennartSchmidtKern 32e689f
add meta_data group
LennartSchmidtKern 4cd9462
format
LennartSchmidtKern 3009ba7
Merge branch 'access-management' of https://github.com/code-kern-ai/r…
LennartSchmidtKern 926fc4c
model
LennartSchmidtKern 06b4fbd
Merge branch 'access-management' of github.com:code-kern-ai/refinery-…
LennartSchmidtKern 5bbdf87
sync action
LennartSchmidtKern 9f61c3c
rename action
LennartSchmidtKern b9ad6b6
perf: dynamic 'by' record grouping
andhreljaKern 2e769dd
style: arguments newlines in function definitions
andhreljaKern 419811b
new getters
LennartSchmidtKern 21a3234
Merge remote-tracking branch 'origin/cognition-integration-provider' …
LennartSchmidtKern a20ea01
delete groups
LennartSchmidtKern 93bfb51
Merge branch 'access-management' of github.com:code-kern-ai/refinery-…
LennartSchmidtKern 09b63b5
fix: rm get project by name and org id
andhreljaKern 0822467
perf: pr review comments
andhreljaKern 24954fd
Merge branch 'cognition-integration-provider' of https://github.com/c…
andhreljaKern 39b710f
perf: pr review comments
andhreljaKern 5ffe2bf
fix: paginated query
andhreljaKern be01221
perf: update integrations model
andhreljaKern 4807248
Merge branch 'cognition-integration-provider' of https://github.com/c…
andhreljaKern bfe2e28
chore: merge dev into cognition-integration-provider
andhreljaKern c389dc6
perf: update to_snake_case regex compilation
andhreljaKern 4243fd5
Merge branch 'cognition-integration-provider' of github.com:code-kern…
andhreljaKern 44f58c3
chore: resolve merge conflict
andhreljaKern 2c35db6
Merge branch 'cognition-integration-provider' of github.com:code-kern…
andhreljaKern 0be3fc5
access management
LennartSchmidtKern f1b40eb
perf: db model update
andhreljaKern 744ee36
perf: pr comments
andhreljaKern c1ae061
perf: remove unnecessary checks
andhreljaKern 88caad0
fix: nullable error message
andhreljaKern 4fa69bc
perf: pr comments
andhreljaKern f44b56d
merge
LennartSchmidtKern 74008a9
delete
LennartSchmidtKern 3020f36
perf: move IntegrationMetadata enum to integration_objects.helper
andhreljaKern cdb143e
Merge branch 'access-management' of github.com:code-kern-ai/refinery-…
andhreljaKern a0420da
chore: resolve merge conflicts
andhreljaKern 2fe5e2d
Oidc field in the users table (#170)
lumburovskalina 9a7026f
fix: metadata helper function
andhreljaKern 2a4899f
perf: update integration task type name
andhreljaKern d57104e
style: formatting
andhreljaKern db484cf
perf: pr review comments
andhreljaKern 42b09fd
perf: add REFINERY_ATTRIBUTE_ACCESS constants
andhreljaKern e0d1fb4
fix: query builder for record_ids
andhreljaKern fafeccd
perf: monitor.set_integration_task_to_failed with state
andhreljaKern 90ac0d5
Merge branch 'cognition-integration-provider' of github.com:code-kern…
andhreljaKern 535e992
perf: add early exit for deleted integrations
andhreljaKern ab273ca
perf: add early exit for task execution
andhreljaKern cf5cdd8
Merge branch 'cognition-integration-provider' of https://github.com/c…
andhreljaKern 209fa94
sharepoint active queue
LennartSchmidtKern 5004048
unique by name and integration
LennartSchmidtKern 1ae14b5
typing
LennartSchmidtKern 4d81dff
improve sql
LennartSchmidtKern 91cdd20
merge
LennartSchmidtKern 36a48c7
model
LennartSchmidtKern 5ef1483
fix group
LennartSchmidtKern c9ea2e2
Merge branch 'dev' into cognition-integration-provider
andhreljaKern e38a007
remove unique
LennartSchmidtKern 71c9603
perf: add file_properties integration column
andhreljaKern 602baf9
perf: update default state for set_integration_task_to_failed
andhreljaKern 6d5ed14
chore: resolve conflict
andhreljaKern 06ffea3
chore: resolve conflicts
andhreljaKern 06f7509
Adds option filter for pid
JWittmeyer 9c2f2a1
PR comments
JWittmeyer 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
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
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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
from datetime import datetime | ||
from typing import List, Optional | ||
from ..business_objects import general | ||
from ..session import session | ||
from ..models import CognitionGroup | ||
|
||
|
||
def get(group_id: str) -> CognitionGroup: | ||
return session.query(CognitionGroup).filter(CognitionGroup.id == group_id).first() | ||
|
||
|
||
def get_with_organization_id(organization_id: str, group_id: str) -> CognitionGroup: | ||
return ( | ||
session.query(CognitionGroup) | ||
.filter( | ||
CognitionGroup.organization_id == organization_id, | ||
CognitionGroup.id == group_id, | ||
) | ||
.first() | ||
) | ||
|
||
|
||
def get_all(organization_id: str) -> List[CognitionGroup]: | ||
return ( | ||
session.query(CognitionGroup) | ||
.filter(CognitionGroup.organization_id == organization_id) | ||
.order_by(CognitionGroup.name.asc()) | ||
.all() | ||
) | ||
|
||
|
||
def get_all_by_integration_id( | ||
organization_id: str, integration_id: str | ||
) -> List[CognitionGroup]: | ||
integration_id_json = CognitionGroup.meta_data.op("->>")("integration_id") | ||
|
||
return ( | ||
session.query(CognitionGroup) | ||
.filter( | ||
CognitionGroup.organization_id == organization_id, | ||
integration_id_json == integration_id, | ||
) | ||
.order_by(CognitionGroup.name.asc()) | ||
.all() | ||
) | ||
|
||
|
||
def get_all_by_integration_id_permission_grouped( | ||
organization_id: str, integration_id: str | ||
) -> List[CognitionGroup]: | ||
integration_id_json = CognitionGroup.meta_data.op("->>")("integration_id") | ||
|
||
integration_groups = ( | ||
session.query(CognitionGroup) | ||
.filter( | ||
CognitionGroup.organization_id == organization_id, | ||
integration_id_json == integration_id, | ||
) | ||
.all() | ||
) | ||
integration_groups_by_permission = {} | ||
for group in integration_groups: | ||
permission_id = group.meta_data.get("permission_id") | ||
integration_groups_by_permission[permission_id] = group | ||
JWittmeyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return integration_groups_by_permission | ||
|
||
|
||
def get_by_name(organization_id: str, name: str): | ||
LennartSchmidtKern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
session.query(CognitionGroup) | ||
.filter( | ||
CognitionGroup.organization_id == organization_id, | ||
CognitionGroup.name == name, | ||
) | ||
.first() | ||
) | ||
|
||
|
||
def create_group( | ||
organization_id: str, | ||
name: str, | ||
description: str, | ||
created_by: str, | ||
created_at: Optional[datetime] = None, | ||
with_commit: bool = True, | ||
meta_data: Optional[dict] = None, | ||
) -> CognitionGroup: | ||
group = CognitionGroup( | ||
organization_id=organization_id, | ||
name=name, | ||
description=description, | ||
created_by=created_by, | ||
created_at=created_at, | ||
meta_data=meta_data, | ||
) | ||
general.add(group, with_commit) | ||
return group | ||
|
||
|
||
def update_group( | ||
group_id: str, | ||
name: Optional[str] = None, | ||
description: Optional[str] = None, | ||
with_commit: bool = True, | ||
meta_data: Optional[dict] = None, | ||
) -> CognitionGroup: | ||
group = get(group_id) | ||
|
||
if name is not None: | ||
group.name = name | ||
if description is not None: | ||
group.description = description | ||
if meta_data is not None: | ||
group.meta_data = meta_data | ||
general.flush_or_commit(with_commit) | ||
|
||
return group | ||
|
||
|
||
def delete(organization_id: str, group_id: str, with_commit: bool = True) -> None: | ||
group = get_with_organization_id(organization_id, group_id) | ||
if group: | ||
general.delete(group, with_commit) |
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from datetime import datetime | ||
from typing import Optional | ||
from ..business_objects import general, user | ||
from . import group | ||
from ..session import session | ||
from ..models import CognitionGroupMember | ||
|
||
|
||
def get(group_id: str, id: str): | ||
LennartSchmidtKern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
session.query(CognitionGroupMember) | ||
.filter( | ||
CognitionGroupMember.group_id == group_id, CognitionGroupMember.id == id | ||
) | ||
.first() | ||
) | ||
|
||
|
||
def get_by_group_and_user(group_id: str, user_id: str) -> CognitionGroupMember: | ||
return ( | ||
session.query(CognitionGroupMember) | ||
.filter( | ||
CognitionGroupMember.group_id == group_id, | ||
CognitionGroupMember.user_id == user_id, | ||
) | ||
.first() | ||
) | ||
|
||
|
||
def get_by_user_id(user_id: str) -> list: | ||
LennartSchmidtKern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
session.query(CognitionGroupMember) | ||
.filter(CognitionGroupMember.user_id == user_id) | ||
.all() | ||
) | ||
|
||
|
||
def get_all_by_group(group_id: str) -> list: | ||
LennartSchmidtKern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
session.query(CognitionGroupMember) | ||
.filter(CognitionGroupMember.group_id == group_id) | ||
.all() | ||
) | ||
|
||
|
||
def get_all_by_group_count(group_id: str) -> int: | ||
return ( | ||
session.query(CognitionGroupMember) | ||
.filter(CognitionGroupMember.group_id == group_id) | ||
.count() | ||
) | ||
|
||
|
||
def create( | ||
group_id: str, | ||
user_id: str, | ||
created_at: Optional[datetime] = None, | ||
with_commit: bool = True, | ||
) -> CognitionGroupMember: | ||
already_exist = get_by_group_and_user(group_id=group_id, user_id=user_id) | ||
if already_exist: | ||
return already_exist | ||
|
||
group_item = group.get(group_id) | ||
user_item = user.get(user_id) | ||
if not group_item or not user_item: | ||
raise Exception("Group or user not found") | ||
if group_item.organization_id != user_item.organization_id: | ||
raise Exception("User not in the same organization as the group") | ||
|
||
group_member = CognitionGroupMember( | ||
group_id=group_id, | ||
user_id=user_id, | ||
created_at=created_at, | ||
) | ||
general.add(group_member, with_commit) | ||
return group_member | ||
|
||
|
||
def delete_by_group_and_user_id( | ||
group_id: str, user_id: str, with_commit: bool = True | ||
) -> None: | ||
group_member = get_by_group_and_user(group_id, user_id) | ||
if group_member: | ||
general.delete(group_member, with_commit) | ||
|
||
|
||
def delete_by_user_id(user_id: str, with_commit: bool = True) -> None: | ||
group_memberships = ( | ||
session.query(CognitionGroupMember) | ||
.filter(CognitionGroupMember.user_id == user_id) | ||
.all() | ||
) | ||
for membership in group_memberships: | ||
general.delete(membership, with_commit=False) | ||
general.flush_or_commit(with_commit) | ||
|
||
|
||
def clear_by_group_id(group_id: str, with_commit: bool = True) -> None: | ||
group_memberships = get_all_by_group(group_id) | ||
for membership in group_memberships: | ||
general.delete(membership, with_commit=False) | ||
general.flush_or_commit(with_commit) |
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.
Uh oh!
There was an error while loading. Please reload this page.