Having pre-built Looker SDKs for a variety of programming languages is definitely on my wish list.
This requires two steps:
Learning how to build and distribute packages in each of those languages
Integrating that build & distribute into our Looker release process
We’d only be able to do this for the top few languages customers use to call our API. Everyone else will still have to use the Swagger codegen process to generate a client SDK in their language, or roll-their-own SDK that wraps the REST endpoints directly.
Good news for you! Python is already in the top 5 languages used to call the Looker API. ��
I can’t offer any timeframes for getting this investigated and done, as I have to fit this work in around my other responsibilities. (shh! New Looker APIs in the works!) But I hear ya and I definitely want to make getting up to speed with Looker client SDKs a lot easier for you all!
$ ls
lookerapi.json python_sdk swagger-codegen swagger-codegen-cli.jar
$ cd python_sdk/
$ ls
docs README.md setup.py test tox.ini
git_push.sh requirements.txt swagger_client test-requirements.txt
$ pip install .
Note this will install the module as “swagger_client”, unless you rename the directory.
Virtual environment highly recommended.
The sdk seems to work fine with Python 3.6. I tried using the current stable version of swagger-codegen (2.2.3), but got an error, something to do with “can’t create Role” (can’t remember exactly and it has scrolled off my terminal). Using swagger-codegen v2.2.2 as specified above, no problems.
I get the following error starting the server after I generated a nodejs package with codegen:
API Errors:
#/paths/~1dashboards~1{dashboard_id}~1prefetch/get/parameters/1: Not a valid parameter definition
#/paths/~1dashboards~1{dashboard_id}~1prefetch/get/parameters/1: Not a valid parameter definition
#: Missing required property: schema
#: Not a valid undefined definition
#/items: Additional properties not allowed: $ref
#/items: Additional properties not allowed: $ref
#/items: Additional properties not allowed: $ref
#/items: Additional properties not allowed: $ref
#/paths/~1dashboards~1{dashboard_id}~1prefetch/get/parameters/1: Missing required property: $ref
1 error and 0 warnings
It appears the dashboard_filters query arg in the dashboard prefetch request is supposed to be an array of objects which I believe is disallowed by OpenAPI spec.
Open a new browser window and navigate to this URL: https://
I am stuck with 2 problem at present.
Problem 1:
In the below process step
Open a new browser window and navigate to this URL: https://:19999/api/3.0/swagger.json Subsitute your custom Looker API Host domain name and port if necessary.
Save the contents of that swagger.json page to looker_sdk/lookerapi.json.
I am able to browse toward the URL but that has many in list. Should I manually copy paste them and save it to lookerapi.json or only which is required. Like authentication alone ?
Problem 2: GIT
when I try to access GIT
git clone git@github.com:swagger-api/swagger-codegen.git ./swagger-codegen
I am prompted with error
Cloning into ‘swagger-codegen’… ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository.
Please make sure you have the correct access rights
Is there any plan to distribute examples of using the swagger generated api’s in languages such as Java? I’ve found the link below before, and it has just about every language other than java.
It looks like LookerEmbedClientExample is the Java version of the SSO script you linked to here,
but this is for generating an SSO Login URL.
To generate a Swagger SDK for Java, follow the above instructions until you get to the header “Generate a Looker API Client SDK.” After the command there is a paragraph describing how to alter the statement to get a Java SDK.
You can use the same command to generate Looker API client SDKs for Java, .NET, and a variety of other languages and platforms supported by the Swagger-Codegen tools. Change the language target with the -l parameter and the output directory with the -o parameter.
I’ve generated the Looker API SDK via the swagger generation. My problem is finding tangible examples of the swagger api sdk in action. Would love to see some tangible examples in java. Let me know if that makes sense.
Ah I see, thanks for clarifying. At this time there aren’t tangible examples of using the Looker API with Java but I will let our Product/Docs team know these would be helpful.
We do have these examples in Python, but it doesn’t look like we currently have the same thing for Java.
The reason is that if I merely passed strings as positional parameters, then the configuration object wasn’t an object, but was just strings, which don’t have the configuration object’s methods, so the SDK code would break.
I’ve managed to perform all the steps until the last one.
A few questions to debug it:
The file test_app.py must be placed in python work directory (~/pywd/) and not in ~/pywd/looker/, ~/looker_sdk/python_sdk/ nor ~/looker_sdk/python_sdk/swagger_client/ ?
When I run python test_app.py in my python work directory ~/pywd/, the following error occurs
AttributeError: module 'looker' has no attribute 'ApiClient'
I did filled the base_url, client_idand `client_secret``
Is there something I missed ?
I am trying to generate a client using swagger-codegen in aspnetcore. When I generate the client everything gets generated but all the code in the controllers is filled with TODO comments rather than the actual code for the method:
Example:
public virtual IActionResult Login([FromQuery]string clientId, [FromQuery]string clientSecret)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(AccessToken));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400, default(Error));
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404, default(Error));
string exampleJson = null;
exampleJson = "{\n \"access_token\" : \"access_token\",\n \"token_type\" : \"token_type\",\n \"expires_in\" : 0\n}";
var example = exampleJson != null
? JsonConvert.DeserializeObject<AccessToken>(exampleJson)
: default(AccessToken);
//TODO: Change the data returned
return new ObjectResult(example);
}
However, when I generate the client using .net starndard, everything gets generated fine and I can consume the API endpoints as documented.