Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnmbond committed Apr 22, 2024
2 parents 7d1b961 + 584196a commit af5df5a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
15 changes: 15 additions & 0 deletions LogicMonitor.Api.Test/Users/RoleTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace LogicMonitor.Api.Test.Users;

public class RoleTests(ITestOutputHelper iTestOutputHelper) : TestWithOutput(iTestOutputHelper)
{
[Fact]
public async Task GetAll()
{
var items = await LogicMonitorClient
.GetAllAsync<Role>(default)
.ConfigureAwait(true);

items.Should().NotBeNull();
items.Should().NotBeNullOrEmpty();
}
}
19 changes: 19 additions & 0 deletions LogicMonitor.Api/Alerts/InstanceGroupAlertThresholdInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,23 @@ public class InstanceGroupAlertThresholdInfo
/// </summary>
[DataMember(Name = "alertExpr")]
public string AlertExpression { get; set; } = string.Empty;

/// <summary>
/// The alert transition interval
/// </summary>
[DataMember(Name = "alertTransitionInterval")]
public string AlertTransitionInterval { get; set; } = string.Empty;

/// <summary>
/// The alert clear transition interval
/// </summary>
[DataMember(Name = "alertClearTransitionInterval")]
public string AlertClearTransitionInterval { get; set; } = string.Empty;

/// <summary>
/// The alert for no data value
/// </summary>
[DataMember(Name = "alertForNoData")]
public int AlertForNoData { get; set; }

}
8 changes: 7 additions & 1 deletion LogicMonitor.Api/LogicModules/DataPointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,13 @@ public class DataPointConfiguration : IdentifiedItem
/// Parent Instance Group Alert Expression
/// </summary>
[DataMember(Name = "parentInstanceGroupAlertExpr")]
public string ParentInstanceGroupAlertExpression { get; set; } = string.Empty;
public InstanceGroupAlertThresholdInfo? ParentInstanceGroupAlertExpression { get; set; }

/// <summary>
/// Parent Resource Group Alert Expression
/// </summary>
[DataMember(Name = "parentResourceDataSourceAlertExpr")]
public object? ParentResourceDataSourceAlertExpr { get; set; }

/// <summary>
/// Alert for no data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ public class DataPointConfigurationCreationDTO : IdentifiedItem
/// Parent Instance Group Alert Expression
/// </summary>
[DataMember(Name = "parentInstanceGroupAlertExpr")]
public string ParentInstanceGroupAlertExpression { get; set; } = string.Empty;
public InstanceGroupAlertThresholdInfo? ParentInstanceGroupAlertExpression { get; set; }
}
11 changes: 5 additions & 6 deletions LogicMonitor.Api/LogicMonitorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public async Task PutAsync(string subUrl, object @item, CancellationToken cancel
// Check the outer HTTP status code
if (!httpResponseMessage.IsSuccessStatusCode)
{
if ((int)httpResponseMessage.StatusCode != 429 && httpResponseMessage.ReasonPhrase != "Too Many Requests")
if ((int)httpResponseMessage.StatusCode != 429)
{
if (WaitDuringLogicMonitorUpgrades && httpResponseMessage.StatusCode == HttpStatusCode.ServiceUnavailable)
{
Expand Down Expand Up @@ -870,7 +870,7 @@ public async Task DeleteAsync(string subUrl, CancellationToken cancellationToken
// Check the outer HTTP status code
if (!httpResponseMessage.IsSuccessStatusCode)
{
if ((int)httpResponseMessage.StatusCode != 429 && httpResponseMessage.ReasonPhrase != "Too Many Requests")
if ((int)httpResponseMessage.StatusCode != 429)
{
if (WaitDuringLogicMonitorUpgrades && httpResponseMessage.StatusCode == HttpStatusCode.ServiceUnavailable)
{
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public async Task DeleteAsync(string subUrl, CancellationToken cancellationToken
// NOT A SUCCESS :-(

var statusCode = (int)httpResponseMessage.StatusCode;
var tooManyRequests = statusCode == 429 && httpResponseMessage.ReasonPhrase.Equals("Too Many Requests", StringComparison.OrdinalIgnoreCase);
var tooManyRequests = statusCode == 429;

if (!tooManyRequests)
{
Expand Down Expand Up @@ -1188,11 +1188,10 @@ public async Task DeleteAsync(string subUrl, CancellationToken cancellationToken
if (!httpResponseMessage.IsSuccessStatusCode)
{

if ((int)httpResponseMessage.StatusCode != 429 && httpResponseMessage.ReasonPhrase != "Too Many Requests")
if ((int)httpResponseMessage.StatusCode != 429)
{
if (WaitDuringLogicMonitorUpgrades && httpResponseMessage.StatusCode == HttpStatusCode.ServiceUnavailable)
{
// TODO: could also check the reason phrase, and / or the RESPONSE (which contains "Service Temporarily Unavailable")
_logger.LogDebug("{Prefix} Service Unavailable. Waiting 10000ms", prefix);
await Task.Delay(10000, cancellationToken).ConfigureAwait(false);
continue;
Expand Down Expand Up @@ -1296,7 +1295,7 @@ public async Task DeleteAsync(string subUrl, CancellationToken cancellationToken
// Check the outer HTTP status code
if (!httpResponseMessage.IsSuccessStatusCode)
{
if ((int)httpResponseMessage.StatusCode != 429 && httpResponseMessage.ReasonPhrase != "Too Many Requests")
if ((int)httpResponseMessage.StatusCode != 429)
{
if (WaitDuringLogicMonitorUpgrades && httpResponseMessage.StatusCode == HttpStatusCode.ServiceUnavailable)
{
Expand Down
8 changes: 7 additions & 1 deletion LogicMonitor.Api/Users/PrivilegeObjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@ public enum PrivilegeObjectType
/// Module
/// </summary>
[DataMember(Name = "module")]
Module
Module,

/// <summary>
/// Cost Optimzsation
/// </summary>
[DataMember(Name = "costOptimization")]
CostOptimization
}
6 changes: 6 additions & 0 deletions LogicMonitor.Api/Users/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ public class User : IdentifiedItem, IHasEndpoint
[DataMember(Name = "immediateForceLogout")]
public bool ImmediateForceLogout { get; set; }

/// <summary>
/// The last authorized IP address
/// </summary>
[DataMember(Name = "lastAuthIp")]
public string LastAuthIp { get; set; } = string.Empty;

/// <summary>
/// The endpoint
/// </summary>
Expand Down

0 comments on commit af5df5a

Please sign in to comment.