in src/PSRule.Rules.Azure/Pipeline/Export/ResourceExportVisitor.cs [690:767]
private static async Task<bool> VisitAPIManagement(ResourceContext context, JObject resource, string resourceType, string resourceId)
{
if (!string.Equals(resourceType, TYPE_APIMANAGEMENT_SERVICE, StringComparison.OrdinalIgnoreCase))
return false;
// APIs
var apis = await GetSubResourcesByType(context, resourceId, "apis", APIVERSION_2022_08_01);
AddSubResource(resource, apis);
foreach (var api in apis)
{
var apiResourceId = api[PROPERTY_ID].Value<string>();
var apiType = api[PROPERTY_TYPE].Value<string>();
var isGraphQL = string.Equals(apiType, "graphql");
// Get policies for each API
AddSubResource(resource, await GetSubResourcesByType(context, apiResourceId, PROPERTY_POLICIES, APIVERSION_2022_08_01));
if (!isGraphQL)
{
// Get each operation
var operations = await GetSubResourcesByType(context, apiResourceId, "operations", APIVERSION_2022_08_01);
foreach (var operation in operations)
{
AddSubResource(resource, await GetSubResourcesByType(context, operation[PROPERTY_ID].Value<string>(), PROPERTY_POLICIES, APIVERSION_2022_08_01));
}
}
// Get each resolver
if (isGraphQL)
{
var resolvers = await GetSubResourcesByType(context, apiResourceId, "resolvers", APIVERSION_2022_08_01);
foreach (var resolver in resolvers)
{
AddSubResource(resource, await GetSubResourcesByType(context, resolver[PROPERTY_ID].Value<string>(), PROPERTY_POLICIES, APIVERSION_2022_08_01));
}
}
}
var backends = await GetSubResourcesByType(context, resourceId, "backends", APIVERSION_2022_08_01);
AddSubResource(resource, backends);
var products = await GetSubResourcesByType(context, resourceId, "products", APIVERSION_2022_08_01);
AddSubResource(resource, products);
foreach (var product in products)
{
// Get policies for each product
AddSubResource(resource, await GetSubResourcesByType(context, product[PROPERTY_ID].Value<string>(), PROPERTY_POLICIES, APIVERSION_2022_08_01));
}
var policies = await GetSubResourcesByType(context, resourceId, PROPERTY_POLICIES, APIVERSION_2022_08_01);
AddSubResource(resource, policies);
var identityProviders = await GetSubResourcesByType(context, resourceId, "identityProviders", APIVERSION_2022_08_01);
AddSubResource(resource, identityProviders);
var diagnostics = await GetSubResourcesByType(context, resourceId, "diagnostics", APIVERSION_2022_08_01);
AddSubResource(resource, diagnostics);
var loggers = await GetSubResourcesByType(context, resourceId, "loggers", APIVERSION_2022_08_01);
AddSubResource(resource, loggers);
var certificates = await GetSubResourcesByType(context, resourceId, "certificates", APIVERSION_2022_08_01);
AddSubResource(resource, certificates);
var namedValues = await GetSubResourcesByType(context, resourceId, "namedValues", APIVERSION_2022_08_01);
AddSubResource(resource, namedValues);
var authorizationServers = await GetSubResourcesByType(context, resourceId, "authorizationServers", APIVERSION_2022_08_01);
AddSubResource(resource, authorizationServers);
var portalSettings = await GetSubResourcesByType(context, resourceId, "portalsettings", APIVERSION_2022_08_01);
AddSubResource(resource, portalSettings);
var apiCollections = await GetSubResourcesByProvider(context, resourceId, PROVIDERTYPE_APICOLLECTIONS, APIVERSION_2022_11_20_PREVIEW);
AddSubResource(resource, apiCollections);
return true;
}