Пример #1
0
        private static void EdgeGeneralTests(WebClient webClient)
        {
            // Test the Authenticate method.
            AuthenticateResponse authenticateResponse = webClient.Authenticate(ConfigurationManager.AppSettings["Username"], ConfigurationManager.AppSettings["Password"]);

            EdgeOS.API.Types.Configuration.Configuration exampleConfiguration = new EdgeOS.API.Types.Configuration.Configuration()
            {
                Firewall = new Firewall()
                {
                    Group = new FirewallGroup()
                    {
                        AddressGroup = new Dictionary <string, AddressGroupEntry>()
                        {
                            {
                                "APITestAddresses", new AddressGroupEntry()
                                {
                                    Address = new[] { "4.3.2.1" }
                                }
                            }
                        }
                    }
                }
            };

            // Add an IP to a FirewallAddressGroup (creating it if it doesn't already exist).
            ConfigurationSettingsBatchResponse configurationSettingsBatchResponse = webClient.ConfigurationSettingsBatch(new ConfigurationSettingsBatchRequest
            {
                // Add an IP address group.
                Set = exampleConfiguration,

                // Cut down on the amount of bytes being returned by selecting a hopefully empty node.
                Get = new EdgeOS.API.Types.Configuration.Configuration()
                {
                    CustomAttribute = new[] { "" }
                }
            });

            // Delete APITestAddresses.
            exampleConfiguration.Firewall.Group.AddressGroup["APITestAddresses"] = null;

            // Remove the FirewallAddressGroup.
            ConfigurationSettingsDeleteResponse configurationSettingsDeleteResponse = webClient.ConfigurationSettingsDelete(exampleConfiguration);

            // Get predefined config list.
            ConfigurationSettingsGetResponse configurationSettingsGetPredefinedListResponse = webClient.ConfigurationSettingsGetPredefinedList();

            // Get sections of partial config.
            ConfigurationSettingsGetResponse configurationSettingsGetSectionsResponse = webClient.ConfigurationSettingsGetSections("{\"firewall\":null, \"protocols\":null}");

            // Get tree config.
            ConfigurationSettingsGetTreeResponse configurationSettingsGetTreeResponse = webClient.ConfigurationSettingsGetTree(new[] { "system", "ntp" });

            configurationSettingsGetTreeResponse = webClient.ConfigurationSettingsGetTree(new[] { "system" });
            configurationSettingsGetTreeResponse = webClient.ConfigurationSettingsGetTree(new[] { "firewall", "group", "address-group" });

            // Set a FirewallAddressGroup.
            ConfigurationSettingsSetResponse configurationSettingsSetResponse = webClient.ConfigurationSettingsSet(exampleConfiguration);

            // Data methods.
            DataDefaultConfigurationStatusResponse dataDefaultConfigurationStatusResponse = webClient.DataDefaultConfigurationStatus();
            DataDHCPLeasesResponse         dataDHCPLeasesResponse         = webClient.DataDHCPLeases();
            DataDHCPStatisticsResponse     dataDHCPStatisticsResponse     = webClient.DataDHCPStatistics();
            DataFirewallStatisticsResponse dataFirewallStatisticsResponse = webClient.DataFirewallStatistics();
            DataNATStatisticsResponse      dataNATStatisticsResponse      = webClient.DataNATStatistics();
            DataRoutesResponse             dataRoutesResponse             = webClient.DataRoutes();
            DataSystemInformationResponse  dataSystemInformationResponse  = webClient.DataSystemInformation();

            // Heartbeat.
            webClient.Heartbeat();

            // Firmware update.
            UpgradeResponse upgradeFirmware = webClient.UpgradeFirmware("EdgeOS.API.dll");

            upgradeFirmware = webClient.UpgradeFirmware(new Uri("http://localhost/firmware.bin"));

            //TODO: Wizard Feature.
            //TODO: Wizard Setup.
        }