Exemplo n.º 1
0
        public async void Backup_JobMonitors()
        {
            var backup = await PortalClient.BackupAsync(new ConfigurationBackupSpecification(false) { JobMonitors = true }).ConfigureAwait(false);

            Assert.NotNull(backup.JobMonitors);
            Assert.NotEmpty(backup.JobMonitors);
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
        public async void GetApplications()
        {
            var things = await PortalClient.GetAppliesToAsync("isCisco()").ConfigureAwait(false);

            Assert.NotNull(things);
            Assert.NotEmpty(things);
        }
        public async void GetAll()
        {
            var items = await PortalClient.GetAllAsync <ExternalAlert>().ConfigureAwait(false);

            Assert.NotNull(items);
            Assert.True(items.Count > 0);
        }
Exemplo n.º 5
0
        public async void GetSingleSignOnData()
        {
            var allOpsNotes = await PortalClient.GetAsync <SingleSignOn>().ConfigureAwait(false);

            // Text should be set
            Assert.NotEmpty(allOpsNotes.SamlVersion);
        }
Exemplo n.º 6
0
        public async void GetForecastGraphData()
        {
            var device = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false);

            var dataSourceGraphs = await PortalClient.GetDataSourceGraphsAsync(dataSource.Id).ConfigureAwait(false);

            var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

            var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false);

            var deviceDataSourceInstance = deviceDataSourceInstances[0];
            var dataSourceGraph          = dataSourceGraphs[0];
            var virtualDataPoint         = dataSourceGraph.DataPoints[0];
            var forecastGraphData        = await PortalClient.GetForecastGraphDataAsync(new ForecastDataRequest
            {
                TrainingTimePeriod   = TrainingTimePeriod.SixMonths,
                ForecastTimePeriod   = ForecastTimePeriod.OneMonth,
                DataSourceInstanceId = deviceDataSourceInstance.Id,
                GraphId        = dataSourceGraph.Id,
                DataPointLabel = virtualDataPoint.Name
            }).ConfigureAwait(false);

            Assert.Single(forecastGraphData.TrainingGraphData.Lines);
            Assert.Equal(3, forecastGraphData.ForecastedGraphData.Lines.Count);
        }
Exemplo n.º 7
0
        public async void SetAlertThreshold()
        {
            var deviceGroup = await PortalClient
                              .GetDeviceGroupByFullPathAsync(DeviceGroupFullPath)
                              .ConfigureAwait(false);

            var dataSource = await PortalClient
                             .GetByNameAsync <DataSource>("Ping")
                             .ConfigureAwait(false);

            var datapoints = (await PortalClient
                              .GetDataSourceDataPointsPageAsync(dataSource.Id, new Filters.Filter <DataSourceDataPoint> {
                Skip = 0, Take = 10
            })
                              .ConfigureAwait(false)).Items;
            var datapoint = datapoints.Single(dp => dp.Name == "average");
            await PortalClient
            .SetDeviceGroupDataSourceDataPointThresholds(
                deviceGroup.Id,
                dataSource.Id,
                datapoint.Id,
                "> 191 timezone=Europe/London",
                $"Set by LogicMonitor.Api Unit Test at {DateTimeOffset.UtcNow}",
                true
                )
            .ConfigureAwait(false);

            Assert.NotEqual(AlertStatus.Unknown, deviceGroup.AlertStatus);
        }
Exemplo n.º 8
0
        public async void GetAllDataSources()
        {
            var dataSources = await PortalClient.GetAllAsync <DataSource>().ConfigureAwait(false);

            Assert.NotNull(dataSources);
            Assert.NotEmpty(dataSources);
        }
Exemplo n.º 9
0
        public async void GetDeviceDataSourceByName_IsFast()
        {
            var stopwatch = Stopwatch.StartNew();
            var device    = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var deviceDataSources = await PortalClient.GetDeviceDataSourcesPageAsync(
                device.Id,
                new Filter <DeviceDataSource>
            {
                Take       = 1,
                Properties = new List <string>
                {
                    nameof(DeviceDataSource.Id),
                    nameof(DeviceDataSource.DataSourceName)
                },
                FilterItems = new List <FilterItem <DeviceDataSource> >
                {
                    new FilterItem <DeviceDataSource> {
                        Property  = nameof(DeviceDataSource.DataSourceName),
                        Operation = ":",
                        Value     = "WinCPU"
                    }
                }
            }).ConfigureAwait(false);

            var durationMs = stopwatch.ElapsedMilliseconds;

            Assert.NotNull(deviceDataSources);
            var deviceDataSource = deviceDataSources.Items.SingleOrDefault();

            Assert.NotNull(deviceDataSource);
            Assert.True(durationMs < 2000);
        }
