Skip to content

Commit

Permalink
fixes #71, json output for marketplace blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
Balaji committed Jun 5, 2020
1 parent a61dea2 commit 397428d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions calm/dsl/cli/mpis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import uuid
import click
import sys
import json
from prettytable import PrettyTable

from calm.dsl.api import get_api_client, get_resource_api
Expand Down Expand Up @@ -346,18 +347,19 @@ def get_mpi_by_name_n_version(name, version, app_states=[], app_source=None):
return res


def describe_marketplace_item(name, version=None, app_source=None):
def describe_marketplace_item(name, out, version=None, app_source=None):
"""describes the marketplace blueprint related to marketplace item"""

describe_marketplace_bp(
name=name,
out=out,
version=version,
app_source=app_source,
app_state=MARKETPLACE_BLUEPRINT.STATES.PUBLISHED,
)


def describe_marketplace_bp(name, version=None, app_source=None, app_state=None):
def describe_marketplace_bp(name, out, version=None, app_source=None, app_state=None):
"""describes the marketplace blueprint"""

app_states = [app_state] if app_state else []
Expand All @@ -373,6 +375,12 @@ def describe_marketplace_bp(name, version=None, app_source=None, app_state=None)
name=name, version=version, app_states=app_states, app_source=app_source
)

if out == "json":
blueprint = bp["status"]["resources"]["app_blueprint_template"]
blueprint.pop("status", None)
click.echo(json.dumps(blueprint, indent=4, separators=(",", ": ")))
return

click.echo("\n----MarketPlace Blueprint Summary----\n")
click.echo(
"Name: "
Expand Down
24 changes: 20 additions & 4 deletions calm/dsl/cli/mpis_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def _get_marketplace_bps(name, quiet, app_family, app_states):

@describe.command("marketplace_item")
@click.argument("name")
@click.option(
"--out",
"-o",
"out",
type=click.Choice(["text", "json"]),
default="text",
help="output format",
)
@click.option("--version", "-v", default=None, help="Version of marketplace item")
@click.option(
"--source",
Expand All @@ -115,14 +123,22 @@ def _get_marketplace_bps(name, quiet, app_family, app_states):
type=click.Choice(APP_SOURCES),
help="App Source for marketplace item",
)
def _describe_marketplace_item(name, version, source):
def _describe_marketplace_item(name, out, version, source):
"""Describe a market place item"""

describe_marketplace_item(name=name, version=version, app_source=source)
describe_marketplace_item(name=name, out=out, version=version, app_source=source)


@describe.command("marketplace_bp")
@click.argument("name")
@click.option(
"--out",
"-o",
"out",
type=click.Choice(["text", "json"]),
default="text",
help="output format.",
)
@click.option("--version", "-v", default=None, help="Version of marketplace blueprint")
@click.option(
"--source",
Expand All @@ -138,11 +154,11 @@ def _describe_marketplace_item(name, version, source):
type=click.Choice(APP_STATES),
help="State of marketplace blueprint",
)
def _describe_marketplace_bp(name, version, source, app_state):
def _describe_marketplace_bp(name, out, version, source, app_state):
"""Describe a market place blueprint"""

describe_marketplace_bp(
name=name, version=version, app_source=source, app_state=app_state
name=name, out=out, version=version, app_source=source, app_state=app_state
)


Expand Down

0 comments on commit 397428d

Please sign in to comment.