updated Identity and managment service
This commit is contained in:
@@ -1,53 +1,75 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import Users
|
||||
from Schemas import (
|
||||
Applications,
|
||||
Application2Employee,
|
||||
Application2Occupant,
|
||||
)
|
||||
|
||||
|
||||
# List endpoint
|
||||
SuperUsersListEvent = Event(
|
||||
name="supers_users_list",
|
||||
key="341b394f-9f11-4abb-99e7-4b27fa6bf012",
|
||||
ApplicationListEvent = Event(
|
||||
name="application_list",
|
||||
key="b4efda1e-bde7-4659-ab1a-ef74c0fd88b6",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of users endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
SuperUsersCreateEvent = Event(
|
||||
name="supers_users_create",
|
||||
key="4e7e189e-e015-4ff8-902d-60138cbc77a6",
|
||||
ApplicationCreateEvent = Event(
|
||||
name="application_create",
|
||||
key="f53ca9aa-5536-4d77-9129-78d67e61db4a",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of users endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
SuperUsersUpdateEvent = Event(
|
||||
name="supers_users_update",
|
||||
key="efa4aa4a-d414-4391-91ee-97eb617b7755",
|
||||
ApplicationUpdateEvent = Event(
|
||||
name="application_update",
|
||||
key="0e9a855e-4e69-44b5-8ac2-825daa32840c",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of users endpoint",
|
||||
)
|
||||
|
||||
#Bind Application to employee
|
||||
ApplicationBindEmployeeEvent = Event(
|
||||
name="application_bind_employee",
|
||||
key="26a96c2d-bca8-41cb-8ac1-f3ca8124434b",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
)
|
||||
|
||||
def supers_users_list_callable(list_options: PaginateOnly):
|
||||
#Bind Application to occupant
|
||||
ApplicationBindOccupantEvent = Event(
|
||||
name="application_bind_occupant",
|
||||
key="4eaf2bb0-2a42-4d21-ae65-a9259ebee189",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
)
|
||||
|
||||
|
||||
def application_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with Users.new_session() as db_session:
|
||||
with Applications.new_session() as db_session:
|
||||
if list_options.query:
|
||||
users_list = Users.filter_all(
|
||||
*Users.convert(list_options.query), db=db_session
|
||||
applications_list = Applications.filter_all(
|
||||
*Applications.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
users_list = Users.filter_all(db=db_session)
|
||||
pagination = Pagination(data=users_list)
|
||||
applications_list = Applications.filter_all(db=db_session)
|
||||
pagination = Pagination(data=applications_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=users_list,
|
||||
data=applications_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
@@ -57,10 +79,10 @@ def supers_users_list_callable(list_options: PaginateOnly):
|
||||
).response
|
||||
|
||||
|
||||
SuperUsersListEvent.event_callable = supers_users_list_callable
|
||||
ApplicationListEvent.event_callable = application_list_callable
|
||||
|
||||
|
||||
def supers_users_create_callable():
|
||||
def application_create_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
@@ -74,10 +96,10 @@ def supers_users_create_callable():
|
||||
}
|
||||
|
||||
|
||||
SuperUsersCreateEvent.event_callable = supers_users_create_callable
|
||||
ApplicationCreateEvent.event_callable = application_create_callable
|
||||
|
||||
|
||||
def supers_users_update_callable():
|
||||
def application_update_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
@@ -91,4 +113,36 @@ def supers_users_update_callable():
|
||||
}
|
||||
|
||||
|
||||
SuperUsersUpdateEvent.event_callable = supers_users_update_callable
|
||||
ApplicationUpdateEvent.event_callable = application_update_callable
|
||||
|
||||
|
||||
def application_bind_employee_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
ApplicationBindEmployeeEvent.event_callable = application_bind_employee_callable
|
||||
|
||||
|
||||
def application_bind_occupant_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
ApplicationBindOccupantEvent.event_callable = application_bind_occupant_callable
|
||||
|
||||
Reference in New Issue
Block a user