def do_amend_organization(args, config):
    """
    Amends the state associating with the UUID in the
    Transaction Family : Organization
    
    Args:
        args (ArgumentParser):
            ArgumentParser object containing required parameters
        config (ConfigParser): ConfigParser which contains the default url
        
    Returns:
        type: str
        String representing JSON object which allows the client to know that
        the call was either a success or a failure.
    
    """
    org_id = args.org_id
    org_alias = args.alias
    org_name = args.name
    org_type = args.type
    description = args.description
    org_url = args.url
    private_key = args.private_key
    public_key = args.public_key

    payload = "{}"
    key = json.loads(payload)
    key["publickey"] = public_key
    key["privatekey"] = private_key
    key["allowedrole"] = [{"role": "admin"}, {"role": "member"}]
    payload = json.dumps(key)

    headers = {"content-type": "application/json"}
    response = requests.post("http://127.0.0.1:818/api/sparts/ledger/auth",
                             data=json.dumps(key),
                             headers=headers)
    output = response.content.decode("utf-8").strip()
    statusinfo = json.loads(output)

    if statusinfo.get("status") and statusinfo.get("message"):

        status = statusinfo["status"]
        message = statusinfo["message"]

        if status == "success" and message == "authorized":
            b_url = config.get("DEFAULT", "url")
            client = OrganizationBatch(base_url=b_url)
            response = client.amend_organization(org_id, org_alias, org_name,
                                                 org_type, description,
                                                 org_url, private_key,
                                                 public_key)

            print_msg(response, "amend")
        else:
            print(output)
    else:
        print(output)
def api_do_amend_organization(args, config):
    """
    API version of "do_amend_organization" function.
    """
    param_check = _payload_check_(args)

    if param_check[0]:
        return ret_msg("failed", param_check[1], "EmptyRecord", "{}")

    org_id = args["organization"]["uuid"]

    org_alias = _null_cast(args["organization"], "alias")
    org_name = _null_cast(args["organization"], "name")
    org_type = _null_cast(args["organization"], "type")
    description = _null_cast(args["organization"], "description")
    org_url = _null_cast(args["organization"], "url")

    private_key = args["private_key"]
    public_key = args["public_key"]

    payload = "{}"
    key = json.loads(payload)
    key["publickey"] = public_key
    key["privatekey"] = private_key
    key["allowedrole"] = [{"role": "admin"}, {"role": "member"}]
    payload = json.dumps(key)

    headers = {"content-type": "application/json"}
    response = requests.post("http://127.0.0.1:818/api/sparts/ledger/auth",
                             data=json.dumps(key),
                             headers=headers)
    output = response.content.decode("utf-8").strip()
    statusinfo = json.loads(output)

    if statusinfo.get("status") and statusinfo.get("message"):

        status = statusinfo["status"]
        message = statusinfo["message"]

        if status == "success" and message == "authorized":

            b_url = config.get("DEFAULT", "url")
            client = OrganizationBatch(base_url=b_url)
            response = client.amend_organization(org_id, org_alias, org_name,
                                                 org_type, description,
                                                 org_url, private_key,
                                                 public_key)

            return print_msg(response, "amend")
        else:
            return output
    else:
        return output