Skip to content

feat: create, update, and delete integrations (stacked version) #440

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

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

toph-allen
Copy link
Collaborator

Intent

Add functions to create, update, and delete integrations.

N.B. This supersedes #439, which was based on main, and did not include changes from #437.

Fixes #434

Approach

  • Three pretty simple functions to create, update, and delete integrations.
  • create_integration() takes a client.
  • update_integration() and delete_integration() take a connect_integration object as their first argument.
    • To support this, the connect_integration class now gets a client as an attribute when it is created.
  • Some other simplifications where appropriate, e.g. as_integration() no longer uses method dispatch.

Checklist

  • Does this change update NEWS.md (referencing the connected issue if necessary)?
  • Does this change need documentation? Have you run devtools::document()?

@toph-allen
Copy link
Collaborator Author

toph-allen commented Aug 7, 2025

Looks like CI will not run until the parent PR is closed and this targets main.

Base automatically changed from toph/get-integrations-for-content to main August 7, 2025 21:48
…ypick

# Conflicts:
#	NAMESPACE
#	NEWS.md
#	R/integrations.R
#	man/as_integration.Rd
#	man/get_associations.Rd
#	man/get_integration.Rd
#	man/get_integrations.Rd
#	man/set_integrations.Rd
#	tests/testthat/test-integrations.R
#' @param name A descriptive name to identify the integration.
#' @param description Optional, default `NULL.` A brief description of the integration.
#' @param template The template to use to configure this integration (e.g.,
#' "custom", "github", "google", "connect").
Copy link
Collaborator

Choose a reason for hiding this comment

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

Link to API docs for where you can get a complete list of supported values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The API docs say "See List OAuth templates for more information" — I think our idea is that people call that endpoint. I think linking to the OAuth integration docs overview here might be better right now? 🤔

Adding a get_templates() function is tracked here: #435

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, whatever is best. Just flagging that we should provide users with a way of knowing what the valid values here are.

#' @param template The template to use to configure this integration (e.g.,
#' "custom", "github", "google", "connect").
#' @param config A list containing the configuration for the integration. The
#' required fields vary depending on the template selected.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Link to API docs?

Co-authored-by: Neal Richardson <[email protected]>
@@ -92,7 +93,7 @@ test_that("print.integration produces expected output", {
})

with_mock_dir("2024.12.0", {
test_that("integration creates a single integration", {
test_that("get_integration() creates a single integration", {
Copy link
Contributor

Choose a reason for hiding this comment

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

"creates"? or just "gets"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh yeah lol you're exactly right, I was thinking in a different frame when I originally wrote it

@toph-allen toph-allen linked an issue Aug 8, 2025 that may be closed by this pull request
config = config
)
)
as_integration(result, client)

Choose a reason for hiding this comment

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

Is there a reason we're returning an actual object on a PATCH method? I wouldn't expect a function updating an integration to return the new integration object but maybe that's a reasonable side effect in the context of this package.

Copy link
Collaborator Author

@toph-allen toph-allen Aug 8, 2025

Choose a reason for hiding this comment

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

Yeah, the reasons are two-fold. One is that it matches the way that if you're working with local R objects, the way you update an object is to call a function on it and assign that result to something -- like:

animals <- c("cat", "dog")

# update animals
animals <- c(animals, "bat")

In the context of integrations and Connect, it matches the way the PATCH API works (it returns the updated object, and we're just passing it on.)

So if you imagine that in the context of a script, if I'm say, updating an integration, like giving a GitHub integration a new key, it makes sense for my local representation of that object to be updated to the new version.

client <- connect()

github_integration <- get_integrations(client) |>
  purrr::keep(~ .x$template == "github")[[1]]

github_integration <- update_integration(github_integration, config = list(key = NEW_KEY))

# Now this object will reflect the updated info.
github_integration$config$key

Choose a reason for hiding this comment

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

ah, makes perfect sense. thanks!!

@toph-allen toph-allen force-pushed the toph/create-delete-update-integrations-cherrypick branch from 33c7499 to 86617bb Compare August 8, 2025 15:25
@toph-allen toph-allen force-pushed the toph/create-delete-update-integrations-cherrypick branch from 6ca5987 to a2c6741 Compare August 8, 2025 16:29
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.

Add functions to create, delete, and update integrations
5 participants