Skip to content

Commit 6eccf78

Browse files
committed
Add new API methods for repository.
1 parent 74599bd commit 6eccf78

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

Wirehome.Core/HTTP/Controllers/RepositoriesController.cs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ public RepositoriesController(RepositoryService repositoryService)
1515
}
1616

1717
[HttpPost]
18-
[Route("/api/v1/repositories/{type}/download")]
18+
[Route("/api/v1/repositories/{type}/{uid}/download")]
1919
[ApiExplorerSettings(GroupName = "v1")]
2020
public async Task DownloadEntity(string type, string uid)
2121
{
22+
if (type == null) throw new ArgumentNullException(nameof(type));
2223
if (uid == null) throw new ArgumentNullException(nameof(uid));
2324

2425
var typeBuffer = (RepositoryType)Enum.Parse(typeof(RepositoryType), type, true);
@@ -30,8 +31,61 @@ public async Task DownloadEntity(string type, string uid)
3031
[ApiExplorerSettings(GroupName = "v1")]
3132
public void DeleteEntity(string type, string uid)
3233
{
34+
if (type == null) throw new ArgumentNullException(nameof(type));
35+
if (uid == null) throw new ArgumentNullException(nameof(uid));
36+
3337
var typeBuffer = (RepositoryType)Enum.Parse(typeof(RepositoryType), type, true);
3438
_repositoryService.DeleteEntity(typeBuffer, RepositoryEntityUid.Parse(uid));
3539
}
40+
41+
[HttpPost]
42+
[Route("/api/v1/repositories/component_logics/{uid}/download")]
43+
[ApiExplorerSettings(GroupName = "v1")]
44+
public async Task DownloadComponentLogicEntity(string uid)
45+
{
46+
if (uid == null) throw new ArgumentNullException(nameof(uid));
47+
48+
await _repositoryService.DownloadEntityAsync(RepositoryType.ComponentLogics, RepositoryEntityUid.Parse(uid));
49+
}
50+
51+
[HttpPost]
52+
[Route("/api/v1/repositories/component_adapters/{uid}/download")]
53+
[ApiExplorerSettings(GroupName = "v1")]
54+
public async Task DownloadComponentAdapterEntity(string uid)
55+
{
56+
if (uid == null) throw new ArgumentNullException(nameof(uid));
57+
58+
await _repositoryService.DownloadEntityAsync(RepositoryType.ComponentAdapters, RepositoryEntityUid.Parse(uid));
59+
}
60+
61+
[HttpPost]
62+
[Route("/api/v1/repositories/services/{uid}/download")]
63+
[ApiExplorerSettings(GroupName = "v1")]
64+
public async Task DownloadServiceEntity(string uid)
65+
{
66+
if (uid == null) throw new ArgumentNullException(nameof(uid));
67+
68+
await _repositoryService.DownloadEntityAsync(RepositoryType.Services, RepositoryEntityUid.Parse(uid));
69+
}
70+
71+
[HttpPost]
72+
[Route("/api/v1/repositories/tools/{uid}/download")]
73+
[ApiExplorerSettings(GroupName = "v1")]
74+
public async Task DownloadToolEntity(string uid)
75+
{
76+
if (uid == null) throw new ArgumentNullException(nameof(uid));
77+
78+
await _repositoryService.DownloadEntityAsync(RepositoryType.Tools, RepositoryEntityUid.Parse(uid));
79+
}
80+
81+
[HttpPost]
82+
[Route("/api/v1/repositories/automations/{uid}/download")]
83+
[ApiExplorerSettings(GroupName = "v1")]
84+
public async Task DownloadAutomationEntity(string uid)
85+
{
86+
if (uid == null) throw new ArgumentNullException(nameof(uid));
87+
88+
await _repositoryService.DownloadEntityAsync(RepositoryType.Automations, RepositoryEntityUid.Parse(uid));
89+
}
3690
}
3791
}

0 commit comments

Comments
 (0)