Browse Source

feat: added subscription api

pull/532/head
cKey 4 years ago
parent
commit
911373db05
  1. 2
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebHooks/LINGYUN/Abp/Webhooks/AbpWebhooksModule.cs
  2. 4
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebHooks/LINGYUN/Abp/Webhooks/DefaultWebhookSender.cs
  3. 22
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs
  4. 10
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissions.cs
  5. 14
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/IWebhookSubscriptionAppService.cs
  6. 32
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs
  7. 15
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionDto.cs
  8. 26
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionGetListInput.cs
  9. 44
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/Extensions/WebhookSubscriptionExtensions.cs
  10. 111
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs
  11. 3
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/Localization/Resources/en.json
  12. 3
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/Localization/Resources/zh-Hans.json
  13. 9
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhooksManagementErrorCodes.cs
  14. 19
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSubscriptionRepository.cs
  15. 22
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionFilter.cs
  16. 58
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSubscriptionRepository.cs
  17. 59
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionController.cs

2
aspnet-core/modules/webhooks/LINGYUN.Abp.WebHooks/LINGYUN/Abp/Webhooks/AbpWebhooksModule.cs

@ -17,7 +17,7 @@ namespace LINGYUN.Abp.Webhooks;
[DependsOn(typeof(AbpHttpClientModule))]
public class AbpWebhooksModule : AbpModule
{
internal const string WebhooksClient = "Abp.Webhooks.HttpClient";
internal const string WebhooksClient = "__Abp_Webhooks_HttpClient";
public override void PreConfigureServices(ServiceConfigurationContext context)
{

4
aspnet-core/modules/webhooks/LINGYUN.Abp.WebHooks/LINGYUN/Abp/Webhooks/DefaultWebhookSender.cs

@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Net;
using System.Net.Http;
@ -13,18 +12,15 @@ namespace LINGYUN.Abp.Webhooks
{
public ILogger<DefaultWebhookSender> Logger { protected get; set; }
private readonly AbpWebhooksOptions _options;
private readonly IWebhookManager _webhookManager;
private readonly IHttpClientFactory _httpClientFactory;
private const string FailedRequestDefaultContent = "Webhook Send Request Failed";
public DefaultWebhookSender(
IOptions<AbpWebhooksOptions> options,
IWebhookManager webhookManager,
IHttpClientFactory httpClientFactory)
{
_options = options.Value;
_webhookManager = webhookManager;
_httpClientFactory = httpClientFactory;

22
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissionDefinitionProvider.cs

@ -1,6 +1,7 @@
using LINGYUN.Abp.WebhooksManagement.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
namespace LINGYUN.Abp.WebhooksManagement.Authorization;
@ -10,6 +11,27 @@ public class WebhooksManagementPermissionDefinitionProvider : PermissionDefiniti
{
var group = context.AddGroup(WebhooksManagementPermissions.GroupName, L("Permission:WebhooksManagement"));
var subscription = group.AddPermission(
WebhooksManagementPermissions.WebhookSubscription.Default,
L("Permission:Subscriptions"),
MultiTenancySides.Host)
.WithProviders(ClientPermissionValueProvider.ProviderName);
subscription.AddChild(
WebhooksManagementPermissions.WebhookSubscription.Create,
L("Permission:Create"),
MultiTenancySides.Host)
.WithProviders(ClientPermissionValueProvider.ProviderName);
subscription.AddChild(
WebhooksManagementPermissions.WebhookSubscription.Update,
L("Permission:Update"),
MultiTenancySides.Host)
.WithProviders(ClientPermissionValueProvider.ProviderName);
subscription.AddChild(
WebhooksManagementPermissions.WebhookSubscription.Delete,
L("Permission:Delete"),
MultiTenancySides.Host)
.WithProviders(ClientPermissionValueProvider.ProviderName);
group.AddPermission(
WebhooksManagementPermissions.Publish,
L("Permission:Publish"))

10
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/Authorization/WebhooksManagementPermissions.cs

@ -2,7 +2,7 @@
public static class WebhooksManagementPermissions
{
public const string GroupName = "WebhooksManagement";
public const string GroupName = "AbpWebhooks";
/// <summary>
/// 授权允许发布Webhooks事件, 建议客户端授权
@ -10,4 +10,12 @@ public static class WebhooksManagementPermissions
public const string Publish = GroupName + ".Publish";
public const string ManageSettings = GroupName + ".ManageSettings";
public static class WebhookSubscription
{
public const string Default = GroupName + ".Subscriptions";
public const string Create = Default + ".Create";
public const string Update = Default + ".Update";
public const string Delete = Default + ".Delete";
}
}

14
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/IWebhookSubscriptionAppService.cs

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Services;
namespace LINGYUN.Abp.WebhooksManagement;
public interface IWebhookSubscriptionAppService :
ICrudAppService<
WebhookSubscriptionDto,
Guid,
WebhookSubscriptionGetListInput,
WebhookSubscriptionCreateInput,
WebhookSubscriptionUpdateInput>
{
}

32
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs

@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.WebhooksManagement;
public class WebhookSubscriptionCreateInput : WebhookSubscriptionCreateOrUpdateInput
{
}
public class WebhookSubscriptionUpdateInput : WebhookSubscriptionCreateOrUpdateInput
{
}
public abstract class WebhookSubscriptionCreateOrUpdateInput
{
[Required]
[DynamicStringLength(typeof(WebhookSubscriptionConsts), nameof(WebhookSubscriptionConsts.MaxWebhookUriLength))]
public string WebhookUri { get; set; }
[Required]
[DynamicStringLength(typeof(WebhookSubscriptionConsts), nameof(WebhookSubscriptionConsts.MaxSecretLength))]
public string Secret { get; set; }
public bool IsActive { get; set; }
public List<string> Webhooks { get; set; } = new List<string>();
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
}

15
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionDto.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.WebhooksManagement;
public class WebhookSubscriptionDto : CreationAuditedEntityDto<Guid>
{
public Guid? TenantId { get; set; }
public string WebhookUri { get; set; }
public string Secret { get; set; }
public bool IsActive { get; set; }
public List<string> Webhooks { get; set; } = new List<string>();
public IDictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
}

26
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionGetListInput.cs

@ -0,0 +1,26 @@
using System;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.WebhooksManagement;
public class WebhookSubscriptionGetListInput : PagedAndSortedResultRequestDto
{
public string Filter { get; set; }
public Guid? TenantId { get; set; }
[DynamicStringLength(typeof(WebhookSubscriptionConsts), nameof(WebhookSubscriptionConsts.MaxWebhookUriLength))]
public string WebhookUri { get; set; }
[DynamicStringLength(typeof(WebhookSubscriptionConsts), nameof(WebhookSubscriptionConsts.MaxSecretLength))]
public string Secret { get; set; }
public bool? IsActive { get; set; }
public string Webhooks { get; set; }
public DateTime? BeginCreationTime { get; set; }
public DateTime? EndCreationTime { get; set; }
}

44
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/Extensions/WebhookSubscriptionExtensions.cs

@ -0,0 +1,44 @@
using Newtonsoft.Json;
using System.Linq;
namespace LINGYUN.Abp.WebhooksManagement.Extensions
{
public static class WebhookSubscriptionExtensions
{
public static WebhookSubscriptionDto ToWebhookSubscriptionDto(this WebhookSubscription webhookSubscription)
{
return new WebhookSubscriptionDto
{
Id = webhookSubscription.Id,
TenantId = webhookSubscription.TenantId,
IsActive = webhookSubscription.IsActive,
Secret = webhookSubscription.Secret,
WebhookUri = webhookSubscription.WebhookUri,
Webhooks = webhookSubscription.GetSubscribedWebhooks(),
Headers = webhookSubscription.GetWebhookHeaders(),
CreationTime = webhookSubscription.CreationTime,
CreatorId = webhookSubscription.CreatorId
};
}
public static string ToSubscribedWebhooksString(this WebhookSubscriptionUpdateInput webhookSubscription)
{
if (webhookSubscription.Webhooks.Any())
{
return JsonConvert.SerializeObject(webhookSubscription.Webhooks);
}
return null;
}
public static string ToWebhookHeadersString(this WebhookSubscriptionUpdateInput webhookSubscription)
{
if (webhookSubscription.Headers.Any())
{
return JsonConvert.SerializeObject(webhookSubscription.Headers);
}
return null;
}
}
}

111
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs

@ -0,0 +1,111 @@
using LINGYUN.Abp.WebhooksManagement.Authorization;
using LINGYUN.Abp.WebhooksManagement.Extensions;
using Microsoft.AspNetCore.Authorization;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.WebhooksManagement;
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Default)]
public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, IWebhookSubscriptionAppService
{
protected IWebhookSubscriptionRepository SubscriptionRepository { get; }
public WebhookSubscriptionAppService(
IWebhookSubscriptionRepository subscriptionRepository)
{
SubscriptionRepository = subscriptionRepository;
}
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Create)]
public async virtual Task<WebhookSubscriptionDto> CreateAsync(WebhookSubscriptionCreateInput input)
{
await CheckSubscribedAsync(input);
var subscription = new WebhookSubscription(
GuidGenerator.Create(),
input.WebhookUri,
input.Secret,
JsonConvert.SerializeObject(input.Webhooks),
JsonConvert.SerializeObject(input.Headers),
CurrentTenant.Id);
await SubscriptionRepository.InsertAsync(subscription);
await CurrentUnitOfWork.SaveChangesAsync();
return subscription.ToWebhookSubscriptionDto();
}
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Delete)]
public virtual Task DeleteAsync(Guid id)
{
return SubscriptionRepository.DeleteAsync(id);
}
public async virtual Task<WebhookSubscriptionDto> GetAsync(Guid id)
{
var subscription = await SubscriptionRepository.GetAsync(id);
return subscription.ToWebhookSubscriptionDto();
}
public async virtual Task<PagedResultDto<WebhookSubscriptionDto>> GetListAsync(WebhookSubscriptionGetListInput input)
{
var filter = new WebhookSubscriptionFilter
{
Filter = input.Filter,
BeginCreationTime = input.BeginCreationTime,
EndCreationTime = input.EndCreationTime,
IsActive = input.IsActive,
Secret = input.Secret,
TenantId = input.TenantId,
Webhooks = input.Webhooks,
WebhookUri = input.WebhookUri
};
var totalCount = await SubscriptionRepository.GetCountAsync(filter);
var subscriptions = await SubscriptionRepository.GetListAsync(filter,
input.Sorting, input.MaxResultCount, input.SkipCount);
return new PagedResultDto<WebhookSubscriptionDto>(totalCount,
subscriptions.Select(subscription => subscription.ToWebhookSubscriptionDto()).ToList());
}
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Update)]
public async virtual Task<WebhookSubscriptionDto> UpdateAsync(Guid id, WebhookSubscriptionUpdateInput input)
{
var subscription = await SubscriptionRepository.GetAsync(id);
if (!string.Equals(subscription.WebhookUri, input.WebhookUri))
{
await CheckSubscribedAsync(input);
}
subscription.SetWebhookUri(input.WebhookUri);
subscription.SetWebhooks(input.ToSubscribedWebhooksString());
subscription.SetHeaders(input.ToWebhookHeadersString());
await SubscriptionRepository.UpdateAsync(subscription);
await CurrentUnitOfWork.SaveChangesAsync();
return subscription.ToWebhookSubscriptionDto();
}
protected async virtual Task CheckSubscribedAsync(WebhookSubscriptionCreateOrUpdateInput input)
{
foreach (var webhookName in input.Webhooks)
{
if (await SubscriptionRepository.IsSubscribedAsync(CurrentTenant.Id, input.WebhookUri, webhookName))
{
throw new BusinessException(WebhooksManagementErrorCodes.WebhookSubscription.DuplicateSubscribed)
.WithData(nameof(WebhookSubscription.WebhookUri), input.WebhookUri)
.WithData(nameof(WebhookSubscription.Webhooks), webhookName);
}
}
}
}

3
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/Localization/Resources/en.json

@ -5,6 +5,7 @@
"Permission:WebhooksManagement": "Webhooks",
"Permission:ManageSettings": "Manage Settings",
"DisplayName:CheckConnect": "Check Connect",
"Description:CheckConnect": "When a third-party service is connected, it is used to check whether the communication is normal."
"Description:CheckConnect": "When a third-party service is connected, it is used to check whether the communication is normal.",
"Webhooks:010001": "Payload address {WebhookUri} has been mounted event {Webhooks}!"
}
}

3
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/Localization/Resources/zh-Hans.json

@ -5,6 +5,7 @@
"Permission:WebhooksManagement": "Webhooks",
"Permission:ManageSettings": "管理设置",
"DisplayName:CheckConnect": "检查连接",
"Description:CheckConnect": "第三方服务接入时,用于检查是否通讯正常."
"Description:CheckConnect": "第三方服务接入时,用于检查是否通讯正常.",
"Webhooks:010001": "载荷地址 {WebhookUri} 已经挂载事件 {Webhooks}!"
}
}

9
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain.Shared/LINGYUN/Abp/WebhooksManagement/WebhooksManagementErrorCodes.cs

@ -2,5 +2,12 @@
public static class WebhooksManagementErrorCodes
{
public const string Namespace = "WebhooksManagement";
public const string Namespace = "Webhooks";
public static class WebhookSubscription
{
public const string Prefix = Namespace + ":010";
public const string DuplicateSubscribed = Prefix + "001";
}
}

