.. option:: -l, --live
- Get current configuration JSON-schema directly from the running resolver.
+ Get configuration JSON-schema from the running resolver.
Requires connection to the management API.
.. option:: <file>
print(response)
sys.exit(1)
- print(f"status: {response.status}")
-
if self.operation == Operations.GET and self.file:
with open(self.file, "w") as f:
f.write(reformat(response.body, self.format))
return {}
def run(self, args: CommandArgs) -> None:
- url = f"{args.socket}/reload"
- response = request("POST", url)
- print(response)
+ response = request("POST", f"{args.socket}/reload")
if response.status != 200:
+ print(response)
sys.exit(1)
schema.add_argument(
"-l",
"--live",
- help="Get current configuration JSON-schema directly from the running resolver. Requires connection to the management API.",
+ help="Get configuration JSON-schema from the running resolver. Requires connection to the management API.",
action="store_true",
default=False,
)
def run(self, args: CommandArgs) -> None:
if self.live:
response = request("GET", f"{args.socket}/schema")
- if response.status == 200:
- schema = response.body
- else:
+ if response.status != 200:
print(response)
sys.exit(1)
+ schema = response.body
else:
schema = json.dumps(KresConfig.json_schema(), indent=4)
def __init__(self, namespace: argparse.Namespace) -> None:
super().__init__(namespace)
- def run(self, args: CommandArgs) -> None:
- url = f"{args.socket}/stop"
- response = request("POST", url)
- print(response)
-
- if response.status != 200:
- sys.exit(1)
-
- @staticmethod
- def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
- return {}
-
@staticmethod
def register_args_subparser(
subparser: "argparse._SubParsersAction[argparse.ArgumentParser]",
"stop", help="Tells the resolver to shutdown everthing. No process will run after this command."
)
return stop, StopCommand
+
+ def run(self, args: CommandArgs) -> None:
+ response = request("POST", f"{args.socket}/stop")
+
+ if response.status != 200:
+ print(response)
+ sys.exit(1)
+
+ @staticmethod
+ def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
+ return {}
with open(self.input_file, "r") as f:
data = f.read()
else:
- data = input("Type new configuration: ")
+ data = input("Type configuration to validate: ")
try:
KresConfig(try_to_parse(data))
- print("config is valid")
except (DataParsingError, DataValidationError) as e:
print(e)
sys.exit(1)