@@ -22,8 +22,8 @@ ITokenCacheService tokenCacheService
2222 )
2323{
2424
25- [ Function ( nameof ( GetSyncJobConfig ) + nameof ( ListIds ) ) ]
26- public IActionResult ListIds (
25+ [ Function ( nameof ( GetSyncJobConfig ) + nameof ( ListAreas ) ) ]
26+ public IActionResult ListAreas (
2727 [ HttpTrigger (
2828 AuthorizationLevel . Function ,
2929 "get" ,
@@ -33,43 +33,46 @@ public IActionResult ListIds(
3333 {
3434 ArgumentNullException . ThrowIfNull ( req ) ;
3535
36- return syncJobsConfig ? . Value ? . Jobs ? . Keys is { } ids
37- ? new OkObjectResult ( ids )
36+ return syncJobsConfig ? . Value ? . Jobs ? . Values
37+ ? . Where ( job => job . Area is { Length : > 0 } )
38+ . Select ( job => job . Area )
39+ . Distinct ( )
40+ . ToArray ( ) is { Length : > 0 } areas
41+ ? new OkObjectResult ( areas )
3842 : new NoContentResult ( ) ;
3943 }
4044
41- [ Function ( nameof ( GetSyncJobConfig ) + nameof ( ListAreas ) ) ]
42- public IActionResult ListAreas (
45+ [ Function ( nameof ( GetSyncJobConfig ) + nameof ( ListIds ) ) ]
46+ public IActionResult ListIds (
4347 [ HttpTrigger (
4448 AuthorizationLevel . Function ,
4549 "get" ,
46- Route = "config/{id }"
50+ Route = "config/{area }"
4751 ) ] HttpRequest req ,
48- string id
52+ string area
4953 )
5054 {
5155 ArgumentNullException . ThrowIfNull ( req ) ;
5256
53- if (
54- ! string . IsNullOrWhiteSpace ( id ) &&
55- syncJobsConfig ? . Value ? . Jobs ? . TryGetValue ( id , out var syncJobConfig ) == true &&
56- syncJobConfig ? . Area is { Length : > 0 } area
57- )
58- {
59- return new OkObjectResult ( new string [ ] { area } ) ;
60- }
61- return new NotFoundResult ( ) ;
57+ return
58+ ! string . IsNullOrWhiteSpace ( area ) &&
59+ syncJobsConfig ? . Value ? . Jobs
60+ ? . Where ( job => job . Value . Area == area )
61+ . Select ( job => job . Key )
62+ . ToArray ( ) is { Length : > 0 } ids
63+ ? new OkObjectResult ( ids )
64+ : new NoContentResult ( ) ;
6265 }
6366
6467 [ Function ( nameof ( GetSyncJobConfig ) + nameof ( GetJobConfig ) ) ]
6568 public IActionResult GetJobConfig (
6669 [ HttpTrigger (
6770 AuthorizationLevel . Function ,
6871 "get" ,
69- Route = "config/{id }/{area }"
72+ Route = "config/{area }/{id }"
7073 ) ] HttpRequest req ,
71- string id ,
72- string area
74+ string area ,
75+ string id
7376 )
7477 {
7578 ArgumentNullException . ThrowIfNull ( req ) ;
@@ -106,10 +109,10 @@ public async Task<IActionResult> GetJobConfigSchema(
106109 [ HttpTrigger (
107110 AuthorizationLevel . Function ,
108111 "get" ,
109- Route = "config/{id }/{area }/schema"
112+ Route = "config/{area }/{id }/schema"
110113 ) ] HttpRequest req ,
111- string id ,
112- string area
114+ string area ,
115+ string id
113116 )
114117 {
115118 ArgumentNullException . ThrowIfNull ( req ) ;
0 commit comments