19
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSubscriptionRepository.cs

@ -1,8 +1,27 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Abp.WebhooksManagement;
public interface IWebhookSubscriptionRepository : IRepository<WebhookSubscription, Guid>
{
Task<bool> IsSubscribedAsync(
Guid? tenantId,
string webhookUri,
string webhookName,
CancellationToken cancellationToken = default);
Task<int> GetCountAsync(
WebhookSubscriptionFilter filter,
CancellationToken cancellationToken = default);
Task<List<WebhookSubscription>> GetListAsync(
WebhookSubscriptionFilter filter,
string sorting = $"{nameof(WebhookSubscription.CreationTime)} DESC",
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default);
}

22
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionFilter.cs

@ -0,0 +1,22 @@
using System;
namespace LINGYUN.Abp.WebhooksManagement;
public class WebhookSubscriptionFilter
{
public string Filter { get; set; }
public Guid? TenantId { get; set; }
public string WebhookUri { get; set; }
public string Secret { get; set; }
public bool? IsActive { get; set; }
public string Webhooks { get; set; }
public DateTime? BeginCreationTime { get; set; }
public DateTime? EndCreationTime { get; set; }
}

58
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSubscriptionRepository.cs

@ -1,4 +1,10 @@
using System;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
@ -13,4 +19,54 @@ public class EfCoreWebhookSubscriptionRepository :
: base(dbContextProvider)
{
}
public async virtual Task<bool> IsSubscribedAsync(
Guid? tenantId,
string webhookUri,
string webhookName,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.AnyAsync(x => x.TenantId == tenantId &&
x.WebhookUri == webhookUri &&
x.Webhooks.Contains("\"" + webhookName + "\""),
GetCancellationToken(cancellationToken));
}
public async virtual Task<int> GetCountAsync(
WebhookSubscriptionFilter filter,
CancellationToken cancellationToken = default)
{
return await ApplyFilter(await GetDbSetAsync(), filter)
.CountAsync(GetCancellationToken(cancellationToken));
}
public async virtual Task<List<WebhookSubscription>> GetListAsync(
WebhookSubscriptionFilter filter,
string sorting = $"{nameof(WebhookSubscription.CreationTime)} DESC",
int maxResultCount = 10,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
return await ApplyFilter(await GetDbSetAsync(), filter)
.OrderBy(sorting ?? $"{nameof(WebhookSubscription.CreationTime)} DESC")
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
protected virtual IQueryable<WebhookSubscription> ApplyFilter(
IQueryable<WebhookSubscription> queryable,
WebhookSubscriptionFilter filter)
{
return queryable
.WhereIf(filter.TenantId.HasValue, x => x.TenantId == filter.TenantId)
.WhereIf(filter.IsActive.HasValue, x => x.IsActive == filter.IsActive)
.WhereIf(!filter.WebhookUri.IsNullOrWhiteSpace(), x => x.WebhookUri == filter.WebhookUri)
.WhereIf(!filter.Secret.IsNullOrWhiteSpace(), x => x.Secret == filter.Secret)
.WhereIf(!filter.Webhooks.IsNullOrWhiteSpace(), x => x.Webhooks.Contains("\"" + filter.Webhooks + "\""))
.WhereIf(filter.BeginCreationTime.HasValue, x => x.CreationTime.CompareTo(filter.BeginCreationTime) >= 0)
.WhereIf(filter.EndCreationTime.HasValue, x => x.CreationTime.CompareTo(filter.EndCreationTime) <= 0)
.WhereIf(!filter.Filter.IsNullOrWhiteSpace(), x => x.WebhookUri.Contains(filter.Filter) ||
x.Secret.Contains(filter.Filter) || x.Webhooks.Contains(filter.Filter));
}
}

