コード例 #1
0
def get_properties(application_name, platform_name, path, timestamp, export):
    params = {}
    params["path"] = path
    if timestamp:
        params["timestamp"] = "timestamp"
    response = Client().get(
        "/rest/applications/"
        + application_name
        + "/platforms/"
        + platform_name
        + "/properties",
        params=params,
    )
    if export:
        _export(response.json()["key_value_properties"])
    else:
        utils.pretty_print(response)
コード例 #2
0
def _get_module_keys(
    application_name,
    platform_name,
    path=None,
    module_name=None,
    module_version=None,
    working_copy=None,
    instance_name=None,
):
    if path and module_name and module_version and working_copy is not None:
        return [{
            "path": path,
            "module_name": module_name,
            "module_version": module_version,
            "working_copy": working_copy,
            "instance_name": instance_name,
        }]
    response = Client().get("/rest/applications/" + application_name +
                            "/platforms/" + platform_name)
    response.raise_for_status()
    module_keys = []
    for module in response.json()["modules"]:
        module_keys.append({
            "path":
            module["path"],
            "module_name":
            module["name"],
            "module_version":
            module["version"],
            "working_copy":
            module["working_copy"],
            "instances":
            [m["name"]
             for m in module["instances"]],  # only needed for filtering below
        })
    if path:
        module_keys = list(filter(lambda key: key["path"] == path,
                                  module_keys))
    if module_name:
        module_keys = list(
            filter(lambda key: key["module_name"] == module_name, module_keys))
    if module_version:
        module_keys = list(
            filter(lambda key: key["module_version"] == module_version,
                   module_keys))
    if working_copy is not None:
        module_keys = list(
            filter(lambda key: key["working_copy"] == working_copy,
                   module_keys))
    if instance_name:
        module_keys = list(
            filter(lambda key: instance_name in key["instances"], module_keys))
        if module_keys:  # else error management will be performed below
            assert len(module_keys) == 1
            module_keys[0]["instance_name"] = instance_name
    if not module_keys:
        raise click.BadParameter(
            "Zero matching module(s) found given the --path / --module-name / --module-version / --working-copy / --release / --instance-name options provided"
        )
    for module_key in module_keys:
        del module_key[
            "instances"]  # should not be exposed outside this function
    return module_keys