-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Looker SDK generator for the Dart language #933
base: main
Are you sure you want to change the base?
Conversation
Description: A generator for the Dart language. Note, only supports Looker SDK 4.0. Changes: 1. Dart generator. 2. Tests for dart generator. 3. Generated dart methods and models. 4. Runtime librart for dart. 5. Example dart implementation. 6. Unit tests, 7. End to end test.
Codegen Tests 1 files 18 suites 31s ⏱️ Results for commit 6e70e89. |
Converted to draft. google g3 reports a bunch of lint errors. Turned out I had missed turning on full lint. Have figured out how to do that but it will take a while to fix. |
Codegen Tests 1 files 18 suites 26s ⏱️ Results for commit 83309aa. |
Codegen Tests 1 files 18 suites 30s ⏱️ Results for commit 6d68297. |
Codegen Tests 1 files 18 suites 26s ⏱️ Results for commit 108aeef. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Nothing major but some minor tweaks.
|
||
## Developing | ||
|
||
Relies on `yarn` and `dart` being installed. This was developed with `dart` version `2.15.1` so the recommendation is to have a version of dart that is at least at that version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add a Dart install link? Is Dart config supported with Nix? Would be good to find out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me do that.
Not sure I want to get into nix setup for Dart. You cannot use the normal Dart install for cloudtops (you have to download the SDK from an internal google site). Need to figure out how to document "google" specific stuff.
dart/looker_sdk/README.md
Outdated
|
||
### Generate | ||
|
||
Run `yarn sdk Gen` from the `{reporoot}`. Note that the SDK generator needs to be built `yarn build`. If changing the generator run 'yarn watch` in a separate window. This command generates two files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be yarn gen dart
?
Run `yarn sdk Gen` from the `{reporoot}`. Note that the SDK generator needs to be built `yarn build`. If changing the generator run 'yarn watch` in a separate window. This command generates two files: | |
Run `yarn gen dart` from the `{reporoot}`. Note that the SDK generator needs to be built with `yarn build` first. If changing the generator run 'yarn watch` in a separate window. This command generates two files: |
dart/looker_sdk/README.md
Outdated
|
||
### Run format | ||
|
||
Run `yarn format` from `{reporoot}/dart/looker_sdk` to format the `dart` files correctly. This should be run if you change any of the run time library `dart` files. The repo CI will run the linter and will fail if the files have not been correctly formatted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be hooked into the reformatter for codegen
AuthAccessToken.fromResponse(Map map, String contentType) | ||
: _accessToken = map['access_token'], | ||
_tokenType = map['token_type'], | ||
_expiresIn = map['expires_in']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you'll want the refresh token in case someone wants to implement OAuth flow? Or worry about it then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the OAUTH flow I think. This is really targeting flutter and an client id/secret will not cut it. Need to get an understanding of how mobile does authentication.
static LookerSDK getSdk() { | ||
if (_sdk == null) { | ||
throw Exception('SDK not initialized'); | ||
} | ||
return _sdk; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handy when we only need 1 API supported
case HttpMethod.get: | ||
var response = await http.get(fullPath, headers: headers); | ||
return handleResponse(response, responseHandler); | ||
case HttpMethod.post: | ||
var response = await http.post(fullPath, headers: headers, body: body); | ||
return handleResponse(response, responseHandler); | ||
case HttpMethod.patch: | ||
var response = await http.patch(fullPath, headers: headers, body: body); | ||
return handleResponse(response, responseHandler); | ||
case HttpMethod.delete: | ||
var response = await http.delete(fullPath, headers: headers); | ||
return handleResponse(response, responseHandler); | ||
case HttpMethod.put: | ||
var response = await http.put(fullPath, headers: headers, body: body); | ||
return handleResponse(response, responseHandler); | ||
case HttpMethod.head: | ||
throw UnimplementedError('head'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're basing this on what I did for TypeScript, I did it this way because I wasn't clever enough with TypeScript and the request lib to abstract the method and params into a single call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was based on what you did for typescript and also is original code from way back. This can be improved. Let me do that,
name: looker_sdk | ||
version: 0.0.1 | ||
environment: | ||
sdk: '>=2.9.0 <3.0.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious what this does. Does this mean use 2.9.x or greater but not 3.x?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again very old stuff. My recollection is that this was mainly driven by flutter but I believe your summation is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryans99 would we expect this SDK branch to be the best choice for using looker in flutter mobile apps, or platform calls to swift/kotlin SDKs, or rest api calls, or embedded urls, or just depending on things?
Co-authored-by: John Kaster <[email protected]>
Co-authored-by: John Kaster <[email protected]>
Co-authored-by: John Kaster <[email protected]>
Co-authored-by: John Kaster <[email protected]>
Codegen Tests 1 files 18 suites 32s ⏱️ Results for commit 9f0a8f4. |
9474788
to
5f9930c
Compare
@bryans99 i'm interested in this if you have time to get back to it... |
Description:
A generator for the Dart language. Note, only supports Looker SDK 4.0.
Changes: