Example #1
0
  public Records getRecords(
      String table_name,
      String ids,
      String filter,
      Integer limit,
      Integer offset,
      String order,
      String fields,
      String related,
      Boolean include_count,
      Boolean include_schema,
      String id_field)
      throws ApiException {
    // verify required params are set
    if (table_name == null) {
      throw new ApiException(400, "missing required params");
    }
    // create path and map variables
    String path =
        "/db/{table_name}"
            .replaceAll("\\{format\\}", "json")
            .replaceAll(
                "\\{" + "table_name" + "\\}", apiInvoker.escapeString(table_name.toString()));

    // query params
    Map<String, String> queryParams = new HashMap<String, String>();
    Map<String, String> headerParams = new HashMap<String, String>();

    if (!"null".equals(String.valueOf(ids))) queryParams.put("ids", String.valueOf(ids));
    if (!"null".equals(String.valueOf(filter))) queryParams.put("filter", String.valueOf(filter));
    if (!"null".equals(String.valueOf(limit))) queryParams.put("limit", String.valueOf(limit));
    if (!"null".equals(String.valueOf(offset))) queryParams.put("offset", String.valueOf(offset));
    if (!"null".equals(String.valueOf(order))) queryParams.put("order", String.valueOf(order));
    if (!"null".equals(String.valueOf(fields))) queryParams.put("fields", String.valueOf(fields));
    if (!"null".equals(String.valueOf(related)))
      queryParams.put("related", String.valueOf(related));
    if (!"null".equals(String.valueOf(include_count)))
      queryParams.put("include_count", String.valueOf(include_count));
    if (!"null".equals(String.valueOf(include_schema)))
      queryParams.put("include_schema", String.valueOf(include_schema));
    if (!"null".equals(String.valueOf(id_field)))
      queryParams.put("id_field", String.valueOf(id_field));
    String contentType = "application/json";

    try {
      String response =
          apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
      if (response != null) {
        return (Records) ApiInvoker.deserialize(response, "", Records.class);
      } else {
        return null;
      }
    } catch (ApiException ex) {
      if (ex.getCode() == 404) {
        return null;
      } else {
        throw ex;
      }
    }
  }
Example #2
0
  public Record deleteRecord(
      String table_name, String id, String id_field, String fields, String related)
      throws ApiException {
    // verify required params are set
    if (table_name == null || id == null) {
      throw new ApiException(400, "missing required params");
    }
    // create path and map variables
    String path =
        "/db/{table_name}/{id}"
            .replaceAll("\\{format\\}", "json")
            .replaceAll(
                "\\{" + "table_name" + "\\}", apiInvoker.escapeString(table_name.toString()))
            .replaceAll("\\{" + "id" + "\\}", apiInvoker.escapeString(id.toString()));

    // query params
    Map<String, String> queryParams = new HashMap<String, String>();
    Map<String, String> headerParams = new HashMap<String, String>();

    if (!"null".equals(String.valueOf(id_field)))
      queryParams.put("id_field", String.valueOf(id_field));
    if (!"null".equals(String.valueOf(fields))) queryParams.put("fields", String.valueOf(fields));
    if (!"null".equals(String.valueOf(related)))
      queryParams.put("related", String.valueOf(related));
    String contentType = "application/json";

    try {
      String response =
          apiInvoker.invokeAPI(
              basePath, path, "DELETE", queryParams, null, headerParams, contentType);
      if (response != null) {
        return (Record) ApiInvoker.deserialize(response, "", Record.class);
      } else {
        return null;
      }
    } catch (ApiException ex) {
      if (ex.getCode() == 404) {
        return null;
      } else {
        throw ex;
      }
    }
  }