public async void GetIntegrations()
        {
            var integrations = await PortalClient.GetAllAsync <Integration>().ConfigureAwait(false);

            // Text should be set
            Assert.All(integrations, on => Assert.False(string.IsNullOrWhiteSpace(on.Name)));
        }
        public async void GetAllDataSources()
        {
            var dataSources = await PortalClient.GetAllAsync <DataSource>().ConfigureAwait(false);

            Assert.NotNull(dataSources);
            Assert.NotEmpty(dataSources);
        }
Exemple #3
0
        public async void GetAllCollectorsSettings()
        {
            var allCollectorSettings = await PortalClient.GetAllAsync <Collector>().ConfigureAwait(false);

            Assert.NotNull(allCollectorSettings);
            Assert.True(allCollectorSettings.Count > 0);
        }
        public async void GetAll()
        {
            var items = await PortalClient.GetAllAsync <ExternalAlert>().ConfigureAwait(false);

            Assert.NotNull(items);
            Assert.True(items.Count > 0);
        }
Exemple #5
0
        public async void GetAllCollectorGroups()
        {
            var collectorGroups = await PortalClient.GetAllAsync <CollectorGroup>().ConfigureAwait(false);

            Assert.NotNull(collectorGroups);
            Assert.NotEmpty(collectorGroups);
        }
Exemple #6
0
        public async void CreateUpdateDelete()
        {
            // Ensure there is no existing UserGroup called "Test"
            var existingUserGroup = (await PortalClient
                                     .GetAllAsync(new Filter <UserGroup> {
                FilterItems = new List <FilterItem <UserGroup> > {
                    new Eq <UserGroup>(nameof(UserGroup.Name), Value)
                }
            })
                                     .ConfigureAwait(false))
                                    .SingleOrDefault();

            if (existingUserGroup != null)
            {
                await PortalClient.DeleteAsync(existingUserGroup).ConfigureAwait(false);
            }

            var userGroup = await PortalClient.CreateAsync(new UserGroupCreationDto
            {
                Name        = Value,
                Description = "Desc",
            }).ConfigureAwait(false);

            // Refetch
            var refetch = await PortalClient.GetAsync <UserGroup>(userGroup.Id).ConfigureAwait(false);

            Assert.NotNull(refetch);

            // Delete
            await PortalClient.DeleteAsync(userGroup).ConfigureAwait(false);
        }
Exemple #7
0
        public async void GetAll()
        {
            var escalationChains = await PortalClient.GetAllAsync <EscalationChain>().ConfigureAwait(false);

            Assert.NotNull(escalationChains);
            Assert.True(escalationChains.Count > 0);
        }
        public async void GetAlertsFilteredByDevice()
        {
            var device = await GetWindowsDeviceAsync().ConfigureAwait(false);

            foreach (var alertType in new List <AlertType> {
                AlertType.DataSource, AlertType.EventSource
            })
            {
                var alertFilter = new Filter <Alert>
                {
                    Skip        = 0,
                    Take        = 10,
                    FilterItems = new List <FilterItem <Alert> >
                    {
                        new Eq <Alert>(nameof(Alert.MonitorObjectName), device.DisplayName)
                    }
                };

                // Refetch each alert
                foreach (var alert in await PortalClient.GetAllAsync(alertFilter).ConfigureAwait(false))
                {
                    var _ = await PortalClient.GetAlertAsync(alert.Id).ConfigureAwait(false);
                }
            }
        }
        public async void CanCreateAndDeleteNetscanGroups()
        {
            var allNetscanGroups = await PortalClient.GetAllAsync <NetscanGroup>().ConfigureAwait(false);

            const string name        = "API Unit Test CanCreateAndDeleteNetscanGroups";
            const string description = "API Unit Test CanCreateAndDeleteNetscanGroups Description";

            var existingTestNetscanGroup = allNetscanGroups.SingleOrDefault(group => group.Name == name);

            if (existingTestNetscanGroup != null)
            {
                await PortalClient.DeleteAsync <NetscanGroup>(existingTestNetscanGroup.Id).ConfigureAwait(false);
            }
            Assert.DoesNotContain(await PortalClient.GetAllAsync <NetscanGroup>().ConfigureAwait(false), group => group.Name == name);
            // Definitely not there now

            // Create one
            var netscanGroupCreationDto = new NetscanGroupCreationDto
            {
                Name        = name,
                Description = description
            };
            var newNetscanGroup = await PortalClient.CreateAsync(netscanGroupCreationDto).ConfigureAwait(false);

            Assert.Contains(await PortalClient.GetAllAsync <NetscanGroup>().ConfigureAwait(false), group => group.Name == name);

            await PortalClient.DeleteAsync(newNetscanGroup).ConfigureAwait(false);

            Assert.DoesNotContain(await PortalClient.GetAllAsync <NetscanGroup>().ConfigureAwait(false), group => group.Name == name);
        }
        public async void GetAllReports()
        {
            var reports = await PortalClient.GetAllAsync <Report>().ConfigureAwait(false);

            Assert.NotNull(reports);
            Assert.NotEmpty(reports);
        }
