-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
🐛 Source Mailchimp: use datacenter parameter from apikey info #4285
Conversation
/test connector=connectors/source-mailchimp
|
primary_key = "id" | ||
page_size = 100 | ||
|
||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.current_offset = 0 | ||
dc = kwargs['authenticator'].datacenter |
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.
dc = kwargs['authenticator'].datacenter | |
data_center = kwargs['authenticator'].datacenter |
@@ -33,13 +33,15 @@ | |||
|
|||
|
|||
class MailChimpStream(HttpStream, ABC): | |||
url_base = "https://us2.api.mailchimp.com/3.0/" | |||
url_base = "" |
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.
We can use a dynamic property
url_base = "" | |
@property | |
def url_base(self) -> str: | |
return f"https://{self.data_center}.api.mailchimp.com/3.0/" |
@@ -37,6 +37,7 @@ | |||
|
|||
class HttpBasicAuthenticator(TokenAuthenticator): | |||
def __init__(self, auth: Tuple[str, str], auth_method: str = "Basic", **kwargs): | |||
self.datacenter = auth[1].split('-').pop() |
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.
self.datacenter = auth[1].split('-').pop() | |
# API keys have the format <key>-<data_center>. See https://mailchimp.com/developer/marketing/docs/fundamentals/#api-structure | |
self.datacenter = auth[1].split('-').pop() |
/test connector=connectors/source-mailchimp
|
/publish connector=connectors/source-mailchimp
|
3be5792
to
6e8e9ac
Compare
|
||
@property |
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 removal breaks reading logic and acceptance tests, related issue #4499
What
Closes #4198
change base url to use datacenter info
More information is possible to look at the mailchimp3 python client
https://github.com/VingtCinq/python-mailchimp/blob/d454e6280e1c66cfdbab502a11cb41f023ca0867/mailchimp3/mailchimpclient.py#L88-L89
How
update the base_url in init class instance to use datacenter info from apikey
https://mailchimp.com/developer/marketing/docs/export-api/#api-parameters
Recommended reading order
source.py
=> added datacenter in the Authentication class isn't the best place... let me know if a need to decode in the Stream class instead;streams.py
=> update class variable to use datacenter variablePre-merge Checklist
Expand the checklist which is relevant for this PR.
Connector checklist
airbyte_secret
in output spec./gradlew :airbyte-integrations:connectors:<name>:integrationTest
./test connector=connectors/<name>
command as documented here is passing.docs/integrations/
directory./publish
command described hereConnector Generator checklist
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changes