/// <summary> /// Initializes a new instance of the <see cref="CostAggregationService"/> class. /// </summary> /// <param name="settings"><see cref="ICostMonitoringSettings"/> instance.</param> /// <param name="dbContext"><see cref="IMonitoringDbContext"/> instance.</param> /// <param name="auth"><see cref="IAzureAuthenticationHelperWrapper"/> instance.</param> /// <param name="billing"><see cref="IAzureBillingApiClientHelper"/> instance.</param> /// <param name="httpClient"><see cref="IHttpClientHelper"/> instance.</param> public CostAggregationService(ICostMonitoringSettings settings, IMonitoringDbContext dbContext, IAzureAuthenticationHelperWrapper auth, IAzureBillingApiClientHelper billing, IHttpClientHelper httpClient) { this._settings = settings.ThrowIfNullOrEmpty(); this._dbContext = dbContext.ThrowIfNullOrEmpty(); this._auth = auth.ThrowIfNullOrEmpty(); this._billing = billing.ThrowIfNullOrEmpty(); this._httpClient = httpClient.ThrowIfNullOrEmpty(); }
/// <summary> /// Initializes a new instance of the <see cref="AzureBillingApiClientWrapper"/> class. /// </summary> /// <param name="settings"><see cref="AuthenticationSettings"/> instance.</param> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is <see langword="null"/></exception> /// <exception cref="InvalidOperationException">Authentication settings not found</exception> public AzureBillingApiClientWrapper(ICostMonitoringSettings settings) { settings.ThrowIfNullOrEmpty(); if (settings.Authentication.IsNullOrEmpty()) { throw new InvalidOperationException("Authentication settings not found"); } this._auth = settings.Authentication; }
public string GetOAuthTokenFromAad(ICostMonitoringSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var auth = settings.Authentication; if (auth == null) { throw new InvalidOperationException("Authentication settings not found"); } var resources = settings.Resources; if (resources == null) { throw new InvalidOperationException("Resources settings not found"); } return(AzureAuthenticationHelper.GetOAuthTokenFromAAD(auth.AadLoginUrl, auth.TenantId, resources.BaseUrl, auth.RedirectUrl, auth.ApplicationId, auth.ApplicationSecret)); }
/// <summary> /// Initializes a new instance of the <see cref="AzureBillingApiClientHelper"/> class. /// </summary> /// <param name="settings"><see cref="ICostMonitoringSettings"/> instance.</param> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is <see langword="null"/></exception> public AzureBillingApiClientHelper(ICostMonitoringSettings settings) { this._settings = settings.ThrowIfNullOrEmpty(); this._wrapper = new AzureBillingApiClientWrapper(this._settings); }
/// <summary> /// Initializes a new instance of the <see cref="CostReminderService"/> class. /// </summary> /// <param name="settings"><see cref="ICostMonitoringSettings"/> instance.</param> /// <param name="dbContext"><see cref="IMonitoringDbContext"/> instance.</param> public CostReminderService(ICostMonitoringSettings settings, IMonitoringDbContext dbContext) { this._settings = settings.ThrowIfNullOrEmpty(); this._dbContext = dbContext.ThrowIfNullOrEmpty(); }
/// <summary> /// Initializes a new instance of the <see cref="CostMonitoringSettingsTests"/> class. /// </summary> /// <param name="fixture"><see cref="CostMonitoringSettingsFixture"/> instance.</param> public CostMonitoringSettingsTests(CostMonitoringSettingsFixture fixture) { this._settings = fixture.Settings; }