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

Add Workspace and Connection Geography Support to API #17650

Merged
merged 11 commits into from
Oct 10, 2022

Conversation

pmossman
Copy link
Contributor

@pmossman pmossman commented Oct 5, 2022

What

Addresses https://github.com/airbytehq/airbyte-cloud/issues/2278

How

  • Adds new endpoint v1/web_backend/geographies/list which returns available Geographies
    • Will be just ['auto'] in OSS, and ['auto', 'us', 'eu'] in Cloud
  • Modifies /v1/workspaces/update to support a new property called defaultGeography
    • This endpoint is already PATCH-style, which means:
      • If this property is present on the update request, will set the workspace's defaultGeography column to the value
      • If this property is not present on the update request, will leave the workspace's current defaultGeography unmodified
  • Modifies the /v1/connections/create and /v1/web_backend/connections/create endpoint to support a new optional property called geography
    • If present on the create request, will set the Connection's geography column to the value
    • If not present, the Connection will use whatever is set on its workspace's defaultGeography.
  • Modifies the /v1/connections/update and /v1/web_backend/connections/update endpoint to support a new optional property called geography
    • This endpoint is already PATCH-style, which means:
      • If this property is present, will set the Connection's 'geography' column to the value
      • If not present, will leave the Connection's 'geography' unmodified

Recommended reading order

  1. Start with the various .yaml files that define the Geography type and various schema updates
  2. WebBackendGeographiesHandler.java
  3. ConnectionsHandler.java
  4. WorkspacesHandler.java
  5. Other non-test changes, all relatively minor
  6. Tests

@github-actions github-actions bot added area/api Related to the api area/documentation Improvements or additions to documentation area/platform issues related to the platform area/server labels Oct 5, 2022
@pmossman pmossman force-pushed the parker/geograph-api-endpoints branch from d19b471 to 909f342 Compare October 5, 2022 23:53
@pmossman pmossman temporarily deployed to more-secrets October 5, 2022 23:54 Inactive
@pmossman pmossman temporarily deployed to more-secrets October 6, 2022 00:04 Inactive
@pmossman pmossman temporarily deployed to more-secrets October 6, 2022 17:51 Inactive
@pmossman pmossman force-pushed the parker/geograph-api-endpoints branch from 8c492df to 1b4d45c Compare October 6, 2022 18:11
@pmossman pmossman temporarily deployed to more-secrets October 6, 2022 18:13 Inactive
@pmossman pmossman force-pushed the parker/geograph-api-endpoints branch from 1b4d45c to e5afee7 Compare October 6, 2022 19:10
@pmossman pmossman temporarily deployed to more-secrets October 6, 2022 19:12 Inactive
@@ -286,7 +287,8 @@ private static void createWorkspaceIfNoneExists(final ConfigRepository configRep
.withSlug(workspaceId.toString())
.withInitialSetupComplete(false)
.withDisplaySetupWizard(true)
.withTombstone(false);
.withTombstone(false)
.withDefaultGeography(Geography.AUTO);
Copy link
Contributor

Choose a reason for hiding this comment

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

nice touch

Copy link
Contributor

@terencecho terencecho left a comment

Choose a reason for hiding this comment

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

lgtm, left a couple of comments. I think it's probably worth waiting for someone on FE to give another approval before merging.

airbyte-api/src/main/openapi/config.yaml Outdated Show resolved Hide resolved
airbyte-api/src/main/openapi/config.yaml Show resolved Hide resolved
@pmossman pmossman force-pushed the parker/geograph-api-endpoints branch from e5afee7 to b68ed71 Compare October 7, 2022 23:42
@pmossman pmossman temporarily deployed to more-secrets October 7, 2022 23:45 Inactive
@pmossman pmossman force-pushed the parker/geograph-api-endpoints branch from b68ed71 to 020edce Compare October 10, 2022 15:54
@pmossman pmossman temporarily deployed to more-secrets October 10, 2022 15:56 Inactive
Copy link
Contributor

@ambirdsall ambirdsall left a comment

Choose a reason for hiding this comment

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

The API contracts look reasonable to me. I like that it seems the frontend can use the same code path for OSS and cloud, and will simply fetch different geography lists based on context (hiding a geography selection UI if the only geography is auto is a reasonable piece of busines logic, and cleaner than hardcoding distinct OSS/cloud behaviors); easy to work with and extend in various directions as the product evolves.

My only issue is fetching data with a POST verb, but that's a sufficiently well-established convention that it wouldn't be appropriate to add in an ad hoc one-off GET endpoint.

/**
* Only called by the wrapped Cloud API to enable multi-cloud
*/
public WebBackendGeographiesListResult listGeographiesCloud() {
Copy link
Contributor

Choose a reason for hiding this comment

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

remind me: why/how does the Cloud api call this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the idea to explicitly call this method in the wrapped server in Cloud?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah exactly, in the Cloud wrapped server, we'd call this specific endpoint instead of the OSS-specific endpoint. I think this is a short-term solution that we'll iterate on once we have more concrete needs around specialized OSS use-cases. I think it should serve our needs for now and should be pretty easy to adjust in the future

Copy link
Contributor

@davinchia davinchia left a comment

Choose a reason for hiding this comment

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

Looks sane to me!

One question to make sure I understand how we want to call this in Cloud.

@pmossman
Copy link
Contributor Author

My only issue is fetching data with a POST verb, but that's a sufficiently well-established convention that it wouldn't be appropriate to add in an ad hoc one-off GET endpoint.

@ambirdsall definitely agree with this - we have some lower-level server code that assumes every API call is a POST for logging and redaction of sensitive parameters, so that's the convention we use for now. I think there's growing consensus that this is something we'll want to change eventually but for now I think following the established convention makes sense

@pmossman pmossman merged commit fb9efb3 into master Oct 10, 2022
@pmossman pmossman deleted the parker/geograph-api-endpoints branch October 10, 2022 20:34
jhammarstedt pushed a commit to jhammarstedt/airbyte that referenced this pull request Oct 31, 2022
* progress on adding geography throughout api

* fix workspace handler test

* more progress

* implement workspace defaulting and add/update more tests

* fix bootloader tests

* set defaultGeography in missing places

* add Geography column when reading Connection record from DB

* fix pmd

* add more comments/description

* format

* description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Related to the api area/documentation Improvements or additions to documentation area/platform issues related to the platform area/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants