https://lakefs.io/ logo
#dev
Title
# dev
g

Giuseppe Barbieri

01/12/2024, 11:58 AM
I'm glad to see there is already a java client, but java is quite verbose I'm a Kotlin dev and I'd like to implement some wrapper with some nice DSLs (it could be something like this, for example), like the python example I see the java client is auto-generated.. would you consider adding alongside a Kotlin wrapper (and/or accepting a PR)?
i

Itai Admi

01/12/2024, 12:12 PM
We're always encourage contributions, that's what makes OSS so great 😀
g

Giuseppe Barbieri

01/12/2024, 12:13 PM
very nice, could I have some of your time to understand how to do it at best?
i

Itai Admi

01/12/2024, 12:15 PM
Sure. I'll let the product discuss this first and follow up with you next week. Is that ok?
b

Barak Amar

01/12/2024, 12:20 PM
did you try the openapi kotlin generator? there are also other alternatives like https://github.com/cjbooms/fabrikt you can try. unless you are looking for a higher level API.
g

Giuseppe Barbieri

01/12/2024, 12:22 PM
Sure. I'll let the product discuss this first and follow up with you next week. Is that ok?
sure
did you try the openapi kotlin generator?
no, not yet
b

Barak Amar

01/12/2024, 12:24 PM
it may produce more kotlin friendly client api
g

Giuseppe Barbieri

01/12/2024, 12:24 PM
could you show me exactly how the generation take place?
at the moment, I mean
how it's triggered, if there are any templates, etc
b

Barak Amar

01/12/2024, 12:36 PM
The API swagger file can be found under the project
api/
folder. You can follow instructions from https://openapi-generator.tech/ or the project above how to run the code generation. Note it is not part of the lakefs project. Later today I can share specific commands to execute as an example.
g

Giuseppe Barbieri

01/12/2024, 1:28 PM
yep, that'd be nice, thanks Barak
b

Barak Amar

01/12/2024, 2:32 PM
Following docker run command that will produce Kotlin code based on the latest API spec (you can point on specific lakeFS version or run the command from you project and and point to the file)
Copy code
docker run --rm -it -v $(pwd):/code openapitools/openapi-generator-cli generate -i <https://raw.githubusercontent.com/treeverse/lakeFS/master/api/swagger.yml> -g kotlin --package-name lakefs_sdk -o /code/kotlin
Hope this will make the usage more kotlin, again it is not higher level as the high-level python sdk, you will need some code to make it more friendly.
For more options for the generated code you can check the generator specific flags: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin.md
g

Giuseppe Barbieri

01/16/2024, 10:13 AM
is a similar command used for generating the python client api as well? Because I find them quite different
Copy code
sudo docker run --rm -it -v $(pwd):/code openapitools/openapi-generator-cli generate -i <https://raw.githubusercontent.com/treeverse/lakeFS/master/api/swagger.yml> -g python --package-name lakefs_sdk -o /code/python
starting from the
Configuration
class, there is no such class in kotlin
b

Barak Amar

01/16/2024, 12:33 PM
The python SDK is not the high-level python SDK referenced at the lakefs docs. It is not generated. As you saw the generated python sdk holds configuration class to instance a new api client. The kotlin generated code uses ApiClient companion object to help default client properties and each API class will use the default unless you override on creation. Instead of passing configuration you can set the default user/password (which are key/secret for us) and the base url using property:
Copy code
// Use the API client, which automatically authenticates
    ApiClient.username = "AKIAIOSFODNN7EXAMPLE"
    ApiClient.password = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

    // Create a new API client for the repositories API
    val repoApi = RepositoriesApi()
    val repositoryList = repoApi.listRepositories()

    // Print the list of repositories (first page)
    for (repo in repositoryList.results) {
        println("Repo: ${repo.id} (${repo.storageNamespace})")
    }
With the above code I'm using
-Dlakefs_sdk.baseUrl=<http://localhost:8000/api/v1>
to control my server endpoint.
I don't have control over the generated code and the second project I referenced will probably generate a different code for Kotlin on how they implement the transport / initialization / argument passing and etc. But all should provide a way to invoke the API.
g

Giuseppe Barbieri

01/16/2024, 1:44 PM
wait, the high-level python code under
clients/python
isn't generated?
b

Barak Amar

01/16/2024, 2:38 PM
The code under
clients/python
is generated code - it is python package
lakefs-sdk
. The code under
client/python-wrapper
is the high-level python code (not generated) - it is the python package
lakefs
documented https://docs.lakefs.io/integrations/python.html#using-the-lakefs-sdk
g

Giuseppe Barbieri

01/16/2024, 2:50 PM
ok, clear, thanks
one last question though: does the high level python use the generated python under the hood?
b

Barak Amar

01/16/2024, 3:01 PM
yes, it does.
g

Giuseppe Barbieri

01/17/2024, 11:44 AM
ok, for
username
and
password
, but for
host
(like here) what shall I use?
b

Barak Amar

01/17/2024, 4:25 PM
You can pass the base url as property
-Dlakefs_sdk.baseUrl=<http://localhost:8000/api/v1>
or pass it as part of each API constructor.