public async Task <PolicyProductTemplateResource> Create(ProductDeploymentDefinition product, string[] dependsOn) { var fileReader = new FileReader(); var isUrl = product.Policy.IsUri(out _); var policyTemplateResource = new PolicyProductTemplateResource() { Name = $"[concat(parameters('ApimServiceName'), '/{product.Name}/policy')]", Properties = new PolicyProductProperties() { Format = isUrl ? "rawxml-link" : "rawxml", Value = isUrl ? product.Policy : await fileReader.RetrieveFileContentsAsync(product.Policy) }, DependsOn = dependsOn }; return(policyTemplateResource); }
public List <TagProductTemplateResource> Create(ProductDeploymentDefinition product, string[] dependsOn) { var tagProductTemplates = new List <TagProductTemplateResource>(); var tagDisplayNames = product.TagList; foreach (string tagDisplayName in tagDisplayNames) { var tagName = GetTagName(tagDisplayName); var tagProductTemplate = new TagProductTemplateResource() { Name = $"[concat(parameters('ApimServiceName'), '/{product.Name}/{tagName}')]", Properties = new TagProductTemplateProperties(), DependsOn = dependsOn }; tagProductTemplates.Add(tagProductTemplate); } return(tagProductTemplates); }
private async Task <IEnumerable <TemplateResource> > CreateChildResourceTemplates(ProductDeploymentDefinition product) { var resources = new List <TemplateResource>(); var dependsOn = new string[] { $"[resourceId('{ResourceType.Product}', parameters('ApimServiceName'), '{product.Name}')]" }; if (product.IsDependOnPolicy()) { resources.Add(await _policyProductTemplateCreator.Create(product, dependsOn)); } if (product.IsDependOnTags()) { resources.AddRange(_tagProductTemplateCreator.Create(product, dependsOn)); } return(resources); }