base
PermissionGraphBackend
Bases: ABC
Base class for PermissionGraph interface.
Source code in src/permission_graph/backends/base.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
add_edge(etype, source, target, **kwargs)
abstractmethod
Add a edge to the permission graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
etype |
str
|
edge type (one of 'member_of', 'allow', 'deny') |
required |
source |
Vertex
|
source vertex |
required |
target |
Vertex
|
target vertex |
required |
**kwargs |
Any
|
addition attributes to add to edge |
{}
|
Raises ValueError if an edge from source to target already exists.
Source code in src/permission_graph/backends/base.py
37 38 39 40 41 42 43 44 45 46 47 48 |
|
add_vertex(vertex, **kwargs)
abstractmethod
Add a vertex to the permission graph.
Raises ValueError if vertex already exists.
Source code in src/permission_graph/backends/base.py
10 11 12 13 14 15 |
|
edge_exists(source, target)
abstractmethod
Return True if edge exists.
Source code in src/permission_graph/backends/base.py
50 51 52 |
|
get_edge_type(source, target)
abstractmethod
Return the EdgeType of the edge connecting two vertices.
Raises ValueError if there is no edge between the two vertices.
Source code in src/permission_graph/backends/base.py
69 70 71 72 73 74 |
|
get_vertices_from(vertex)
abstractmethod
Get all vertices that a vertex targets.
Source code in src/permission_graph/backends/base.py
29 30 31 |
|
get_vertices_to(vertex)
abstractmethod
Get all vertices that target a vertex.
Source code in src/permission_graph/backends/base.py
25 26 27 |
|
remove_edge(source, target)
abstractmethod
Remove an edge from the permission graph.
Source code in src/permission_graph/backends/base.py
54 55 56 |
|
remove_vertex(vertex, **kwargs)
abstractmethod
Remove a vertex from the permission graph.
Source code in src/permission_graph/backends/base.py
17 18 19 |
|
shortest_paths(source, target)
abstractmethod
Return the lists of vertices that make the shortest paths from source to target.
Returns:
Type | Description |
---|---|
list[list[Vertex]]
|
|
list[list[Vertex]]
|
|
Source code in src/permission_graph/backends/base.py
58 59 60 61 62 63 64 65 66 67 |
|
update_vertex_attributes(vertex, **kwargs)
abstractmethod
Update one or more attributes of a vertex.
Source code in src/permission_graph/backends/base.py
33 34 35 |
|
vertex_exists(vertex)
abstractmethod
Check if a vertex with vtype=vtype and id=id already exists.
Source code in src/permission_graph/backends/base.py
21 22 23 |
|
vertex_factory(vertex_id)
abstractmethod
Return a vertex from a vertex id.
Given a vertex id, return an vertex object of the appropriate subclass.
Source code in src/permission_graph/backends/base.py
76 77 78 79 80 81 |
|