7
7
using System . Threading . Tasks ;
8
8
using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . API . Clients . Abstractions ;
9
9
using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Constants ;
10
- using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Extensions ;
11
10
using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Common . Templates . Tags ;
12
11
using Microsoft . Azure . Management . ApiManagement . ArmTemplates . Extractor . Models ;
13
12
@@ -18,6 +17,7 @@ public class TagClient : ApiClientBase, ITagClient
18
17
const string GetAllTagsLinkedToApiRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apis/{4}/tags?api-version={5}&format=rawxml" ;
19
18
const string GetAllTagsRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/tags?$skip={4}&api-version={5}" ;
20
19
const string GetTagsLinkedToApiOperationRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apis/{4}/operations/{5}/tags?api-version={6}&format=rawxml" ;
20
+ const string GetAllTagsLinkedToProduct = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/products/{4}/tags?api-version={5}" ;
21
21
22
22
readonly IApisClient apisClient ;
23
23
@@ -48,7 +48,7 @@ public async Task<List<TagTemplateResource>> GetAllAsync(ExtractorParameters ext
48
48
49
49
public async Task < List < TagTemplateResource > > GetAllTagsLinkedToApiAsync ( string apiName , ExtractorParameters extractorParameters )
50
50
{
51
- ( string azToken , string azSubId ) = await this . Auth . GetAccessToken ( ) ;
51
+ var ( azToken , azSubId ) = await this . Auth . GetAccessToken ( ) ;
52
52
53
53
string requestUrl = string . Format ( GetAllTagsLinkedToApiRequest ,
54
54
this . BaseUrl , azSubId , extractorParameters . ResourceGroup , extractorParameters . SourceApimName , apiName , GlobalConstants . ApiVersion ) ;
@@ -58,20 +58,12 @@ public async Task<List<TagTemplateResource>> GetAllTagsLinkedToApiAsync(string a
58
58
59
59
public async Task < List < TagTemplateResource > > GetAllTagsLinkedToProductAsync ( string productName , ExtractorParameters extractorParameters )
60
60
{
61
- var apisLinkedToProduct = await this . apisClient . GetAllLinkedToProductAsync ( productName , extractorParameters ) ;
62
-
63
- var tagTemplateResources = new List < TagTemplateResource > ( ) ;
64
- foreach ( var productApi in apisLinkedToProduct )
65
- {
66
- var apiTags = await this . GetAllTagsLinkedToApiAsync ( productApi . Name , extractorParameters ) ;
61
+ var ( azToken , azSubId ) = await this . Auth . GetAccessToken ( ) ;
67
62
68
- if ( ! apiTags . IsNullOrEmpty ( ) )
69
- {
70
- tagTemplateResources . AddRange ( apiTags ) ;
71
- }
72
- }
63
+ string requestUrl = string . Format ( GetAllTagsLinkedToProduct ,
64
+ this . BaseUrl , azSubId , extractorParameters . ResourceGroup , extractorParameters . SourceApimName , productName , GlobalConstants . ApiVersion ) ;
73
65
74
- return tagTemplateResources ;
66
+ return await this . GetPagedResponseAsync < TagTemplateResource > ( azToken , requestUrl ) ;
75
67
}
76
68
}
77
69
}
0 commit comments