Skip to content

Commit 6db21a0

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
varlink: add endpoint.py defining the endpoint type
Signed-off-by: John Mulligan <[email protected]>
1 parent 918ff96 commit 6db21a0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

sambacc/varlink/endpoint.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#
2+
# sambacc: a samba container configuration tool (and more)
3+
# Copyright (C) 2025 John Mulligan
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>
17+
#
18+
19+
20+
import typing
21+
22+
23+
class VarlinkEndpoint:
24+
"""The sambacc VarlinkEndpoint classes are used to connect the varlink
25+
server to the backend logic. It must provide the varlink interface as well
26+
as the implementation class and that class's (keyword) arguments.
27+
"""
28+
29+
location: str = "sambacc.varlink.interfaces"
30+
interface_filename: str = ""
31+
interface_name: str = ""
32+
interface_cls: typing.Type
33+
interface_kwargs: dict
34+
35+
def __init__(
36+
self,
37+
*,
38+
location: str = "",
39+
interface_filename: str = "",
40+
interface_name: str = "",
41+
interface_cls: typing.Optional[typing.Type] = None,
42+
interface_kwargs: typing.Optional[dict] = None,
43+
) -> None:
44+
if location:
45+
self.location = location
46+
if interface_filename:
47+
self.interface_filename = interface_filename
48+
if interface_name:
49+
self.interface_name = interface_name
50+
if interface_cls:
51+
self.interface_cls = interface_cls
52+
else:
53+
raise ValueError("an interface class is required")
54+
if interface_kwargs:
55+
self.interface_kwargs = interface_kwargs
56+
else:
57+
self.interface_kwargs = {}

0 commit comments

Comments
 (0)