Skip to content
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(java): Initialize Java SDK #158

Merged
merged 23 commits into from
Sep 8, 2023
Merged

feat(java): Initialize Java SDK #158

merged 23 commits into from
Sep 8, 2023

Conversation

booniepepper
Copy link
Contributor

@booniepepper booniepepper commented Jul 25, 2023

  • feat(java): make setup-new-sdk
  • fix(java): Initial configuration updates

Introduces a Java SDK generated with make setup-new-sdk

Description

References

Closes #152
Closes #157

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Makefile Outdated Show resolved Hide resolved
Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the top level files are repeated under native

Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the SDK namespace to dev.openfga.sdk? in the future we may want to publish other packages under the dev.openfga namespace

@booniepepper booniepepper force-pushed the feat/java-sdk branch 2 times, most recently from 58a317c to 4e5faaa Compare August 18, 2023 23:44
@booniepepper booniepepper marked this pull request as ready for review August 25, 2023 14:13
@booniepepper booniepepper requested a review from a team as a code owner August 25, 2023 14:13
booniepepper and others added 13 commits September 6, 2023 20:12
Closes #169

From #170

* chore(java): Update to JUnit 5
* test(java): Move generated OpenFgaApiTest to a template
* test(java): Unit test the Check API, introduce Mockito, update javadocs
* test(java): Add unhappy case tests
* test(java): Flesh out first test on check
* clean(java): Remove lengthy javadoc descriptions in unit tests
* test(java): Add HTTP mocks and verifications
* test(java): Flesh out all unit tests and mocks
* clean(java): Remove now-unused api_test.mustache
* clean(java): Only configure tests with jvm-test-suite semantics
* clean(java): Re-order tests to follow other test suites and order of https://openfga.dev/api/service
* clean(java): Refactor tests for brevity and clarity
* test(java): Flesh out write API with writes/deletes
* test(java): Flesh out expand test, minor refactors
* test(java): Add tests on all 400/404/500s, Update status codes on some create/delete tests
Adds Configuration for the SDK. This also includes a StringUtil utility class, and basic credentials modeling (but not handling yet)

Closes #154

Details can be found in #173

* feat(java): Introduce a Configuration class
* fix(java): Assert deletion by Store ID instead of name for local dev
* fix(java): Update integ tests for Configuration change
* misc(java): Minor refactors to Configuration
* misc(java): Move Configuration class out of ApiClient
* refactor(java): Make interface of Configuration more similar to generated models
* feat(java): Add isValid() to Configuration
* misc(java): Make an errors package path
* docs(java): Note in javadocs that Configuration will take precedence over HttpClient settings
* refactor(java): Make Configuration an interface, BasicConfiguration an implementation, other updates
* refactor(java): Rename Configuration types
* feat(java): Add some Credentials types
* refactor(java): Rename Configuration template files with config- prefix
* refactor(java): Move isNullOrWhitespace out of Configuration
* feat(java): Add assertValid() to ClientCredentials
* misc(java): Update filenames of "util" classes
* Update config/clients/java/template/config-Configuration.java.mustache
  * Co-authored-by: Raghd Hamzeh <raghd.hamzeh@auth0.com>
* Update config/clients/java/template/config-Configuration.java.mustache
  * Co-authored-by: Raghd Hamzeh <raghd.hamzeh@auth0.com>
* feat(java): Add default for API URL when its null/empty/whitespace

---------

Co-authored-by: Raghd Hamzeh <raghd.hamzeh@auth0.com>
* refactor(java): Thread Configuration through request builders

* refactor(java): Thread Configuration through requests

* feat(java): Introduce ConfigurationOverride class

* test(java): Add tests on ConfigurationOverride

* refactor(java): Consistent code in Configuration.override(...)
- Add Java 20 to CI
- Use exact hashes for CI actions
- Fix broken link for models in README
- Fix artifact version in build.gradle and elsewhere
- Git ignore some files

---------

Co-authored-by: Raghd Hamzeh <raghd.hamzeh@auth0.com>
* refactor(java): Remove all @generated annotations

* refactor(java): Remove unused JSON.java

* refactor(java): Move configuration types to dev.openfga.sdk.api.configuration
* refactor(java): Move error and util classes around

* refactor(java): Remove an unused date format class

* refactor(java): Move auth classes to their own space

* refactor(java): Move ApiException creation function to a constructor

* feat(java): Introduce OAuth2Client

* refactor(java): Use more mustache values for Java package paths

* refactor(java): Rename misc classes and variable names

* test(java): Add basic happy-path test on OAuth2Client

* refactor(java): Move some credentials packages to 'configuration' package

* refactor(java): Add Credentials to Configuration

* refactor(java): Add OAuth2Client to OpenFgaApi

* refactor(java): Assert valid credentials when asserting valid configuration

* feat(java): Put OAuth2 header on requests

* feat(java): Allow credentials in Configuration to be overridden
@booniepepper booniepepper marked this pull request as ready for review September 8, 2023 14:09
.github/workflows/main.yaml Outdated Show resolved Hide resolved
Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the scripts/build_client.sh, please add to line 33: |.gradle

So that it becomes:
cd "${CLIENTS_OUTPUT_DIR}/fga-${SDK_LANGUAGE}-sdk" && ls -A | grep -Ev '.git|node_modules|.idea|venv|.gradle' | xargs rm -r && cd -

.github/workflows/main.yaml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@rhamzeh rhamzeh added this pull request to the merge queue Sep 8, 2023
Merged via the queue into main with commit 43229fc Sep 8, 2023
5 of 6 checks passed
@rhamzeh rhamzeh deleted the feat/java-sdk branch September 8, 2023 14:52
}

group = '{{groupId}}'
version = '{{artifactVersion}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packageVersion and drop from overrides

"modelPackage": "dev.openfga.sdk.api.model",
"snapshotVersion": false,
"packageDescription": "Java SDK for OpenFGA",
"artifactDescription": "Java SDK for OpenFGA",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop

"packageName": "dev.openfga:openfga-sdk",
"artifactId": "openfga-sdk",
"groupId": "dev.openfga",
"artifactVersion": "0.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop

@rhamzeh rhamzeh mentioned this pull request Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java SDK: Choosing an HTTP client library Generate basic Java SDK (with minimal changes)
4 participants