Exemple #11
0
        public async void CreateUser()
        {
            // Delete it if it already exists
            foreach (var existingUser in await PortalClient.GetAllAsync(new Filter <User>
            {
                FilterItems = new List <FilterItem <User> >
                {
                    new Eq <User>(nameof(User.UserName), "test")
                }
            }).ConfigureAwait(false))
            {
                await PortalClient.DeleteAsync(existingUser).ConfigureAwait(false);
            }

            var userCreationDto = new UserCreationDto
            {
                ViewPermission = new ViewPermission
                {
                    Alerts     = true,
                    Dashboards = true,
                    Devices    = true,
                    Reports    = true,
                    Websites   = true,
                    Settings   = true
                },
                Username  = "******",
                FirstName = "first",
                LastName  = "last",
                Email     = "*****@*****.**",
#pragma warning disable SCS0015 // Hardcoded password
                Password = "******",
#pragma warning restore SCS0015 // Hardcoded password
                Password1           = "Abc123!!!",
                ForcePasswordChange = true,
                TwoFAEnabled        = false,
                SmsEmail            = "",
                SmsEmailFormat      = "sms",
                Timezone            = "",
                ViewPermissions     = new List <bool> {
                    true, true, true, true, true, true
                },
                Status = "active",
                Note   = "note",
                Roles  = new List <Role>
                {
                    new Role {
                        Id = 1
                    }
                },
                ApiTokens = new List <object>(),
                Phone     = "+447761503941",
                ApiOnly   = false
            };

            var user = await PortalClient.CreateAsync(userCreationDto).ConfigureAwait(false);

            // Delete again
            await PortalClient.DeleteAsync(user).ConfigureAwait(false);
        }
        public async void GetAll()
        {
            var snmpSysOidMaps = await PortalClient.GetAllAsync <SnmpSysOidMap>().ConfigureAwait(false);

            Assert.NotNull(snmpSysOidMaps);
            Assert.All(snmpSysOidMaps, snmpSysOidMap => Assert.NotNull(snmpSysOidMap.Oid));
            Assert.All(snmpSysOidMaps, snmpSysOidMap => Assert.NotNull(snmpSysOidMap.Categories));
        }
        public async void CanGetNetscanById()
        {
            var netscan = (await PortalClient.GetAllAsync <Netscan>().ConfigureAwait(false))[0];

            var refetchedNetscan = await PortalClient.GetAsync <Netscan>(netscan.Id).ConfigureAwait(false);

            Assert.NotNull(refetchedNetscan);
        }
Exemple #14
0
        public async void GetAllWebsites()
        {
            var websites = await PortalClient.GetAllAsync <Website>().ConfigureAwait(false);

            // Services should be returned
            Assert.NotNull(websites);
            Assert.NotEmpty(websites);
        }
Exemple #15
0
        public async void GetConfigSourceById()
        {
            var configSources = await PortalClient.GetAllAsync <ConfigSource>().ConfigureAwait(false);

            Assert.NotEmpty(configSources);
            var configSource = await PortalClient.GetAsync <ConfigSource>(configSources[0].Id).ConfigureAwait(false);

            Assert.NotNull(configSource);
        }
        public async void GetAlertDisableDevices_RawFilter()
        {
            var deviceList = await PortalClient.GetAllAsync(new Filter <Device> {
                QueryString = "filter=alertDisableStatus!:\"none-none-none\""
            }).ConfigureAwait(false);

            Assert.NotNull(deviceList);
            Assert.NotEmpty(deviceList);
        }
Exemple #17
0
        public async void SetWebsiteMonitorCheckpoints()
        {
            var websiteMonitorCheckpoints = await PortalClient.GetAllAsync <WebsiteMonitorCheckpoint>().ConfigureAwait(false);

            // Some website folders should be returned
            Assert.True(websiteMonitorCheckpoints.Count > 0);

            //// Website folders should have unique Ids
            //Assert.False(websiteMonitorCheckpoints.Select(c => c.Id).HasDuplicates());
        }
Exemple #18
0
        public override async Task RefreshDataSetAsync(ConnectedSystemDataSet dataSet, CancellationToken cancellationToken)
        {
            Logger.LogDebug($"Refreshing DataSet {dataSet.Name}");
            var inputText = dataSet.QueryConfig.Query ?? throw new ConfigurationException($"Missing Query in QueryConfig for dataSet '{dataSet.Name}'");
            var query     = new SubstitutionString(inputText);
            // Send the query off to LogicMonitor
            var connectedSystemItems = await _logicMonitorClient
                                       .GetAllAsync <JObject>(query.ToString(), cancellationToken)
                                       .ConfigureAwait(false);

            Logger.LogDebug($"Got {connectedSystemItems.Count} results for {dataSet.Name}.");

            await ProcessConnectedSystemItemsAsync(
                dataSet,
                connectedSystemItems,
                ConnectedSystem,
                cancellationToken
                ).ConfigureAwait(false);
        }
