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

Manage webhooks from the CLI #8242

Open
mtilda opened this issue Jan 12, 2025 · 3 comments
Open

Manage webhooks from the CLI #8242

mtilda opened this issue Jan 12, 2025 · 3 comments

Comments

@mtilda
Copy link

mtilda commented Jan 12, 2025

Is your feature request related to a problem? Please describe.

I am looking for an easy way to work around the problem described in #8241. Currently my method is to manually modify or destroy/recreate the webhook from inside the browser. This is slow and tedious.

Describe the solution you'd like

I would like to be able to disable and re-enable webhooks, like this:

sanity hook disable
sanity hook enable

An alternative way to provide this functionality would be to add the ability to export and import a webhook config. The process of "disabling" and "re-enabling" a webhook could then look like this:

sanity hook export
sanity hook delete  # this already exists
sanity hook import

The export/import functionality would also be useful for copying webhook configurations across projects.

Additional context

In investigating this, I noticed the existing command sanity hook create actually opens a webpage in my browser. Is there a reason the CLI cannot create and update webhooks?

Are any of these features planned?

@mtilda
Copy link
Author

mtilda commented Jan 13, 2025

I am just noticing there is an enabled/disabled status attached to the webhooks that is toggleable in-browser, so we should we should be able to control that via CLI commands.

@mtilda
Copy link
Author

mtilda commented Jan 14, 2025

I noticed that the create command opens a browser...

While other commands like delete and list hit a REST API...

.request({method: 'DELETE', uri: `/hooks/${hookId}`})

Questions

  • Where is the source code for the REST API?
  • Can I make a PATCH request to /hooks/[hook_id]?
  • Do we have any unit tests covering CLI commands? What about the REST API?

@cngonzalez
Copy link
Member

Hi @mtilda ! I think these are valuable suggestions to add to our CLI sanity hook commands. I've forwarded them internally, but I do not have any sense of when we may be able to deliver them.

To answer some of your other questions:

  1. The webhook REST API is not open-source, but we do have it documented here. Please have a look!
  2. You should be able to make a PATCH request to hooks/projects/{projectId}/{id}. Please see the "Update a webhook" section in our docs and do let me know if you have any issues.
  3. Yes, our CLI does have unit tests, which are available in this repo, and so do our internal services. Please let me know if you've seen errors or undesired behavior.

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

No branches or pull requests

2 participants