public async Task <IActionResult> GetDetector(string subscriptionId, string resourceGroupName, string hostingEnvironmentName, string detectorId, [FromBody] DiagnosticStampData postBody, string startTime = null, string endTime = null, string timeGrain = null) { if (postBody == null) { postBody = await GetHostingEnvironmentPostBody(hostingEnvironmentName); } if (!DateTimeHelper.PrepareStartEndTimeWithTimeGrain(startTime, endTime, timeGrain, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage)) { return(BadRequest(errorMessage)); } HostingEnvironment ase = await GetHostingEnvironment(subscriptionId, resourceGroupName, hostingEnvironmentName, postBody, startTimeUtc, endTimeUtc); return(await base.GetDetector(ase, detectorId, startTime, endTime, timeGrain)); }
public async Task <IActionResult> ListDetectors(string subscriptionId, string resourceGroupName, string hostingEnvironmentName, [FromBody] DiagnosticStampData postBody) { if (postBody == null) { postBody = await GetHostingEnvironmentPostBody(hostingEnvironmentName); } DateTimeHelper.PrepareStartEndTimeWithTimeGrain(string.Empty, string.Empty, string.Empty, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage); HostingEnvironment ase = await GetHostingEnvironment(subscriptionId, resourceGroupName, hostingEnvironmentName, postBody, startTimeUtc, endTimeUtc); return(await base.ListDetectors(ase)); }
// Purposefully leaving this method in Base class. This method is shared between two resources right now - HostingEnvironment and WebApp protected async Task <HostingEnvironment> GetHostingEnvironment(string subscriptionId, string resourceGroup, string name, DiagnosticStampData stampPostBody, DateTime startTime, DateTime endTime) { if (stampPostBody == null) { return(new HostingEnvironment(subscriptionId, resourceGroup, name)); } HostingEnvironment hostingEnv = new HostingEnvironment(subscriptionId, resourceGroup, name) { Name = stampPostBody.InternalName, InternalName = stampPostBody.InternalName, ServiceAddress = stampPostBody.ServiceAddress, State = stampPostBody.State, DnsSuffix = stampPostBody.DnsSuffix, UnhealthySince = stampPostBody.UnhealthySince, SuspendedOn = stampPostBody.SuspendedOn, Location = stampPostBody.Location }; switch (stampPostBody.Kind) { case DiagnosticStampType.ASEV1: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.V1; break; case DiagnosticStampType.ASEV2: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.V2; break; default: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.None; break; } string stampName = !string.IsNullOrWhiteSpace(hostingEnv.InternalName) ? hostingEnv.InternalName : hostingEnv.Name; var result = await this._stampService.GetTenantIdForStamp(stampName, hostingEnv.HostingEnvironmentType == HostingEnvironmentType.None, startTime, endTime, (DataProviderContext)HttpContext.Items[HostConstants.DataProviderContextKey]); hostingEnv.TenantIdList = result.Item1; hostingEnv.PlatformType = result.Item2; return(hostingEnv); }
// Purposefully leaving this method in Base class. This method is shared between two resources right now - HostingEnvironment and WebApp protected async Task <HostingEnvironment> GetHostingEnvironment(string subscriptionId, string resourceGroup, string name, DiagnosticStampData stampPostBody, DateTime startTime, DateTime endTime) { if (stampPostBody == null) { return(new HostingEnvironment(subscriptionId, resourceGroup, name)); } string requestId = string.Empty; if (this.Request.Headers.TryGetValue(HeaderConstants.RequestIdHeaderName, out StringValues requestIds)) { requestId = requestIds.FirstOrDefault() ?? string.Empty; } HostingEnvironment hostingEnv = new HostingEnvironment(subscriptionId, resourceGroup, name) { InternalName = stampPostBody.InternalName, ServiceAddress = stampPostBody.ServiceAddress, State = stampPostBody.State, DnsSuffix = stampPostBody.DnsSuffix, UnhealthySince = stampPostBody.UnhealthySince, SuspendedOn = stampPostBody.SuspendedOn, Location = stampPostBody.Location }; switch (stampPostBody.Kind) { case DiagnosticStampType.ASEV1: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.V1; break; case DiagnosticStampType.ASEV2: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.V2; break; default: hostingEnv.HostingEnvironmentType = HostingEnvironmentType.None; break; } string stampName = !string.IsNullOrWhiteSpace(hostingEnv.InternalName) ? hostingEnv.InternalName : hostingEnv.Name; var result = await this._stampService.GetTenantIdForStamp(stampName, startTime, endTime, requestId); hostingEnv.TenantIdList = result.Item1; hostingEnv.PlatformType = result.Item2; return(hostingEnv); }
public async Task <IActionResult> GetInsights(string subscriptionId, string resourceGroupName, string hostingEnvironmentName, [FromBody] DiagnosticStampData postBody, string supportTopicId, string minimumSeverity = null, string startTime = null, string endTime = null, string timeGrain = null) { if (postBody == null) { return(BadRequest("Post Body missing.")); } if (!DateTimeHelper.PrepareStartEndTimeWithTimeGrain(startTime, endTime, timeGrain, out DateTime startTimeUtc, out DateTime endTimeUtc, out TimeSpan timeGrainTimeSpan, out string errorMessage)) { return(BadRequest(errorMessage)); } HostingEnvironment ase = await GetHostingEnvironment(subscriptionId, resourceGroupName, hostingEnvironmentName, postBody, startTimeUtc, endTimeUtc); return(await base.GetInsights(ase, supportTopicId, minimumSeverity, startTime, endTime, timeGrain)); }