Exemple #19
0
        public async void GetCollectorGroups()
        {
            var collectorGroups = await PortalClient.GetAllAsync <CollectorGroup>().ConfigureAwait(false);

            Assert.NotEmpty(collectorGroups);
            Assert.True(collectorGroups.All(cg => cg.Id != 0));
            Assert.True(collectorGroups.All(cg => cg.Name != null));
            // Bug in LogicMonitor's API
            // Assert.NotEqual(0, collectorGroups.TotalCount);
        }
        public async void GetDeviceUsingSubUrl()
        {
            var device = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var deviceRefetch = await PortalClient
                                .GetAllAsync <JObject>($"device/devices?filter=id:{device.Id}&fields=inheritedProperties", CancellationToken.None)
                                .ConfigureAwait(false);

            Assert.NotNull(deviceRefetch);
        }
Exemple #21
0
        public async void GetDashboardsWithWidgets()
        {
            var dashboards = await PortalClient.GetAllAsync <Dashboard>().ConfigureAwait(false);

            // Make sure that some are returned
            Assert.True(dashboards.Count > 0);

            // Make sure that all have Unique Ids
            Assert.False(dashboards.Select(c => c.Id).HasDuplicates());
        }
Exemple #22
0
        public async void GetAllConfigSources()
        {
            var configSources = await PortalClient.GetAllAsync <ConfigSource>().ConfigureAwait(false);

            // Make sure that some are returned
            Assert.NotEmpty(configSources);

            // Make sure that all have Unique Ids
            Assert.False(configSources.Select(c => c.Id).HasDuplicates());
        }
        private async Task Main(PortalClient portalClient, string alertRuleName, bool enableAlertClear)
        {
            var alertRule = (await portalClient.GetAllAsync <AlertRule>().ConfigureAwait(false)).SingleOrDefault(ar => ar.Name == alertRuleName);

            if (alertRule == null)
            {
                throw new ArgumentException($"No alert rule found with name {alertRuleName}");
            }

            alertRule.SuppressAlertClear = !enableAlertClear;
        }
        public async void CanGetNetscanGroups()
        {
            var allNetscanGroups = await PortalClient.GetAllAsync <NetscanGroup>().ConfigureAwait(false);

            Assert.NotNull(allNetscanGroups);
            Assert.NotEmpty(allNetscanGroups);
            var ids = allNetscanGroups.Select(nspg => nspg.Id);

            Assert.True(allNetscanGroups.Count == ids.Count());
            Assert.NotEmpty(allNetscanGroups);
        }
        public async void GetDataSourceCollectionMethodsQuickly()
        {
            // Get all DataSource Collection methods
            var dataSources = await PortalClient.GetAllAsync(new Filter <DataSource> {
                Properties = new List <string> {
                    nameof(DataSource.CollectionMethod)
                }
            }).ConfigureAwait(false);

            Assert.NotNull(dataSources);
        }
        public async void ListAllNetscans()
        {
            var netscans = await PortalClient.GetAllAsync <Netscan>().ConfigureAwait(false);

            Assert.NotNull(netscans);
            Assert.NotEmpty(netscans);

            // Ids should all be distinct
            var ids = netscans.Select(nsp => nsp.Id);

            Assert.True(netscans.Count == ids.Count());
        }
Exemple #27
0
        public async void GetCollectorGroupSettings()
        {
            var collectorGroups = await PortalClient
                                  .GetAllAsync <CollectorGroup>()
                                  .ConfigureAwait(false);

            var pulsantCollectorGroupSettings = await PortalClient
                                                .GetAsync <CollectorGroup>(collectorGroups[0].Id)
                                                .ConfigureAwait(false);

            Assert.NotNull(pulsantCollectorGroupSettings);
        }
Exemple #28
0
        public async void RunDebugCommand()
        {
            var collectors = await PortalClient.GetAllAsync <Collector>().ConfigureAwait(false);

            var testCollector = collectors.Find(c => !c.IsDown);

            Assert.NotNull(testCollector);
            var response = await PortalClient.ExecuteDebugCommandAndWaitForResultAsync(testCollector.Id, "!ping 8.8.8.8").ConfigureAwait(false);

            Assert.NotNull(response);
            Logger.LogInformation(response.Output);
        }
        public async void GetCollector()
        {
            var collectors = await PortalClient.GetAllAsync <Collector>().ConfigureAwait(false);

            Assert.NotNull(collectors);
            Assert.NotEmpty(collectors);
            var refetchedCollector = await PortalClient
                                     .GetAsync <Collector>(collectors[0].Id)
                                     .ConfigureAwait(false);

            Assert.NotNull(refetchedCollector);
        }
        public async void GetDeviceScheduledDownTimes()
        {
            var sdts = await PortalClient.GetAllAsync(new Filter <ScheduledDownTime>
            {
                FilterItems = new List <FilterItem <ScheduledDownTime> >
                {
                    new Eq <ScheduledDownTime>(nameof(ScheduledDownTime.Type), "DeviceSDT"),
                    new Eq <ScheduledDownTime>(nameof(ScheduledDownTime.IsEffective), false),
                }
            }).ConfigureAwait(false);

            Assert.All(sdts, sdt => Assert.False(sdt.IsEffective));
        }