def do_retrieve(args, config): id = args.id b_url = config.get('DEFAULT', 'url') client = OrganizationBatch(base_url=b_url) data = client.retrieve_organization(id) if data is not None: data = filter_output(str(data)) output = ret_msg("success", "OK", "OrganizationRecord", data) print(output) else: raise OrganizationException("Organization not found: {}".format(id))
def do_retrieve_organization(args, config): """ Retrieves 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. Raises: OrganizationException: * If failed to retrieve the uuid """ all_flag = args.all range_flag = args.range org_id = args.org_id if range_flag != None: all_flag = True b_url = config.get("DEFAULT", "url") client = OrganizationBatch(base_url=b_url) data = client.retrieve_organization(org_id, all_flag, range_flag) if data is not None: if all_flag == False: output = ret_msg("success", "OK", "OrganizationRecord", data.decode()) else: output = ret_msg("success", "OK", "OrganizationRecord", data) print(output) else: raise OrganizationException( "Organization not found: {}".format(org_id))
def api_do_retrieve_organization(org_id, config, all_flag=False, range_flag=None): """ API version of "do_retrieve_organization" function. """ if range_flag != None: all_flag = True b_url = config.get("DEFAULT", "url") client = OrganizationBatch(base_url=b_url) data = client.retrieve_organization(org_id, all_flag, range_flag) if data is not None: if all_flag == False: output = ret_msg("success", "OK", "OrganizationRecord", data.decode()) else: if range_flag == None: output = ret_msg("success", "OK", "OrganizationRecord", data) else: if len(data) != 0: output = ret_msg("success", "OK", "OrganizationRecord", json.dumps(data[0])) else: output = ret_msg("success", "OK", "OrganizationRecord", "{}") return output else: return ret_msg( "failed", "OrganizationException : UUID {} does not exist." \ .format(org_id), "OrganizationRecord", "{}" )