# wayfair-teams Create as many end-points as we believe is sensible and provide responses that are functionally equivalent to the old API. <br/> ## **Content** - [Models](#Models) - TeamModel - CommunicationChannelModel - EmployeeModel - [Endpoints](#Endpoints) - [Teams Metadata](#Teams-Metadata) - GET /teams - GET /teams/{team_id} - POST /teams - PATCH /teams/{team_id} - [Teams Membership](#Teams-Membership) - GET /teams/{team_id}/employees - POST /teams/{team_id}/employees - DELETE /teams/{team_id}/employees - GET /teams/{team_id}/admin(TBD) - PUT /teams/{team_id}/admin(TBD) - [Teams Hierarchy](#Teams-Hierarchy) - GET /teams/{team_id}/children - POST /teams/{team_id}/children - DELETE /teams/{team_id}/children - GET /teams/{team_id}/parent - [Logging](#Logging) <br/> ## **Models** **REQUEST** **RESPONSE** *ResponseTeamModel* ```json= { team_id: int, team_name: str, team_description: str, team_label: {label_id: int, label_name: str}, team_type: {type_id: int, type_name: str}, team_icon: {icon_id: int, icon_name: str}, team_keywords: List[], team_created: datetime, team_updated: datetime, team_archived:datetime, contacts: List[ContactModel], employees: Optional[List[EmployeeModel]], member_count: int } ``` TeamContactModel ```json= { type: str, identifier: str, labels: List[str] } ``` EmployeeModel ```json= { employee_id: int, employee_name: str, role_name: str, join_date: datetime } ``` <br/> ## Endpoints version 1.0 ### **Teams Metadata** ***Route: team*** ***GET /teams*** Get multiple teams metadata *Functional Equivalency:* 1. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v2/teams.py#L24 @endpoint.router.get("", tags=[TEAMS_TAG]) 2. https://github.csnzoo.com/shared/data-team-service/blob/d9b011658c34baf8d8a010916efb25f413b58ecb/components/fastapi_/endpoints/v1/team.py#L203 @endpoint.router.get("/check_team_name/{_team_name}", tags=[TEAM_TAG]) 3. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/teams.py#L37 @endpoint.router.get("/batch", tags=[TEAMS_TAG]) Parameters: * filters * team-ids: List[int] - semicolon delimited. For example: /teams?team-ids=1,2,3,4 * team-names: List[str] * team-type: str * team_created_before: str * team_created_after: str * sort: Optional[str] * offset: Optional[int] = 0 * limit: Optional[int] = 100 * fields: Optional[List[str]] = [] -- select the fields to be returned for each team, e.g. team_id, team_name, or team_description Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = List[TeamModel] ``` ***GET /teams/{team_id}*** Get the metadata of a specific team. Functional Equivalency: https://github.csnzoo.com/shared/data-team-service/blob/d9b011658c34baf8d8a010916efb25f413b58ecb/components/fastapi_/endpoints/v1/team.py#L82 @endpoint.router.get("/{team_id}", tags=[TEAM_TAG]) @endpoint.router.get("/name/{team_name}", tags=[TEAM_TAG]) Parameters: * Required: * team_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = TeamModel ``` ***POST /teams*** Create a new team with the provided metadata. *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/d9b011658c34baf8d8a010916efb25f413b58ecb/components/fastapi_/endpoints/v1/team.py#L219 @endpoint.router.post("/create_team", tags=[TEAM_TAG]) Request Body * Required: * team_name: str * team_label: int * team_type: int * Optional: * team_description: str * team_isactive: bool * team_created: datetime * communication_channels: ``` List[{ identifier: str, communication_mode: str, labels: List[str] }], ``` Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = TeamModel ``` ***PATCH /teams/{team_id}*** Update the metadata of an existing team. *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/d9b011658c34baf8d8a010916efb25f413b58ecb/components/fastapi_/endpoints/v1/team.py#L137 @endpoint.router.post("/edit_team", tags=[TEAM_TAG]) Parameters: * Required: * team_id: int Request Body * Optional: * team_label: int, * team_description: str * team_type: int * team_isactive: bool * team_icon: int * team_created: datetime * communication_channels: ``` List[{ identifier: str, communication_mode: str, labels: List[str] }], ``` Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = TeamModel ``` <br/> ### **Teams Membership** ***GET /teams/{team_id}/employees*** Get all employees of a specific team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L246 @endpoint.router.get("/{team_id}/employees", tags=[TEAM_MEMBER_TAG]) Parameters: * Required: * team_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = List[EmployeeModel] ``` ***POST /teams/{team_id}/employees*** Add one or multiple employees to a team *Functional Equivalency:* 1. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L347 @endpoint.router.post("/add_employee", tags=[TEAM_MEMBER_TAG]) 2. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L391 @endpoint.router.post("/batch_add_employees", tags=[TEAM_MEMBER_TAG]) Parameters: * Required: * team_id: int Request Body * employee_ids: List[int] Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = List[EmployeeModel] ``` ***DELETE /teams/{team_id}/employees*** Remove employees from a team *Functional Equivalency:* 1. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L446 @endpoint.router.post("/remove_employee", tags=[TEAM_MEMBER_TAG]) 2. https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L505 @endpoint.router.post("/batch_remove_employees", tags=[TEAM_MEMBER_TAG]) Parameters: * Required: * team_id: int Request Body * employee_ids: List[int] Response: ``` HTTP/1.1 200 OK ``` ***GET /employee/{employee_id}/member_of_team/{team_id}*** *Functional Equivalency* https://github.csnzoo.com/shared/data-team-service/blob/main/components/fastapi_/endpoints/v1/team.py#L292 @endpoint.router.get("/{team_id}/check_employee_in_team", tags=[USER_METADATA_TAG]) Parameters: * Required: * team_id: int * employee_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = Boolean ``` _______________________ ***GET /employee/{employee_id}/roles*** ----------------------- **ROLES/PERMISSIONS STUFF** -- TBD ***GET /teams/{team_id}/admin(TBD)*** Get the admin of a team > [name=Rita Linets] I think that we should generally have a set of end-points that expose roles/permissions. Something like: > GET /roles/<employee_id> etc.; > The problem of course is that it's hard to predict where the product team is headed. *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L313 @endpoint.router.get("/{team_id}/check_employee_is_admin", tags=[USER_METADATA_TAG]) Parameters: * Required: * team_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = EmployeeModel ``` ***PUT /teams/{team_id}/admin(TBD)*** Creat or update the admin of a team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team.py#L595 @endpoint.router.post("/edit_team_admin", tags=[TEAM_MEMBER_TAG]) Parameters: * Required: * team_id: int Request Body: * Required: * employee_id: str * employee_name: str Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = EmployeeModel -- is_team_admin = True ``` <br/> ### **Teams Hierarchy** ***GET /teams/{team_id}/children*** Get all children of a team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team_hierarchy.py#L32 @endpoint.router.get("/{team_id}/children", tags=[TEAM_HIERARCHY_TAG]) Parameters: * Required: * team_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = List[TeamModel] ``` ***POST /teams/{team_id}/children*** Add one or multiple children to a team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team_hierarchy.py#L111 @endpoint.router.post( "/{team_id}/add_parent/{parent_team_id}", tags=[TEAM_HIERARCHY_TAG] ) Parameters: * Required: * team_id: int Request Body: * team_id: List[int] Response: ``` HTTP/1.1 200 OK Content-Type: application/json // list of children Response = List[TeamModel] ``` ***DELETE /teams/{team_id}/children*** Remove one or multiple children of a team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team_hierarchy.py#L154 @endpoint.router.delete( "/{team_id}/remove_parent/{parent_team_id}", tags=[TEAM_HIERARCHY_TAG] ) Parameters: * Required: * team_id: int Request Body: * team_ids: List[int] Response: ``` HTTP/1.1 200 OK ``` ***GET /teams/{team_id}/parent*** Get the parent of a team *Functional Equivalency:* https://github.csnzoo.com/shared/data-team-service/blob/e00b5893d6752c1c840dae8424125d88dbc64152/components/fastapi_/endpoints/v1/team_hierarchy.py#L76 @endpoint.router.get("/{team_id}/parent", tags=[TEAM_HIERARCHY_TAG]) Parameters: * Required: * team_id: int Response: ``` HTTP/1.1 200 OK Content-Type: application/json Response = TeamModel ``` ## Logging Metrics: - _id - Timestamp - Username - Endpoint URI - Request Method - Payload - Response status - Response time - Error message Performance Monitoring(Grafana?): - Memory usage - CPU usage