Skip to content

Commit

Permalink
[Ops] Add get-outcome command.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarciani committed May 19, 2024
1 parent 3fec0da commit a4f69b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ops/src/yawa_ops/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from yawa_ops.commands.auth.login import login
from yawa_ops.commands.auth.logout import logout
from yawa_ops.commands.management import info, shutdown, health
from yawa_ops.commands.simple.get_outcome import get_outcome
from yawa_ops.commands.simple.get_greetings import get_greetings
from yawa_ops.config.metadata import NAME, VERSION
from yawa_ops.utils import guiutils, logutils
Expand Down Expand Up @@ -41,6 +42,7 @@ def main(ctx, debug=False):

# Simple
main.add_command(get_greetings)
main.add_command(get_outcome)


if __name__ == "__main__":
Expand Down
28 changes: 28 additions & 0 deletions ops/src/yawa_ops/commands/simple/get_outcome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import click
import yawac
from yawac.apis.tags.get_outcome_api import GetOutcomeApi
from yawa_ops.commands.base_command import BaseCommand
from yawa_ops.utils import logutils
from yawa_ops.utils.api import build_client, print_response

log = logutils.get_logger(__name__)


@click.command(help="Get Greetings.", cls=BaseCommand)
@click.pass_context
@click.option(
"--outcome",
required=True,
help="Outcome.",
)
def get_outcome(ctx, endpoint, profile, verify_ssl, ca_file, debug, outcome):
with build_client(**ctx.obj.get("CLIENT_CONFIG")) as api_client:
try:
response = GetOutcomeApi(api_client).get_outcome(
query_params={
"outcome": outcome,
}
)
print_response(response)
except yawac.ApiException as e:
log.error("Request failed:\n%s" % e)

0 comments on commit a4f69b3

Please sign in to comment.