Exemplo n.º 10
0
        public static async Task SpecifyingQueues()
        {
            PortalClient portalClient = null; //As initialized earlier

            var organizationNumber = "123456789";
            var sender             = new Sender(organizationNumber, new PollingQueue("CustomPollingQueue"));

            var documentToSign = new Document(
                "Subject of Message",
                "This is the content",
                FileType.Pdf,
                @"C:\Path\ToDocument\File.pdf"
                );

            var signers = new List <Signer>
            {
                new Signer(new PersonalIdentificationNumber("00000000000"), new NotificationsUsingLookup())
            };

            var portalJob = new Job(documentToSign, signers, "myReferenceToJob", sender);

            var portalJobResponse = await portalClient.Create(portalJob);

            var changedJob = await portalClient.GetStatusChange(sender);
        }
Exemplo n.º 11
0
        public static async Task CreateAndSend()
        {
            ClientConfiguration clientConfiguration = null; //As initialized earlier
            var portalClient = new PortalClient(clientConfiguration);

            var documentToSign = new Document(
                "Subject of Message",
                "This is the content",
                FileType.Pdf,
                @"C:\Path\ToDocument\File.pdf"
                );

            var signers = new List <Signer>
            {
                new Signer(new PersonalIdentificationNumber("00000000000"), new NotificationsUsingLookup()),
                new Signer(new PersonalIdentificationNumber("11111111111"), new Notifications(
                               new Email("*****@*****.**"),
                               new Sms("999999999"))),
                new Signer(new ContactInformation {
                    Email = new Email("*****@*****.**")
                }),
                new Signer(new ContactInformation {
                    Sms = new Sms("88888888")
                }),
                new Signer(new ContactInformation
                {
                    Email = new Email("*****@*****.**"),
                    Sms   = new Sms("77777777")
                })
            };

            var portalJob = new Job(documentToSign, signers, "myReferenceToJob");

            var portalJobResponse = await portalClient.Create(portalJob);
        }
Exemplo n.º 12
0
        public async void Backup_Integrations()
        {
            var backup = await PortalClient.BackupAsync(new ConfigurationBackupSpecification(false) { Integrations = true }).ConfigureAwait(false);

            Assert.NotNull(backup.Integrations);
            Assert.NotEmpty(backup.Integrations);
        }
Exemplo n.º 13
0
        public async void Backup_Users()
        {
            var backup = await PortalClient.BackupAsync(new ConfigurationBackupSpecification(false) { Users = true }).ConfigureAwait(false);

            Assert.NotNull(backup);
            Assert.NotNull(backup.RoleGroups);
            Assert.NotNull(backup.Roles);
            Assert.NotNull(backup.UserGroups);
            Assert.NotNull(backup.Users);

            var roleGroup = backup.RoleGroups[0];

            Assert.NotNull(roleGroup);

            var role = backup.Roles[0];

            Assert.NotNull(role);

            var userGroup = backup.UserGroups[0];

            Assert.NotNull(userGroup);

            var user = backup.Users[0];

            Assert.NotNull(user);

            // CreatedBy is populated
            Assert.False(string.IsNullOrWhiteSpace(user.CreatedBy));
        }
Exemplo n.º 14
0
        public async void Backup_SnmpSysOidMaps()
        {
            var backup = await PortalClient.BackupAsync(new ConfigurationBackupSpecification(false) { SnmpSysOidMaps = true }).ConfigureAwait(false);

            Assert.NotNull(backup.SnmpSysOidMaps);
            Assert.NotEmpty(backup.SnmpSysOidMaps);
        }
Exemplo n.º 15
0
        public async Task GetGraphData()
        {
            var utcNow        = DateTime.UtcNow;
            var startDateTime = utcNow.FirstDayOfLastMonth();
            var device        = await GetWindowsDeviceAsync().ConfigureAwait(false);

            Assert.NotNull(device);

            var dataSource = await PortalClient
                             .GetDataSourceByUniqueNameAsync("WinCPU")
                             .ConfigureAwait(false);

            Assert.NotNull(dataSource);

            var dataSourceGraph = await PortalClient
                                  .GetDataSourceGraphByNameAsync(dataSource.Id, "CPU Usage")
                                  .ConfigureAwait(false);

            Assert.NotNull(dataSourceGraph);

            var deviceDataSource = await PortalClient
                                   .GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id)
                                   .ConfigureAwait(false);

            Assert.NotNull(deviceDataSource);

            var deviceDataSourceInstances = await PortalClient
                                            .GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance>())
                                            .ConfigureAwait(false);

            Assert.NotNull(deviceDataSourceInstances);
            Assert.NotEmpty(deviceDataSourceInstances);

            var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest
            {
                DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id,
                DataSourceGraphId          = dataSourceGraph.Id,
                TimePeriod    = TimePeriod.Zoom,
                StartDateTime = startDateTime,
                EndDateTime   = utcNow.LastDayOfLastMonth()
            };

            //  Ensure Caching is enabled
            PortalClient.UseCache = true;

            var graphData = await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false);

            Assert.NotEmpty(graphData.Lines);
            Assert.Equal(startDateTime, graphData.StartTimeUtc);
            Assert.NotNull(graphData.Lines[0].ColorString);

            // Ensure that subsequent fetches are fast
            var stopwatch = Stopwatch.StartNew();

            graphData = await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false);

            Assert.NotNull(graphData);
            stopwatch.Stop();
            Assert.True(stopwatch.ElapsedMilliseconds < 50);
        }
