-
Notifications
You must be signed in to change notification settings - Fork 26
feat: function to set all oauth integrations associated with a content item #431
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
Conversation
R/integrations.R
Outdated
|
|
||
| # Integration class ---- | ||
|
|
||
| validate_integration <- function(x) { |
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.
Is this necessary? You're only going to get one of these objects from the server, which we control.
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.
I think so. Otherwise a user could pass in any list to the as_integration() function and then hit server errors about incorrect GUIDs when they pass it into things. (Granted, we could rely on those errors!) It's also just… like, what I understand to be good form for S3 classes, even if those are classes that will mostly be created internally. I'd rather leave this in, but don't feel like it's necessary.
I could make it more concise by checking the field names against the ptype names we already have defined in connectapi_ptypes, use that as the canonical place where prototypes are defined.
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.
Otherwise a user could pass in any list to the as_integration() function and then hit server errors about incorrect GUIDs when they pass it into things.
Can you show me where that happens? I only see as_integration() being called inside get_integrations() and (get_)integration(), on data that is coming from the server.
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.
I'm confused what you're asking about. We export as_integration(), so a user could pass other data into it. But that possibility isn't something that happens in our codebase.
Perhaps the supporting change here is to not export as_integration() — is that what you're implying?
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.
I removed the as_integration() export and the validation.
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.
The fact that the validator made sure that you had an id and guid suggested to me that you would only get that from a server API response, and that if you were constructing a payload to create an integration (which I don't see supported yet), you wouldn't include those fields. So I couldn't see a scenario where this validation would be called on anything other than the thing that comes back from the server, which we can assume to be the shape it is because we control the other side of that API.
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.
I made the changes, so I'm going to merge bypassing your remaining requested changes. Thanks again for the review!
Co-authored-by: Neal Richardson <[email protected]>
mconflitti-pbc
left a comment
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.
Looks good to me. Is the plan to include the complementary getter for content's integration's as well?
Yep! I was going to do that in this PR, but I held off for the next one, because it also requires thinking about how I want to handle Associations (i.e. return them as a class, or just return the set of integrations — I'm not sure if it makes sense for them to be a user-facing class in this package). |
They are technically their own record in the db which is what the python sdk returns. it contains a subset of info from the integrations |
Yeah, I saw that they were their own object in the API and that the Python API returned info on them. The date associated is probably useful to be able to access, but I also as a data scientist could imagine it feeling weird that I need to think about what is essentially the join table between the two object types I care about. My thought was to have something like a |
|
GitHub says this merge bypasses the rules; just noting that I have another approval and made the changes that were requested in that review. |
Intent
Add a function to set a content item's OAuth associations.
Example usage:
Fixes #414
Approach
content_set_all_integrations(content, integrations), which sets all integration associations for a provided content item.content, is a content item. The second parameter,integrations, can be a singleconnect_integrationclass object or a list of such objects.associationtype objects, maybe this'll return that later, but that'd require another request to the Connect server.connect_integration.get_integrations()function.integration(client, guid)to the details of a single integration from the server given its guid.Checklist
NEWS.md(referencing the connected issue if necessary)?devtools::document()?Validation
Note
At time of writing (7:30 PM on Friday) CI is failing. There was a problem with some of my S3 method consistency, but maybe also some Docker errors in there, I'm not sure. Attempted one fix, but I'm not going to get into an iteration cycle at this time; I'll fix Monday AM.