-
Notifications
You must be signed in to change notification settings - Fork 132
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 newmode v2 #1227
base: main
Are you sure you want to change the base?
Add newmode v2 #1227
Conversation
Will the NewMode v1 API stop working in February? |
Rather than creating a new connector with a different name that would have to be edited in lots of different scripts, can we set some kind of variable, either on the connector or at the global config level, that directs which connector to use under the hood? I'm imagining something like:
So then people wouldn't need to change their scripts at all, just use an environmental variable, and then come Feb we just get rid of the OldNewMode entirely. Unless the old version will still be workable for a while... I'm not 100% sure the above approach will work but it seems like it should? |
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.
Not sure if you wanted me to review the whole thing but I took a quick look, obviously the main thing is the deprecation process - happy to talk about this on a call if you'd prefer
That sounds like an excellent idea, Shauna! Will make those changes! Also, yes, newmode v1 api will stop working in feburary. |
Marked this as ready for review @shaunagm, since I was able to get that last endpoint working! Happy to discuss versioning stuff further, though (specifically for how you think the best way to share with parsons community will be)! |
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.
Great start! Love all the doc strings and there is clearly a lot of detail you've worked through on formatting the requests correctly.
Big things to fix are (1) changing the state in the "get_campaign_ids" method and (2) a consistent return signature from the "converted_request" method. I'm gonna go look at the canales PR now to see how you may be handling the different return values in that script
We expect to shut it down completely on February 28th, 2025. |
"url": "/contact-group/1234", | ||
} | ||
], | ||
"created": [{"value": "0123456789", "format": "Y-m-d\\TH:i:sP"}], |
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 I understand this correctly, this is meant to be a mock response from our /api/v2.1/campaign/x/form endpoint, but I see data here that I wouldn't expect to fin in that response. They look like they're submission responses actually ( /campaign/{campaign_id}/submit). Quite possible that I've misunderstood what's happening here.
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.
Some last thoughts on how to handle the wonkiness in the Campaigns endpoint but overall this looks good!
self.client = OAuth2APIConnector( | ||
uri=base_uri, | ||
auto_refresh_url=V2_API_AUTH_URL, | ||
client_id=self.client_id, | ||
client_secret=self.client_secret, | ||
headers=headers, | ||
token_url=V2_API_AUTH_URL, | ||
grant_type="client_credentials", | ||
) |
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.
Ohhh ok I think I get it. Creating the client in the init function isn't possible because this one endpoint has different headers, base_uri, and api_version.
what if instead we create a self.client
in the init method with all the default values and then the converted_request
and base_request
accept a "custom_client" argument?
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 could even call it self.default_client
if that would be clearer. and then in this function it would say something like
client = client if client else self.default_client
data = self.converted_request( | ||
endpoint=endpoint, | ||
method="GET", | ||
params=params, | ||
data_key="data", | ||
is_get_campaign_ids_method=True, |
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.
and then if we go that way, this would looks something like:
data = self.converted_request( | |
endpoint=endpoint, | |
method="GET", | |
params=params, | |
data_key="data", | |
is_get_campaign_ids_method=True, | |
campaigns_client = OAuth2APIConnector( | |
uri=V2_API_CAMPAIGNS_URL, | |
auto_refresh_url=V2_API_AUTH_URL, | |
client_id=self.client_id, | |
client_secret=self.__client_secret, | |
headers=self.headers, | |
token_url=V2_API_AUTH_URL, | |
grant_type="client_credentials", | |
) | |
data = self.converted_request( | |
# endpoint=endpoint, -- and then I guess this would be optional and you'd need either a endpoint or an override url? | |
method="GET", | |
params=params, | |
data_key="data", | |
custom_client=campaigns_client, | |
override_url=<whatever_it_would_be> |
|
Creates a separate class for NewMode's v2 API since the existing v1 (and the python wrapper the existing NewMode sync is based on will be sunset nest February)
@shaunagm, definitely hoping to discuss Parsons deprecation process with you! Also, wondering if you think v2 should just go in its own folder?
Discussed with @willyraedy some options to go about this. This PR currently follows the 2nd option
NewMode and NewModeV2 are both available and people can update their code
All users swap to NewModeV2
Then you switch NewMode to be V2 as well so both NewMode and NewModeV2 are the v2 version
All users swap back to NewMode
Delete NewModeV2