Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 98fb7ec

Browse files
f-alizadaFarhad Alizada
andauthored
Retrieve product tags from product/tags REST api (#753)
* Retrieve product tags from product. Remove api tag dependency from product. Co-authored-by: Farhad Alizada <falizada@microsoft.com>
1 parent 4de20e6 commit 98fb7ec

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/ArmTemplates/Common/API/Clients/Tags/TagClient.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading.Tasks;
88
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.API.Clients.Abstractions;
99
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Constants;
10-
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Extensions;
1110
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Common.Templates.Tags;
1211
using Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extractor.Models;
1312

@@ -18,6 +17,7 @@ public class TagClient : ApiClientBase, ITagClient
1817
const string GetAllTagsLinkedToApiRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/apis/{4}/tags?api-version={5}&format=rawxml";
1918
const string GetAllTagsRequest = "{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/tags?$skip={4}&api-version={5}";
2019
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}";
2121

2222
readonly IApisClient apisClient;
2323

@@ -48,7 +48,7 @@ public async Task<List<TagTemplateResource>> GetAllAsync(ExtractorParameters ext
4848

4949
public async Task<List<TagTemplateResource>> GetAllTagsLinkedToApiAsync(string apiName, ExtractorParameters extractorParameters)
5050
{
51-
(string azToken, string azSubId) = await this.Auth.GetAccessToken();
51+
var (azToken, azSubId) = await this.Auth.GetAccessToken();
5252

5353
string requestUrl = string.Format(GetAllTagsLinkedToApiRequest,
5454
this.BaseUrl, azSubId, extractorParameters.ResourceGroup, extractorParameters.SourceApimName, apiName, GlobalConstants.ApiVersion);
@@ -58,20 +58,12 @@ public async Task<List<TagTemplateResource>> GetAllTagsLinkedToApiAsync(string a
5858

5959
public async Task<List<TagTemplateResource>> GetAllTagsLinkedToProductAsync(string productName, ExtractorParameters extractorParameters)
6060
{
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();
6762

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);
7365

74-
return tagTemplateResources;
66+
return await this.GetPagedResponseAsync<TagTemplateResource>(azToken, requestUrl);
7567
}
7668
}
7769
}

0 commit comments

Comments
 (0)