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: Implement parent-child sync for all accessible customers #45

Merged

Conversation

tobiascadee
Copy link

At the moment AccessibleCustomers is not being used as a parent stream to CustomerHierarchyStream. This update fixes that. By updating to the latest singer-sdk version we can use generate_child_contexts to generate multiple child streams per parent stream to sync all accessible customers.

I also added a check to make sure a customer is enabled to avoid 403 errors.

Also changed some of the tap config because in my opinion it was a bit unclear. login_customer_id is now required as it is required in the header. You can also specify customer_ids to filter on customers you want to sync. But only if you have access to them and they are enabled. I understand that some people need to update their config but in the end I think this is more clear.

Moved pagination to the new singer-sdk pagination setup: https://sdk.meltano.com/en/v0.40.0/guides/pagination-classes.html

Other updates are linting updates.

@tobiascadee
Copy link
Author

@DanielPDWalker all done!

@ReubenFrankel ReubenFrankel linked an issue Sep 10, 2024 that may be closed by this pull request
@tobiascadee
Copy link
Author

@DanielPDWalker also need to make sure to update the config in the meltano hub to make sure the documentation is correct.

@ReubenFrankel ReubenFrankel linked an issue Sep 12, 2024 that may be closed by this pull request
pyproject.toml Outdated Show resolved Hide resolved
tap_googleads/client.py Outdated Show resolved Hide resolved
tap_googleads/client.py Outdated Show resolved Hide resolved
tap_googleads/client.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
tap_googleads/tap.py Outdated Show resolved Hide resolved
tap_googleads/tap.py Show resolved Hide resolved
@tobiascadee tobiascadee force-pushed the tobias/fix-parent-child-setup branch from d607f2b to b06eb21 Compare September 17, 2024 11:27
tap_googleads/streams.py Outdated Show resolved Hide resolved
@ReubenFrankel
Copy link

@tobiascadee Your force-push has blown away my commits. Am I OK to add them back?

@tobiascadee
Copy link
Author

@ReubenFrankel ah sorry I thought I would just clean up and integrate your commits into one. Of course you can.

@ReubenFrankel
Copy link

@ReubenFrankel ah sorry I thought I would just clean up and integrate your commits into one. Of course you can.

Ah, I see. Sorry, I didn't realise that's what you had done. 😅 Don't worry about it then.

@tobiascadee tobiascadee force-pushed the tobias/fix-parent-child-setup branch from b06eb21 to 39cb5a8 Compare September 17, 2024 12:59
tap_googleads/client.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
@ReubenFrankel
Copy link

Pretty much there I think - can you update the README with the config changes?

@tobiascadee tobiascadee force-pushed the tobias/fix-parent-child-setup branch 2 times, most recently from a94595f to 35c3f90 Compare September 17, 2024 14:39
@tobiascadee
Copy link
Author

@ReubenFrankel done

Copy link

@ReubenFrankel ReubenFrankel left a comment

Choose a reason for hiding this comment

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

@tobiascadee I spoke with @DanielPDWalker some more this afternoon about the change here to make login_customer_id config required, and we don't think it needs to be. What was your motivation for making it required initially? I see that in the PR description you wrote

login_customer_id is now required as it is required in the header

but the API docs suggest that it is only required when authenticated as a manager account (from OAuth credentials) and accessing a separate customer account:

If accessing an operating customer account directly, the login-customer-id header is not required.

If the authenticated user has access to both the manager and operating customer accounts, then login-customer-id should be specified to avoid any ambiguity. Though not specifying login-customer-id would still work in this case, the context is set to the operating customer account only (which is probably not what is intended).

I don't think there's a great way for the tap to know whether or not you are authenticated in such a way to not set the header at all, so the previous implementation would always set it to either the optional login_customer_id config or the subject customer_id otherwise (see #32). Since this is a tried and tested approach, I think we should re-implement it here to use either login_customer_id or the subject customer_id from context (rather than config).

If we do go ahead with this, you can undo your README changes as well (sorry).


FYI, I am away today so will probably not get back to this until Thursday.

tap_googleads/client.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
tap_googleads/tap.py Outdated Show resolved Hide resolved
tap_googleads/streams.py Outdated Show resolved Hide resolved
At the moment `AccessibleCustomers` is not being used as a parent stream to `CustomerHierarchyStream`. This update fixes that. By updating to the latest singer-sdk version we can use `generate_child_contexts` to generate multiple child streams per parent stream to sync all accessible customers.

I also added a check to make sure a customer is enabled to avoid 403 errors.

Also changed some of the tap config because in my opinion it was a bit unclear. `login_customer_id` is now required as it is required in the header. You can also specify `customer_ids` to filter on customers you want to sync. But only if you have access to them and they are enabled. I understand that some people need to update their config but in the end I think this is more clear.

Moved pagination to the new singer-sdk pagination setup: https://sdk.meltano.com/en/v0.40.0/guides/pagination-classes.html

Other updates are linting updates.
@tobiascadee tobiascadee force-pushed the tobias/fix-parent-child-setup branch from e4e5696 to 9840e5c Compare September 18, 2024 09:21
@tobiascadee
Copy link
Author

I also moved the path and gaql methods to the base class because they are also used in the CustomerHierarchyStream

tap_googleads/tap.py Outdated Show resolved Hide resolved
@ReubenFrankel ReubenFrankel changed the title feat(): fix the parent-child logic feat: Implement parent-child sync for all accessible customers Sep 19, 2024
Co-authored-by: ReubenFrankel <[email protected]>
@tobiascadee
Copy link
Author

@ReubenFrankel your suggestion works on my end. annoying that they implemented it in this way but I guess its the one of the cleanest solutions. any other remarks?

@tobiascadee
Copy link
Author

@ReubenFrankel can we merge?

@ReubenFrankel
Copy link

Right, let's get this in then. Thanks for being patient @tobiascadee

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.

update singer_sdk version feat: Sync all customer accounts available to a manager account
2 participants