59
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.HttpApi/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionController.cs

@ -0,0 +1,59 @@
using LINGYUN.Abp.WebhooksManagement.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
namespace LINGYUN.Abp.WebhooksManagement;
[RemoteService(Name = WebhooksManagementRemoteServiceConsts.RemoteServiceName)]
[Area(WebhooksManagementRemoteServiceConsts.ModuleName)]
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Default)]
[Route("api/webhooks/subscriptions")]
public class WebhookSubscriptionController : WebhooksManagementControllerBase, IWebhookSubscriptionAppService
{
protected IWebhookSubscriptionAppService SubscriptionAppService { get; }
public WebhookSubscriptionController(IWebhookSubscriptionAppService subscriptionAppService)
{
SubscriptionAppService = subscriptionAppService;
}
[HttpPost]
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Create)]
public Task<WebhookSubscriptionDto> CreateAsync(WebhookSubscriptionCreateInput input)
{
return SubscriptionAppService.CreateAsync(input);
}
[HttpDelete]
[Route("{id}")]
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Delete)]
public Task DeleteAsync(Guid id)
{
return SubscriptionAppService.DeleteAsync(id);
}
[HttpGet]
[Route("{id}")]
public Task<WebhookSubscriptionDto> GetAsync(Guid id)
{
return SubscriptionAppService.GetAsync(id);
}
[HttpGet]
public Task<PagedResultDto<WebhookSubscriptionDto>> GetListAsync(WebhookSubscriptionGetListInput input)
{
return SubscriptionAppService.GetListAsync(input);
}
[HttpPut]
[Route("{id}")]
[Authorize(WebhooksManagementPermissions.WebhookSubscription.Update)]
public Task<WebhookSubscriptionDto> UpdateAsync(Guid id, WebhookSubscriptionUpdateInput input)
{
return SubscriptionAppService.UpdateAsync(id, input);
}
}
Loading…
Cancel
Save