Exemplo n.º 16
0
 public BlackjackForm()
 {
     InitializeComponent();
     this.FormBorderStyle = FormBorderStyle.None;
     userhand             = new List <PictureBox>();
     opponenthand         = new List <PictureBox>();
     userhand.Add(pb1User);
     userhand.Add(pb2User);
     userhand.Add(pb3User);
     userhand.Add(pb4User);
     userhand.Add(pb5User);
     opponenthand.Add(pb1Player);
     opponenthand.Add(pb2Player);
     opponenthand.Add(pb3Player);
     opponenthand.Add(pb4Player);
     opponenthand.Add(pb5Player);
     thegame         = new Game();
     curPlayer       = new Player();
     opponentPlayer  = new Player();
     gList           = new List <Game>();
     user            = new User();
     context         = new InstanceContext(this);
     blackjackClient = new BlackjackGameClient(context);
     chatClient      = new ChatClient(context);
     chatClient.SubscribeChat();
     portalClient = new PortalClient(context);
     portalClient.SubscribePortal();
     //panelLobby.Hide();
     blackjackClient.SubscribeGame();
     winner = new Player();
 }
Exemplo n.º 17
0
        public async Task GetWidgetGraphData()
        {
            var utcNow        = DateTime.UtcNow;
            var startDateTime = utcNow.FirstDayOfLastMonth();
            var dashboard     = await GetAllWidgetsDashboardAsync().ConfigureAwait(false);

            Assert.NotNull(dashboard);

            var widgets = await PortalClient.GetWidgetsByDashboardIdAsync(dashboard.Id).ConfigureAwait(false);

            Assert.NotNull(widgets);
            Assert.NotEmpty(widgets);

            var firstCustomGraphWidget = widgets.Find(w => w.Type == "cgraph");

            Assert.NotNull(firstCustomGraphWidget);

            var widgetGraphDataRequest = new WidgetGraphDataRequest
            {
                WidgetId      = firstCustomGraphWidget.Id,
                TimePeriod    = TimePeriod.Zoom,
                StartDateTime = startDateTime,
                EndDateTime   = utcNow.LastDayOfLastMonth()
            };
            var graphData = await PortalClient.GetGraphDataAsync(widgetGraphDataRequest).ConfigureAwait(false);

            Assert.NotEmpty(graphData.Lines);
            Assert.Equal(startDateTime, graphData.StartTimeUtc);
            Assert.NotNull(graphData.Lines[0].ColorString);
        }
Exemplo n.º 18
0
        public async void Get()
        {
            var messageTemplate = await PortalClient.GetAsync <NewUserMessageTemplate>().ConfigureAwait(false);

            Assert.False(string.IsNullOrWhiteSpace(messageTemplate.Subject));
            Assert.False(string.IsNullOrWhiteSpace(messageTemplate.Body));
        }
