I'm glad to see there is already a java client, bu...
# dev
g
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
We're always encourage contributions, that's what makes OSS so great 😀
g
very nice, could I have some of your time to understand how to do it at best?
i
Sure. I'll let the product discuss this first and follow up with you next week. Is that ok?
b
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
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
it may produce more kotlin friendly client api
g
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
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
yep, that'd be nice, thanks Barak
b
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
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
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
wait, the high-level python code under
clients/python
isn't generated?
b
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
ok, clear, thanks
one last question though: does the high level python use the generated python under the hood?
b
yes, it does.
g
ok, for
username
and
password
, but for
host
(like here) what shall I use?
b
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.