Skip to content

Commit

Permalink
Merge pull request #28 from AakashKhopade/EndpointChange
Browse files Browse the repository at this point in the history
Endpoint change
  • Loading branch information
AakashKhopade authored Dec 27, 2024
2 parents 8b25bd8 + 5485eb2 commit b179dfc
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK.Tests/TestApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2021, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
20 changes: 17 additions & 3 deletions LogicMonitor.DataSDK.Tests/TestConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2021, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down Expand Up @@ -53,6 +53,7 @@ public void TestCheckAuthenticationBearer()

Assert.AreEqual(null, msg);
}

[Test]
public void TestNullCompany()
{
Expand All @@ -67,10 +68,12 @@ public void TestNullCompany()
Assert.AreEqual("Company must have your account name", e.Message);
}
}


[TestCase("https://lmabcd.logicmonitor.com/rest")]
public void TestHost(string expected)
{
Assert.AreEqual(expected, config.host);
Assert.AreEqual(expected, config.host);
}
[TestCase(false)]
public void TestAsyncRequestGet(bool async)
Expand Down Expand Up @@ -102,5 +105,16 @@ public void TestCompanySet(string company)
Assert.AreEqual(company, config.Company);
}

}
[TestCase("lmabcd")]
public void TestDomainNameGet(string DomainName)
{
Assert.AreEqual(DomainName, config.Company);
}
[TestCase("lmabcd")]
public void TestDomainNameSet(string DomainName)
{
config.DomainName = "lmabcd";
Assert.AreEqual(DomainName, config.Company);
}
}
}
9 changes: 8 additions & 1 deletion LogicMonitor.DataSDK.Tests/TestRest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
using System;
/*
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
* one at https://mozilla.org/MPL/2.0/.
*/
using System;
using System.Collections.Generic;
using System.Net;
using LogicMonitor.DataSDK.Model;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2021, LogicMonitor, Inc.
* Copyright, 2024, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/Api/IResponseInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/Api/Logs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/Api/Metrics.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
25 changes: 20 additions & 5 deletions LogicMonitor.DataSDK/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand All @@ -11,6 +11,7 @@
using LogicMonitor.DataSDK.Model;
using System.ComponentModel.DataAnnotations;
using System.Text;
using Newtonsoft.Json.Linq;

namespace LogicMonitor.DataSDK
{
Expand Down Expand Up @@ -41,6 +42,12 @@ public class Configuration
/// Use BearerToken property to set the BearerToken while using Bearer authentication.
/// </summary>
public string BearerToken { get; set; }

/// <summary>
/// Set custom endpoint.
/// </summary>
public string DomainName { get; set; }

/// <summary>
/// Use this property to set the Account name(Company Name).
/// </summary>
Expand All @@ -50,7 +57,6 @@ public string Company
set
{
this._company = value;
this._host = "https://" + this._company + ".logicmonitor.com/rest";
}
}
/// <summary>
Expand All @@ -71,16 +77,19 @@ public Configuration()

}

public Configuration(string company = null, string accessID = null, string accessKey = null, string bearerToken = null)

public Configuration(string company = null, string domainName = "logicmonitor.com", string accessID = null, string accessKey = null, string bearerToken = null)
{
objectNameValidator = new ObjectNameValidator();

_company = company ??= Environment.GetEnvironmentVariable("LM_COMPANY");
AccessID = accessID ??= Environment.GetEnvironmentVariable("LM_ACCESS_ID");
AccessKey = accessKey ??= Environment.GetEnvironmentVariable("LM_ACCESS_KEY");
BearerToken = bearerToken ??= Environment.GetEnvironmentVariable("LM_BEARER_TOKEN");

DomainName = domainName ??= Environment.GetEnvironmentVariable("LM_DOMAIN_NAME");

CheckAuthentication();

}


Expand Down Expand Up @@ -123,7 +132,13 @@ public bool CheckAuthentication()
throw new ArgumentException("Invalid Company Name");
}

this._host = "https://" + this._company + ".logicmonitor.com/rest";
//add validate for domain name
//change chost property
if (DomainName == null)
{
DomainName = "logicmonitor.com";
}
this._host = "https://" + this._company + "." + DomainName + "/rest";
this.ConnectionPoolMaxsize = Environment.ProcessorCount * 5;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down
10 changes: 5 additions & 5 deletions LogicMonitor.DataSDK/LogicMonitor.DataSDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ For more details kindly refer -
GitHub repository: https://github.com/logicmonitor/lm-data-sdk-dotnet
API reference: https://logicmonitor.github.io/lm-data-sdk-dotnet
</Description>
<Copyright>Copyright, 2022, LogicMonitor, Inc.</Copyright>
<Copyright>Copyright, 2024, LogicMonitor, Inc.</Copyright>
<RootNamespace>LogicMonitor.DataSDK</RootNamespace>
<PackageLicenseExpression>MPL-2.0</PackageLicenseExpression>
<PackageIcon>LM_Icon.png</PackageIcon>
<repositorytype>SDK</repositorytype>
<Version>0.1.4-alpha</Version>
<PackageReleaseNotes>Summary: What's new in 0.1.4-alpha:-
- Added ability to pass Log Level with a log entry.
<Version>0.1.5-alpha</Version>
<PackageReleaseNotes>Summary: What's new in 0.1.5-alpha:-
- Updated Configuration to entry custom endpoint .
</PackageReleaseNotes>
<PackOnBuild>true</PackOnBuild>
<NeutralLanguage>en-US</NeutralLanguage>
<Owners>Logicmonitor</Owners>
<Summary>Allows you to send metrics directly to the LogicMonitor platform via a dedicated API, removing the need to route the data through a LogicMonitor Collector.</Summary>
<Title>LogicMonitor PushMetricSDK</Title>
<PackageVersion>0.1.4-alpha</PackageVersion>
<PackageVersion>0.1.5-alpha</PackageVersion>
<Configurations>Release;Debug</Configurations>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion LogicMonitor.DataSDK/Utils/ObjectNameValidator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright, 2022, LogicMonitor, Inc.
* Copyright, 2025, LogicMonitor, Inc.
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL
* was not distributed with this file, You can obtain
Expand Down

0 comments on commit b179dfc

Please sign in to comment.