Title
#lakefs-for-beginners
o

Omkar Patil

09/29/2022, 11:35 AM
Hello Everyone!! Can someone guide me how we can consume the LakeFS API in Java!!! Any help is appreciated
Barak Amar

Barak Amar

09/29/2022, 11:38 AM
One of the SDK we publish with lakeFS is for Java - https://search.maven.org/artifact/io.lakefs/api-client
11:39 AM
Here you can find the source as part of lakeFS and with the help of github it will also render the documentation - https://github.com/treeverse/lakeFS/tree/master/clients/java
11:43 AM
package lakefs;

import io.lakefs.clients.api.ApiException;
import io.lakefs.clients.api.model.CommitList;
import io.lakefs.clients.api.model.DiffList;
import io.lakefs.clients.api.model.Error;
import io.lakefs.clients.api.model.Merge;
import io.lakefs.clients.api.model.MergeResult;
import io.lakefs.clients.api.model.RefsDump;
import io.lakefs.clients.api.RefsApi;
import io.lakefs.clients.api.ApiClient;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Client {
    public static void main(String[] args) throws Exception {
        ApiClient client = new ApiClient();
        //client.setDebugging(true);
        client.setBasePath("<http://localhost:8000/api/v1>");
        client.setUsername("<user credentials key>");
        client.setPassword("<user credentials secret");
        //client.setConnectTimeout(0);
        //client.setReadTimeout(0);
        //client.setWriteTimeout(0);
        // ...
    }
}
Sample main with how to setup API client - depends on which API you need to call, you will require to instantiate API class that use this client.
o

Omkar Patil

09/29/2022, 12:07 PM
Thank you for your help!!
12:07 PM
I am trying to hit this API /repositories/{repository}/refs/{ref}/objects
12:08 PM
but I am getting error {"message":"parameter "path" in query has an error: value is required but missing: value is required but missing"}
12:08 PM
what should I pass with this path parameter
12:08 PM
could you please give me example
Barak Amar

Barak Amar

09/29/2022, 12:11 PM
The code you are trying to call will help - but from the patch I assume you are trying to get an object - so path is the location of the object
o

Omkar Patil

09/29/2022, 12:33 PM
how I can get path or object? I have uploaded one text file into repo
Barak Amar

Barak Amar

09/29/2022, 12:35 PM
if you uploaded
data/sample.csv
- this is the path value you like to get.
12:36 PM
Can you paste the API call you question about and the expected result you like to get from calling it?