Exemplo n.º 19
0
        public async void GetWinCpuDeviceDataSourceInstancesFromDev()
        {
            var device = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false);

            var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

            var deviceDataSourceInstances = await PortalClient
                                            .GetAllDeviceDataSourceInstancesAsync(
                device.Id,
                deviceDataSource.Id,
                new Filter <DeviceDataSourceInstance>
            {
                Take         = 300,
                ExtraFilters = new List <FilterItem <DeviceDataSourceInstance> >
                {
                    new Eq <DeviceDataSourceInstance>(nameof(DeviceDataSourceInstance.StopMonitoring), false)
                },
                Order = new Order <DeviceDataSourceInstance> {
                    Property = nameof(DeviceDataSourceInstance.Name), Direction = OrderDirection.Asc
                }
            }).ConfigureAwait(false);

            Assert.NotNull(deviceDataSourceInstances);
            Assert.NotEmpty(deviceDataSourceInstances);
        }
        public async void ImportPropertySource()
        {
            const LogicModuleType logicModuleType = LogicModuleType.PropertySource;

            var propertySourceUpdates =
                (await PortalClient
                 .GetLogicModuleUpdates(logicModuleType, default)
                 .ConfigureAwait(false))
                .Items
                .Where(ds =>
                       ds.Category == LogicModuleUpdateCategory.New)
                .ToList();

            if (propertySourceUpdates.Count > 0)
            {
                await PortalClient
                .ImportLogicModules(
                    logicModuleType,
                    new List <string>
                {
                    propertySourceUpdates[0].Name
                },
                    default)
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 21
0
        public async void GetDeviceGroupProperties()
        {
            var deviceGroupProperties = await PortalClient.GetDeviceGroupPropertiesAsync(1).ConfigureAwait(false);

            // Make sure that some are returned
            Assert.True(deviceGroupProperties.Count > 0);
        }
        public async void ImportJobMonitor()
        {
            const LogicModuleType logicModuleType = LogicModuleType.JobMonitor;

            var jobMonitorUpdates =
                (await PortalClient
                 .GetLogicModuleUpdates(logicModuleType, default)
                 .ConfigureAwait(false))
                .Items
                .Where(ds =>
                       ds.Category == LogicModuleUpdateCategory.New)
                .ToList();

            if (jobMonitorUpdates.Count > 0)
            {
                await PortalClient
                .ImportLogicModules(
                    logicModuleType,
                    new List <string>
                {
                    jobMonitorUpdates[0].Name
                },
                    default)
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 23
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);
        }
        public async void ImportAppliesToFunction()
        {
            const LogicModuleType logicModuleType = LogicModuleType.AppliesToFunction;

            var appliesToFunctionUpdates =
                (await PortalClient
                 .GetLogicModuleUpdates(logicModuleType, default)
                 .ConfigureAwait(false))
                .Items
                .Where(ds =>
                       ds.Category == LogicModuleUpdateCategory.New)
                .ToList();

            if (appliesToFunctionUpdates.Count > 0)
            {
                await PortalClient
                .ImportLogicModules(
                    logicModuleType,
                    new List <string>
                {
                    appliesToFunctionUpdates[0].Name
                },
                    default)
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 25
0
        public async void GetAll()
        {
            var escalationChains = await PortalClient.GetAllAsync <EscalationChain>().ConfigureAwait(false);

            Assert.NotNull(escalationChains);
            Assert.True(escalationChains.Count > 0);
        }
        public async void ImportSnmpSysOidMap()
        {
            const LogicModuleType logicModuleType = LogicModuleType.SnmpSysOIDMap;

            var snmpSysOidMapUpdates =
                (await PortalClient
                 .GetLogicModuleUpdates(logicModuleType, default)
                 .ConfigureAwait(false))
                .Items
                .Where(ds =>
                       ds.Category == LogicModuleUpdateCategory.New)
                .ToList();

            if (snmpSysOidMapUpdates.Count > 0)
            {
                await PortalClient
                .ImportSnmpSysOidMap(
                    new List <SnmpSysOidMapImportItem>
                {
                    new SnmpSysOidMapImportItem
                    {
                        Id  = snmpSysOidMapUpdates[0].LocalId,
                        Oid = snmpSysOidMapUpdates[0].Name
                    }
                },
                    default)
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 27
0
        public async void Get()
        {
            var accountSettings = await PortalClient.GetAsync <AccountSettings>().ConfigureAwait(false);

            Assert.NotNull(accountSettings);
            Assert.True(accountSettings.DeviceCount > 0);
        }
Exemplo n.º 28
0
        public async void GetGraphData_X250()
        {
            PortalClient.UseCache = true;
            var utcNow        = DateTime.UtcNow;
            var startDateTime = utcNow.FirstDayOfLastMonth();
            var device        = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false);

            var dataSourceGraph = await PortalClient.GetDataSourceGraphByNameAsync(dataSource.Id, "CPU Usage").ConfigureAwait(false);

            Assert.NotNull(dataSourceGraph);
            var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

            var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance>()).ConfigureAwait(false);

            var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest
            {
                DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id,
                DataSourceGraphId          = dataSourceGraph.Id,
                TimePeriod    = TimePeriod.Zoom,
                StartDateTime = startDateTime,
                EndDateTime   = utcNow.LastDayOfLastMonth()
            };
            var sw = Stopwatch.StartNew();

            for (var n = 0; n < 250; n++)
            {
                Logger.LogInformation($"{n:000}: {sw.ElapsedMilliseconds:00000}ms");
                await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false);
            }
        }
Exemplo n.º 29
0
        public async void GetAllReports()
        {
            var reports = await PortalClient.GetAllAsync <Report>().ConfigureAwait(false);

            Assert.NotNull(reports);
            Assert.NotEmpty(reports);
        }
Exemplo n.º 30
0
        public async void Backup_EventSources()
        {
            var backup = await PortalClient.BackupAsync(new ConfigurationBackupSpecification(false) { EventSources = true }).ConfigureAwait(false);

            Assert.NotNull(backup.EventSources);
            Assert.NotEmpty(backup.EventSources);
        }