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

V14: Webhook Management API #15147

Merged
merged 30 commits into from
Feb 26, 2024

Conversation

bjarnef
Copy link
Contributor

@bjarnef bjarnef commented Nov 6, 2023

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Added webhooks to Management API and models, which we can generate models for in the new backoffice.
See related PR for new backoffice here: umbraco/Umbraco.CMS.Backoffice#962

Copy link

github-actions bot commented Nov 6, 2023

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@bjarnef
Copy link
Contributor Author

bjarnef commented Nov 6, 2023

@Zeegaan @bergmania I have added this while working on umbraco/Umbraco.CMS.Backoffice#962

I think the CRUD operation methods should take a parameter Guid userKey like in ILanguageService?

Futhermore should the IWebhookService method return Task<IWebhook> instead of Task<Webhook>?

or maybe Task<Attempt<IWebhook?, WebhookOperationStatus>>?

It seems to Update method should also return Webhook (or IWebhook).

Should we have Constants.UdiEntityType.Webhook as well?

The API version should probably be changes as well for this :)

@georgebid
Copy link
Contributor

georgebid commented Nov 7, 2023

Morning @bjarnef, thanks for the PR! Someone on the team will review this soon 😄

@bjarnef
Copy link
Contributor Author

bjarnef commented Nov 7, 2023

@georgebid it definitely need some more work, but it would be great with some feedback from HQ. Maybe it also requires some additional changes regarding webhooks in v13/dev branch.

I know @kjac has worked on the management API, so maybe he could have a look at some point 😎

@georgebid
Copy link
Contributor

georgebid commented Nov 7, 2023

Ah yes, @bjarnef sorry I totally missed that this was marked as a Draft, but yes don't worry - I am sure someone from HQ will be in touch soon! 🚀

@bjarnef
Copy link
Contributor Author

bjarnef commented Nov 15, 2023

@elit0451 maybe something you want to review too since you have worked much with the (content) delivery API.
I need to merge latest changes regarding webhooks and later when having the models, I can look at the related backoffice PR 😎

@bjarnef
Copy link
Contributor Author

bjarnef commented Nov 15, 2023

I think we also need the changes from #15180 but it seems these haven't been merged to v14/dev branch yet.

@Zeegaan
Copy link
Member

Zeegaan commented Nov 16, 2023

Should be updated now 😁

… feature/management-api-webhook

# Conflicts:
#	src/Umbraco.Core/Services/OperationStatus/WebhookOperationStatus.cs
@bjarnef
Copy link
Contributor Author

bjarnef commented Nov 16, 2023

@Zeegaan I have updated that and resolved the conflicts.

I noticed an ambiguous reference because WebhookResponseModel exists in Umbraco.Cms.Core.Models and also Umbraco.Cms.Api.Management.ViewModels.Webhook

@bjarnef bjarnef marked this pull request as ready for review January 1, 2024 22:57
… feature/management-api-webhook

# Conflicts:
#	src/Umbraco.Core/Services/LanguageService.cs
@bjarnef bjarnef changed the title Feature: Management API - Webhook V14: Webhook Management API Feb 19, 2024
@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 19, 2024

I noticed CreatedAtAction() has changed and updated the usage in:
7b48a71

Should the routeValues be nullable? and perhaps an overload as before accepting Guid as identifier?

Nevermind, I noticed theres a new method CreatedAtId<T>() and CreatedAtPath<T>(), which call CreatedAtAction<T>().

@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 21, 2024

It would be great if we could review/merge this, so I can continue the webhooks workspace in backoffice repository 😃

@Zeegaan
Copy link
Member

Zeegaan commented Feb 22, 2024

@bjarnef We are aware of this, and we have set aside sprint time to review, but we are really busy with all kinds of v14 stuff 🏃‍♂️

I will get to this as soon as I am able 😁

@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 22, 2024

@Zeegaan yeah, I know.. and seems there are lots to do. It is after all a major overhaul and cleanup/refactor of 10 year old code in some parts of the backoffice.
But I guess it need this sooner or later 😁

and would love to help with the frontend (in backoffice) webhooks workspace, but I neeed to generate the models from v14/dev branch to continue that work 😅

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

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

Sorry for this taking a long time, finally got around to it 😁
Have a few comments, but overall looks splendid! 💪

@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 23, 2024

Regarding the CurrentUserKey() and audits of the the webhook e.g. was created from backoffice or from code is need further adjustments. IIRC languages have this, but not audit in backoffice UI.

Maybe the webhook model need some adjustments as well. I haven't checked with the latest changes with was added/adjusted in v13.

The webhook inherits TEntity IIRC, but the UI doesn't allow setting a werbhook friendly name yet I think. In case this will be added it could use the header name field in backoffice, but not if it is optional as that requires a value.
Maybe only in v14 later and then webhook model with a name property as well.

@Zeegaan
Copy link
Member

Zeegaan commented Feb 23, 2024

Yea I think a friendly name at some point would be nice, but I think we should aim for feature parity for now, and then we can always sprinkle stuff on top later 😁

I will give this a test for now, and come back if the models needs adjustment 👍


public class CreateWebhookRequestModel : WebhookModelBase
{
public Guid? Id { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Zeegaan does UpdateWebhookRequestModel also need this and WebhookResponseModel?

Should it be part of WebhookModelBase instead then?

Copy link
Member

Choose a reason for hiding this comment

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

No just the CreateModel! 😁
It's basically just so you can specify an Id upon creation 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, but we should probably add it to WebhookResponseModel model as well then - just like with datatype:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added Guid to WebhookResponseModel:
5005138

I noticed other response models inherits from NamedItemResponseModelBase which inherits from ItemResponseModelBase and has Guid Id.

E.g. MemberGroupItemResponseModel inherits from NamedItemResponseModelBase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess WebhookResponseModel can inherits from NamedItemResponseModelBase as webhook inherits TEntity or from ItemResponseModelBase ?

Copy link
Member

Choose a reason for hiding this comment

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

ItemResponseModelBase are for the item endpoints, so no more inheritance please 🙈

@Zeegaan
Copy link
Member

Zeegaan commented Feb 26, 2024

@bjarnef I've added some missing mapping and the new auth policies, but works like a charm now 😁
Will merge when the tests pass 🚀

@Zeegaan Zeegaan merged commit f47830b into umbraco:v14/dev Feb 26, 2024
12 of 15 checks passed
@Zeegaan Zeegaan added the project/bellissima AKA "the new backoffice" label Feb 26, 2024
@bjarnef bjarnef deleted the feature/management-api-webhook branch February 26, 2024 14:04
@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 26, 2024

@Zeegaan do we need something like this to get a paged result of webhooks?
https://github.com/umbraco/Umbraco-CMS/blob/v14/dev/src/Umbraco.Cms.Api.Management/Controllers/Language/AllLanguageController.cs

I noticed after generating models in umbraco/Umbraco.CMS.Backoffice#962 that WebhookResource has two methods to get webhooks:

  • getWebhookById
  • getWebhookItem

where LanguageResource has:

  • getLanguageByIsoCode
  • getItemLanguage
  • getLanguage (paged result returning PagedLanguageResponseModel)

@Zeegaan
Copy link
Member

Zeegaan commented Feb 29, 2024

Yes seems like it 😁

@bjarnef
Copy link
Contributor Author

bjarnef commented Feb 29, 2024

@Zeegaan added in #15802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project/bellissima AKA "the new backoffice" release/14.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants