diff --git a/LogicMonitor.DataSDK.Tests/TestApiClient.cs b/LogicMonitor.DataSDK.Tests/TestApiClient.cs index a0aa986..af0439a 100644 --- a/LogicMonitor.DataSDK.Tests/TestApiClient.cs +++ b/LogicMonitor.DataSDK.Tests/TestApiClient.cs @@ -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 diff --git a/LogicMonitor.DataSDK.Tests/TestConfiguration.cs b/LogicMonitor.DataSDK.Tests/TestConfiguration.cs index 33e297f..08c19ec 100644 --- a/LogicMonitor.DataSDK.Tests/TestConfiguration.cs +++ b/LogicMonitor.DataSDK.Tests/TestConfiguration.cs @@ -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 @@ -53,6 +53,7 @@ public void TestCheckAuthenticationBearer() Assert.AreEqual(null, msg); } + [Test] public void TestNullCompany() { @@ -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) @@ -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); + } + } } diff --git a/LogicMonitor.DataSDK.Tests/TestRest.cs b/LogicMonitor.DataSDK.Tests/TestRest.cs index 76d9632..0289df6 100644 --- a/LogicMonitor.DataSDK.Tests/TestRest.cs +++ b/LogicMonitor.DataSDK.Tests/TestRest.cs @@ -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; diff --git a/LogicMonitor.DataSDK.Tests/Utils/TestObjectNameValidator.cs b/LogicMonitor.DataSDK.Tests/Utils/TestObjectNameValidator.cs index 035f93e..ba0befa 100644 --- a/LogicMonitor.DataSDK.Tests/Utils/TestObjectNameValidator.cs +++ b/LogicMonitor.DataSDK.Tests/Utils/TestObjectNameValidator.cs @@ -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 diff --git a/LogicMonitor.DataSDK/Api/IResponseInterface.cs b/LogicMonitor.DataSDK/Api/IResponseInterface.cs index e837ebf..1bb9977 100644 --- a/LogicMonitor.DataSDK/Api/IResponseInterface.cs +++ b/LogicMonitor.DataSDK/Api/IResponseInterface.cs @@ -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 diff --git a/LogicMonitor.DataSDK/Api/Logs.cs b/LogicMonitor.DataSDK/Api/Logs.cs index 5993493..ef4b0d6 100644 --- a/LogicMonitor.DataSDK/Api/Logs.cs +++ b/LogicMonitor.DataSDK/Api/Logs.cs @@ -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 diff --git a/LogicMonitor.DataSDK/Api/Metrics.cs b/LogicMonitor.DataSDK/Api/Metrics.cs index 42ca489..bd1b406 100644 --- a/LogicMonitor.DataSDK/Api/Metrics.cs +++ b/LogicMonitor.DataSDK/Api/Metrics.cs @@ -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 diff --git a/LogicMonitor.DataSDK/ApiClient.cs b/LogicMonitor.DataSDK/ApiClient.cs index 283cb21..b7841ad 100644 --- a/LogicMonitor.DataSDK/ApiClient.cs +++ b/LogicMonitor.DataSDK/ApiClient.cs @@ -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 diff --git a/LogicMonitor.DataSDK/Configuration.cs b/LogicMonitor.DataSDK/Configuration.cs index 1c4def4..99778df 100644 --- a/LogicMonitor.DataSDK/Configuration.cs +++ b/LogicMonitor.DataSDK/Configuration.cs @@ -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 @@ -11,6 +11,7 @@ using LogicMonitor.DataSDK.Model; using System.ComponentModel.DataAnnotations; using System.Text; +using Newtonsoft.Json.Linq; namespace LogicMonitor.DataSDK { @@ -41,6 +42,12 @@ public class Configuration /// Use BearerToken property to set the BearerToken while using Bearer authentication. /// public string BearerToken { get; set; } + + /// + /// Set custom endpoint. + /// + public string DomainName { get; set; } + /// /// Use this property to set the Account name(Company Name). /// @@ -50,7 +57,6 @@ public string Company set { this._company = value; - this._host = "https://" + this._company + ".logicmonitor.com/rest"; } } /// @@ -71,7 +77,8 @@ 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(); @@ -79,8 +86,10 @@ public Configuration(string company = null, string accessID = null, string acces 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(); + } @@ -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; } diff --git a/LogicMonitor.DataSDK/Constants.cs b/LogicMonitor.DataSDK/Constants.cs index 41215f7..39f89d9 100644 --- a/LogicMonitor.DataSDK/Constants.cs +++ b/LogicMonitor.DataSDK/Constants.cs @@ -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 diff --git a/LogicMonitor.DataSDK/LogicMonitor.DataSDK.csproj b/LogicMonitor.DataSDK/LogicMonitor.DataSDK.csproj index 5efbe6b..183da8d 100644 --- a/LogicMonitor.DataSDK/LogicMonitor.DataSDK.csproj +++ b/LogicMonitor.DataSDK/LogicMonitor.DataSDK.csproj @@ -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 - Copyright, 2022, LogicMonitor, Inc. + Copyright, 2024, LogicMonitor, Inc. LogicMonitor.DataSDK MPL-2.0 LM_Icon.png SDK - 0.1.4-alpha - Summary: What's new in 0.1.4-alpha:- -- Added ability to pass Log Level with a log entry. + 0.1.5-alpha + Summary: What's new in 0.1.5-alpha:- +- Updated Configuration to entry custom endpoint . true en-US Logicmonitor 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. LogicMonitor PushMetricSDK - 0.1.4-alpha + 0.1.5-alpha Release;Debug diff --git a/LogicMonitor.DataSDK/Utils/ObjectNameValidator.cs b/LogicMonitor.DataSDK/Utils/ObjectNameValidator.cs index a0f1ba5..087c643 100644 --- a/LogicMonitor.DataSDK/Utils/ObjectNameValidator.cs +++ b/LogicMonitor.DataSDK/Utils/ObjectNameValidator.cs @@ -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