Merge pull request #14 from negz/resulting

Add convenience functions for returning results
This commit is contained in:
Nic Cope 2023-11-21 18:20:10 -08:00 committed by GitHub
commit 09c6bb991e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 0 deletions

View File

@ -33,3 +33,33 @@ def to(
desired=req.desired,
context=req.context,
)
def normal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a normal result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_NORMAL,
message=message,
)
)
def warning(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a warning result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_WARNING,
message=message,
)
)
def fatal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a fatal result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_FATAL,
message=message,
)
)