Skip to content

add missing scheme entry types #553

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 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions ydb/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class SchemeEntryType(enum.IntEnum):
SEQUENCE = 15
REPLICATION = 16
TOPIC = 17
EXTERNAL_TABLE = 18
EXTERNAL_DATA_SOURCE = 19
VIEW = 20
RESOURCE_POOL = 21

@classmethod
def _missing_(cls, value):
Expand Down Expand Up @@ -103,6 +107,38 @@ def is_directory_or_database(entry):
"""
return entry == SchemeEntryType.DATABASE or entry == SchemeEntryType.DIRECTORY

@staticmethod
def is_external_table(entry):
"""
:param entry: A scheme entry to check
:return: True if scheme entry is an external table and False otherwise
"""
return entry == SchemeEntryType.EXTERNAL_TABLE

@staticmethod
def is_external_data_source(entry):
"""
:param entry: A scheme entry to check
:return: True if scheme entry is an external data source and False otherwise
"""
return entry == SchemeEntryType.EXTERNAL_DATA_SOURCE

@staticmethod
def is_external_view(entry):
"""
:param entry: A scheme entry to check
:return: True if scheme entry is a view and False otherwise
"""
return entry == SchemeEntryType.VIEW

@staticmethod
def is_external_resource_pool(entry):
"""
:param entry: A scheme entry to check
:return: True if scheme entry is a resource pool and False otherwise
"""
return entry == SchemeEntryType.RESOURCE_POOL


class SchemeEntry(object):
__slots__ = (
Expand Down Expand Up @@ -185,6 +221,30 @@ def is_coordination_node(self):
"""
return SchemeEntryType.is_coordination_node(self.type)

def is_external_table(self):
"""
:return: True if scheme entry is an external table and False otherwise
"""
return SchemeEntryType.is_external_table(self.type)

def is_external_data_source(self):
"""
:return: True if scheme entry is an external data source and False otherwise
"""
return SchemeEntryType.is_external_data_source(self.type)

def is_view(self):
"""
:return: True if scheme entry is a view and False otherwise
"""
return SchemeEntryType.is_view(self.type)

def is_resource_pool(self):
"""
:return: True if scheme entry is a resource pool and False otherwise
"""
return SchemeEntryType.is_resource_pool(self.type)


class Directory(SchemeEntry):
__slots__ = ("children",)
Expand Down
Loading