public async Task <IOdsApiFacade> Create(CloudOdsEnvironment environment) { Preconditions.ThrowIfNull(environment, nameof(environment)); var restClient = await _restClientFactory.Create(environment); return(new OdsApiFacade(_mapper, restClient)); }
public async Task <ActionResult> Edit(int applicationId, CloudOdsEnvironment environment) { var application = _getApplicationByIdQuery.Execute(applicationId); var apiFacade = await _odsApiFacadeFactory.Create(environment); var leas = apiFacade.GetAllLocalEducationAgencies().ToList(); var schools = apiFacade.GetAllSchools().ToList(); var profiles = _mapper.Map <List <ProfileModel> >(_getProfilesQuery.Execute()); var educationOrganizationIds = application.ApplicationEducationOrganizations.Select(x => x.EducationOrganizationId).ToList(); var edOrgType = schools.Any(x => educationOrganizationIds.Contains(x.EducationOrganizationId)) ? ApplicationEducationOrganizationType.School : ApplicationEducationOrganizationType.LocalEducationAgency; var model = new EditApplicationViewModel { ApplicationId = applicationId, ApplicationName = application.DisplayName(), ClaimSetName = application.ClaimSetName, ClaimSetNames = GetClaimSetNames(), EducationOrganizationIds = application.ApplicationEducationOrganizations.Select(x => x.EducationOrganizationId), LocalEducationAgencies = leas, Schools = schools, Environment = environment, ProfileId = application.Profiles.FirstOrDefault()?.ProfileId ?? 0, Profiles = profiles, VendorId = application.Vendor.VendorId, EducationOrganizationType = edOrgType }; return(PartialView("_EditApplicationModal", model)); }
public static string GetPersistedName(string applicationName, CloudOdsEnvironment environment) { var environmentPrefix = GetPersistedNamePrefix(environment); return(applicationName.StartsWith(environmentPrefix) ? applicationName : $"{environmentPrefix}{applicationName}"); }
private static OdsApiCredential ApiCredentialForEnvironment(CloudOdsEnvironment environment) { if (environment == CloudOdsEnvironment.Production) { return(new OdsApiCredential(AzureTestSettingsProvider.GetTestConfigVariable("ProductionApiKey"), AzureTestSettingsProvider.GetTestConfigVariable("ProductionApiSecret"))); } throw new InvalidOperationException($"Cannot provide API credentials for '{environment.DisplayName}' environment"); }
public async Task <IOdsRestClient> Create(CloudOdsEnvironment environment) { Preconditions.ThrowIfNull(environment, nameof(environment)); var connectionInfo = await _odsApiConnectionInformationProvider.GetConnectionInformationForEnvironment(environment); _tokenRetriever = new TokenRetriever(connectionInfo); _restClient = new RestClient(connectionInfo.ApiBaseUrl); return(new OdsRestClient(connectionInfo, _restClient, _tokenRetriever)); }
public async Task UpdateSettings(string instanceName, CloudOdsEnvironment environment, CloudOdsApiWebsiteSettings newSettings) { var instance = await GetCloudOdsInstance(instanceName); var context = new CloudOdsApiOperationContext(instance, environment); await _updateCloudOdsApiWebsiteSettingsCommand.Execute(context, newSettings); }
public async Task <Site> GetApiWebsiteAsync(CloudOdsEnvironment environment) { if (environment == CloudOdsEnvironment.Production) { return(await GetProductionApiWebsiteAsync()); } throw new NotSupportedException("Unsupported value for CloudOdsInstanceManagementTarget"); }
public static CloudOdsWebsite ToCloudOdsWebsite(this Site site) { return(new CloudOdsWebsite { Environment = CloudOdsEnvironment.Parse(site.GetTagValue(CloudOdsTags.Environment)), Role = CloudOdsRole.Parse(site.GetTagValue(CloudOdsTags.Role)), SystemId = site.Id, SystemName = site.Name, Url = site.DefaultHostName }); }
private async Task WarmupApiServer(CloudOdsEnvironment environment) { _logger.Info($"Setup: Warming up {environment.DisplayName} API"); try { (await _odsApiFacadeFactory.Create(environment)).WarmUp(); } catch (Exception ex) { _logger.Error($"Setup: {environment.DisplayName} API Warmup Failed", ex); } }
public static bool IsInEnvironment(this Site site, CloudOdsEnvironment environment) { return(site.HasTagWithValue(CloudOdsTags.Environment, environment.DisplayName)); }
public async Task <OdsApiConnectionInformation> GetConnectionInformationForEnvironment(CloudOdsEnvironment environment) { var apiCredentials = await _getOdsAdminAppApiCredentialsQuery.Execute(); if (ApiCredentialAreCorrupted()) { ThrowSecretCorruptionException(); } return(GetConnectionInformationForEnvironment(environment, apiCredentials.ProductionApiCredential, _instanceContext.Name, _apiModeProvider.GetApiMode())); bool ApiCredentialAreCorrupted() { return(apiCredentials == null || environment == CloudOdsEnvironment.Production && apiCredentials.ProductionApiCredential == null); } void ThrowSecretCorruptionException() { const string message = "This application's API stored key and secret have been corrupted. See <a href=\"https://techdocs.ed-fi.org/display/AP/Troubleshooting\">Ed-Fi Tech Docs</a> for help."; throw new InvalidOperationException(message); } }
protected OdsApiConnectionInformation Run(CloudOdsEnvironment environment, OdsApiCredential apiCredentials) { return(CloudOdsApiConnectionInformationProvider.GetConnectionInformationForEnvironment(environment, apiCredentials, "Ods Instance", ApiMode.Sandbox)); }
public PartialViewResult BulkUploadForm(CloudOdsEnvironment environment) { return(PartialView("_BulkUploadForm", new BulkFileUploadModel { CloudOdsEnvironment = environment })); }
public Task <OdsApiConnectionInformation> GetConnectionInformationForEnvironment(CloudOdsEnvironment environment) { var apiCredentials = ApiCredentialForEnvironment(environment); if (environment == CloudOdsEnvironment.Production) { return(ConnectionInformationForEnvironment(AzureTestSettingsProvider.GetTestConfigVariable("ProductionApiUrl"), apiCredentials)); } throw new InvalidOperationException($"Cannot provide connection information for '{environment.DisplayName}' environment"); }
public static OdsApiConnectionInformation GetConnectionInformationForEnvironment(CloudOdsEnvironment environment, OdsApiCredential apiCredentials, string instanceName, ApiMode apiMode) { if (apiCredentials == null) { throw new ArgumentNullException(nameof(apiCredentials)); } if (string.IsNullOrWhiteSpace(apiCredentials.Key)) { throw new ArgumentException($"{nameof(apiCredentials.Key)} in {nameof(apiCredentials)} cannot be null or whitespace"); } if (string.IsNullOrWhiteSpace(apiCredentials.Secret)) { throw new ArgumentException($"{nameof(apiCredentials.Secret)} in {nameof(apiCredentials)} cannot be null or whitespace"); } if (environment == CloudOdsEnvironment.Production) { return(ConnectionInformationForEnvironment(CloudOdsAdminAppSettings.Instance.ProductionApiUrl, apiCredentials, instanceName, apiMode)); } throw new InvalidOperationException($"Cannot provide connection information for '{environment?.DisplayName ?? "null"}' environment"); }
public CloudOdsApiOperationContext(CloudOdsInstance instance, CloudOdsEnvironment targetEnvironment) { Instance = instance; TargetEnvironment = targetEnvironment; }
public static string GetPersistedNamePrefix(CloudOdsEnvironment environment) { return($"{environment.DisplayName}-"); }
protected Task <OdsApiConnectionInformation> Run(CloudOdsEnvironment environment) { return(_system.GetConnectionInformationForEnvironment(environment)); }
public async Task <CloudOdsApiWebsiteSettings> GetSettings(string instanceName, CloudOdsEnvironment environment) { var instance = await GetCloudOdsInstance(instanceName); var context = new CloudOdsApiOperationContext(instance, environment); return(await _getCloudOdsApiWebsiteSettingsQuery.Execute(context)); }