public IActionResult Get() { var content = new { version = _apiVersionProvider.Version, informationalVersion = _apiVersionProvider.InformationalVersion, suite = _apiVersionProvider.Suite, build = _apiVersionProvider.Build, apiMode = _apiSettings.GetApiMode().DisplayName, dataModels = _domainModelProvider .GetDomainModel() .Schemas .Select( s => new { name = s.LogicalName, version = s.Version }) .ToArray(), urls = GetUrlsByName() }; return(Ok(content)); Dictionary <string, string> GetUrlsByName() { var currentYear = _systemDateProvider.GetDate().Year.ToString(); // since instance is dynamic and given through url, this value is just a place holder var instance = "{instance}"; bool isInstanceYearSpecific = _apiSettings.GetApiMode().Equals(ApiMode.InstanceYearSpecific); bool isYearSpecific = _apiSettings.GetApiMode().Equals(ApiMode.YearSpecific) || isInstanceYearSpecific; bool useReverseProxyHeaders = _apiSettings.UseReverseProxyHeaders ?? false; var urlsByName = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase); if (_apiSettings.IsFeatureEnabled(ApiFeature.AggregateDependencies.GetConfigKeyName())) { urlsByName["dependencies"] = Request.RootUrl(useReverseProxyHeaders) + (isInstanceYearSpecific ? $"/metadata/data/v{ApiVersionConstants.Ods}/" + $"{instance}/" + currentYear + "/dependencies" : (isYearSpecific ? $"/metadata/data/v{ApiVersionConstants.Ods}/" + currentYear + "/dependencies" : $"/metadata/data/v{ApiVersionConstants.Ods}/dependencies")); } if (_apiSettings.IsFeatureEnabled(ApiFeature.OpenApiMetadata.GetConfigKeyName())) { urlsByName["openApiMetadata"] = Request.RootUrl(useReverseProxyHeaders) + "/metadata/" + (isInstanceYearSpecific ? $"{instance}/" : string.Empty) + (isYearSpecific ? currentYear : string.Empty); } urlsByName["oauth"] = Request.RootUrl(useReverseProxyHeaders) + (isInstanceYearSpecific ? $"/{instance}" : string.Empty) + "/oauth/token"; urlsByName["dataManagementApi"] = Request.RootUrl(useReverseProxyHeaders) + $"/data/v{ApiVersionConstants.Ods}/" + (isInstanceYearSpecific ? $"{instance}/" : string.Empty) + (isYearSpecific ? currentYear : string.Empty); if (_apiSettings.IsFeatureEnabled(ApiFeature.XsdMetadata.GetConfigKeyName())) { urlsByName["xsdMetadata"] = Request.RootUrl(useReverseProxyHeaders) + "/metadata/" + (isInstanceYearSpecific ? $"{instance}/" : string.Empty) + (isYearSpecific ? $"{currentYear}/" : string.Empty) + "xsd"; } return(urlsByName); } }
public IActionResult Get() { var dataModels = _domainModelProvider .GetDomainModel() .Schemas .Select( s => new { name = s.LogicalName, version = s.Version }) .ToArray(); var exposedUrls = GetUrls(); var content = new { version = _apiVersionProvider.Version, informationalVersion = _apiVersionProvider.InformationalVersion, suite = _apiVersionProvider.Suite, build = _apiVersionProvider.Build, apiMode = _apiSettings.GetApiMode().DisplayName, dataModels = dataModels, urls = new { openApiMetadata = exposedUrls.MetaDataUrl, dependencies = exposedUrls.DependenciesUrl, oauth = exposedUrls.OauthUrl, dataManagementApi = exposedUrls.ApiUrl, } }; return(Ok(content)); ExposedUrls GetUrls() { var currentYear = _systemDateProvider.GetDate().Year.ToString(); // since instance is dynamic and given through url, this value is just a place holder var instance = "{instance}"; bool isYearSpecific = _apiSettings.GetApiMode().Equals(ApiMode.YearSpecific); bool isInstanceYearSpecific = _apiSettings.GetApiMode().Equals(ApiMode.InstanceYearSpecific); //This also involves year itself, thus year needs to be true if (isInstanceYearSpecific) { isYearSpecific = true; } bool useReverseProxyHeaders = _apiSettings.UseReverseProxyHeaders ?? false; var exposedUrls = new ExposedUrls { DependenciesUrl = Request.RootUrl(useReverseProxyHeaders) + (isInstanceYearSpecific ? $"/metadata/data/v{ApiVersionConstants.Ods}/" + $"{instance}/" + currentYear + "/dependencies" : (isYearSpecific ? $"/metadata/data/v{ApiVersionConstants.Ods}/" + currentYear + "/dependencies" : $"/metadata/data/v{ApiVersionConstants.Ods}/dependencies")), MetaDataUrl = Request.RootUrl(useReverseProxyHeaders) + "/metadata/" + (isInstanceYearSpecific ? $"{instance}/" : string.Empty) + (isYearSpecific ? currentYear : string.Empty), OauthUrl = Request.RootUrl(useReverseProxyHeaders) + (isInstanceYearSpecific ? $"/{instance}" : string.Empty) + "/oauth/token", ApiUrl = Request.RootUrl(useReverseProxyHeaders) + $"/data/v{ApiVersionConstants.Ods}/" + (isInstanceYearSpecific ? $"{instance}/" : string.Empty) + (isYearSpecific ? currentYear : string.Empty) }; return(exposedUrls); } }