Skip to content

Commit

Permalink
A lightweight user management kit definitions (#84)
Browse files Browse the repository at this point in the history
* A lightweight user management kit definitions
  • Loading branch information
sz2376 authored Sep 21, 2024
1 parent 04ed43e commit 8399c8c
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 46 deletions.
7 changes: 7 additions & 0 deletions flux_sdk/flux_core/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,11 @@ class TerminationType(Enum):
OFFER_DECLINE = 5
RESCIND = 6
RENEGE = 7


class AppDisconnectedError(Exception):
"""
This exception is raised when the app is disconnected from the third-party system.
"""
pass

35 changes: 0 additions & 35 deletions flux_sdk/user_management/api/base_api.py

This file was deleted.

File renamed without changes.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from abc import ABC, abstractmethod

from flux_sdk.user_management.data_models.data_models import (
GetOrganizationsRequest,
GetOrganizationsResponse,
GetUsersRequest,
GetUsersResponse,
)


class UserLifecycleManagement(ABC):
"""
This class represents the "user_lifecycle_management" capability.
This capability is used to manage the lifecycle of users in the third-party system with supports including:
- Getting user's organizations from the third-party system
- Getting users from the third-party system
"""

@abstractmethod
def get_users(self, request: GetUsersRequest) -> GetUsersResponse:
"""
A function that get users from the third-party system.
Use this hook fetch users from the third-party system so that they can be matched with employees in Rippling.
:param request: The request to get users from the third-party system. This request may contain the
organizations to get users from.
:return: The response containing the users from the third-party system.
"""


@abstractmethod
def get_organizations(self, request: GetOrganizationsRequest) -> GetOrganizationsResponse:
"""
A function that get organizations from the third-party system.
Use this hook to fetch organizations from the third-party system so that the organization information can be
used to get users from the third-party system.
:param request: The request to get organizations from the third-party system.
:return: The response containing the organizations from the third-party system.
"""
11 changes: 0 additions & 11 deletions flux_sdk/user_management/data_models/base_types.py

This file was deleted.

71 changes: 71 additions & 0 deletions flux_sdk/user_management/data_models/data_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from dataclasses import dataclass
from typing import Optional


@dataclass(kw_only=True)
class Organization:
"""
This represents an organization in the third party system.
An organization is used to group users in the third party system.
Different third party systems may have different names of organizations:
Github calls it "Organization", while Google Workspace calls it "Domain".
"""

id: str
"""The unique identifier of the organization in the third party system."""

name: Optional[str] = None
"""The name of the organization in the third party system."""


@dataclass(kw_only=True)
class User:
"""This represents a user in the third party system."""

id: Optional[str] = None
"""The unique identifier of the user in the third party system.
This field is required when getting users from the third party system."""

first_name: Optional[str] = None
"""The first name of the user."""

middle_name: Optional[str] = None
"""The middle name of the user."""

last_name: Optional[str] = None
"""The last name of the user."""

email: Optional[str] = None
"""The email address of the user."""


@dataclass(kw_only=True)
class GetUsersRequest:
"""This represents a request to get users from the third party system."""

organizations: Optional[list[Organization]] = None
"""The organizations to get users from. If this field is not provided,
the users from all organizations should be returned."""


@dataclass(kw_only=True)
class GetUsersResponse:
"""This represents a response containing the users from the third party system."""

users: list[User]
"""The users from the third party system."""


@dataclass(kw_only=True)
class GetOrganizationsRequest:
"""This represents a request to get organizations from the third party system."""

pass


@dataclass(kw_only=True)
class GetOrganizationsResponse:
"""This represents a response containing the organizations from the third party system."""

organizations: list[Organization]
"""The organizations from the third party system."""

0 comments on commit 8399c8c

Please sign in to comment.