使用.NET Cloud Server SDK

2020年12月31日19:42:49 发表评论 84 次浏览

备注:对于SDK版本1.1.0和Cloud API 1.x版

操作

有两种方法可以初始化notlogy客户端。你可以在应用程序/ Web配置中具有API URL和令牌密钥, 也可以在notlogy客户端的构造函数中传递值。

OneAndOneClient客户端= OneAndOneClient.Instance(" https://xxxxxx.1and1.com/v1", apiToken); //通过代码传递的API值

OneAndOneClient客户端= OneAndOneClient.Instance(); //配置文件中的API值

伺服器

列出所有服务器:

var服务器= client.Servers.Get();

显示单个服务器:

var server = client.Servers.Show(serverId);

列出可用的服务器版本:

var serverFlavours = client.Servers.GetAvailableFixedServers();

显示一个服务器风格:

var serverFlavour = client.Servers.GetFlavorInformation(serverFlavourId);

创建服务器:

//例如, 在此处是Windows的服务器设备, 它会在Windows上自动安装, var Appliance = client.ServerAppliances.Get()。Where(app => app.OsFamily == OSFamliyType.Windows && app.AutomaticInstallation == true).FirstOrDefault ();

//获取尚未分配给任何服务器的公共IP var publicIP = client.PublicIPs.Get()。FirstOrDefault(ip => ip.AssignedTo == null);

var result = client.Servers.Create(new POCO.Requests.Servers.CreateServerRequest()
            {
        ApplianceId = appliance.Id, Name = "My server", Description = "Example description", Hardware = new POCO.Requests.Servers.HardwareReqeust()
            {
                CoresPerProcessor = 1, Hdds = new List<POCO.Requests.Servers.HddRequest>()
                    {
                        {new POCO.Requests.Servers.HddRequest()
                        {
                            IsMain=true, //make sure that the hard drive meets the appliance minimum requirements 
                            Size=appliance.MinHddSize, }}
                    }, Ram = 4, Vcore = 2
            }, PowerOn = true, Password = "Test123!", IpId = publicIP.Id
        });`

更新服务器:

var result = client.Servers.Update(new UpdateServerRequest()
        {
            Description = "my server updated", Name = "my server updated"
        }, serverId);

删除服务器:

// bool参数用于Set true, 以在删除服务器后保留服务器IP(默认为false)。 var result = client.Servers.Delete(serverToDelete.Id, false);

显示服务器的硬件:

var result = client.ServersHardware.Show(serverId);

更新服务器的硬件:

var result = client.ServersHardware.Update(new POCO.Requests.Servers.UpdateHardwareRequest()
                {
                    CoresPerProcessor = 2, Ram = 8, Vcore = 4
                }, serverId);`

获取服务器的硬盘驱动器:

var result = client.ServerHdds.Get(serverId);

显示服务器的硬盘驱动器:

var result = client.ServerHdds.Show(serverId, hardDriveId);

将硬盘驱动器添加到服务器:

var result = client.ServerHdds.Create(new POCO.Requests.Servers.AddHddRequest()
                {
                    Hdds = new System.Collections.Generic.List<POCO.Requests.Servers.HddRequest>()
                {
                    { new POCO.Requests.Servers.HddRequest()
                    {Size=20, IsMain=false}}, {new POCO.Requests.Servers.HddRequest()
                    {Size=30, IsMain=false}
                }}
                }, serverId);

更新服务器的硬盘驱动器大小:

var result = client.ServerHdds.Update(new POCO.Requests.Servers.UpdateHddRequest()
            {
                Size = updatedSize
            }, serverId, harddriveId);

从服务器上卸下硬盘驱动器:

var result = client.ServerHdds.Delete(serverId, harddriveId);

显示服务器的已加载DVD:

var result = client.ServersHardware.ShowDVD(serverId);

将DVD装入服务器单元:

var result = client.ServersHardware.UpdateDVD(serverId, dvdId);

卸载服务器的已加载DVD:

var result = client.ServersHardware.DeleteDVD(serverId);

显示服务器的图像:

var image = client.ServerImage.Show(serverId);

将新映像重新安装到服务器中:

var result = client.ServerImage.Update(new POCO.Requests.Servers.UpdateServerImageRequest()
                {
                    Id = imageId, Password = "Test123!"
                }, serverId);

列出服务器的IP地址:

var result = client.ServerIps.Get(serverId);

显示服务器的IP地址:

var result = client.ServerIps.Show(serverId, ipId);

为服务器分配IP:

var result = client.ServerIps.Create(new POCO.Requests.Servers.CreateServerIPRequest()
            {
                Type = IPType.IPV4
            }, serverId);

从服务器取消分配IP:

// bool参数设置为true以便释放IP而不删除它var result = client.ServerIps.Delete(serverId, ipId, true);

列出服务器的防火墙策略:

var result = client.ServerIps.GetFirewallPolicies(serverId, ipId);

将新的防火墙策略添加到服务器的IP:

var policyresult = client.FirewallPolicies.Show(firewallPolicyId); var result = client.ServerIps.UpdateFirewallPolicy(serverId, ipId, policyresult.Id);

从服务器的IP中删除防火墙策略:

var result = client.ServerIps.DeleteFirewallPolicy(serverId, ipId);

列出所有服务器的IP地址负载平衡器:

var result = client.ServerIps.GetLoadBalancer(serverId, ipId);

将新的负载均衡器添加到IP:

var result = client.ServerIps.CreateLoadBalancer(serverId, ipId, loadBalancerId);

从IP删除负载均衡器:

var result = client.ServerIps.DeleteLoadBalancer(serverId, ipId, loadBalancerId);

获取服务器状态:

var result = client.Servers.GetStatus(serverId);

更改服务器状态:

var result = client.Servers.UpdateStatus(new UpdateStatusRequest()
        {
            Action = ServerAction.REBOOT, Method = ServerActionMethod.SOFTWARE
        }, serverId);

列出服务器的专用网络:

var result = client.Servers.GetPrivateNetworks(serverId);

显示服务器的专用网络:

var result = client.Servers.ShowPrivateNetworks(serverId, privateNetworkId);

添加服务器的专用网络:

var result = client.Servers.CreatePrivateNetwork(serverId, privateNetworkId);

删除服务器的专用网络:

var result = client.Servers.DeletePrivateNetwork(serverId, privateNetworkId);

列出服务器的快照:

var result = client.Servers.GetSnapshots(serverId);

创建服务器的新快照:

var result = client.Servers.CreateSnapshot(serverId);

将快照还原到服务器:

var result = client.Servers.UpdateSnapshot(serverId, snapshotId);

从服务器删除快照:

var result = client.Servers.DeleteSnapshot(serverId, snapshotId);

创建服务器克隆:

var result = client.Servers.CreateClone(serverId, " Clone Name");

图片

列出所有图像:

var images = client.Images.Get();

取得一张图片:

var image = client.Images.Show(imageId);

创建图像:

var image = client.Images.Create(new POCO.Requests.Images.CreateImageRequest()
            {
                ServerId = serverId, Description = "describe image", Frequency = ImageFrequency.DAILY, Name = "testImage", NumIimages = 44// Max number of images
            });

更新图像:

var result = client.Images.Update(new UpdateImageRequest()
            {
                Description = "updated", Frequency = ImageFrequency.ONCE, Name = "updaeted API Image"
            }, image.Id);

删除图片:

var result = client.Images.Delete(imageId);

共享存储

列出共享存储:

var result = client.SharedStorages.Get();

获取单个共享存储:

var result = client.SharedStorages.Show(sharedStorageId);

创建共享存储:

var result = client.SharedStorages.Create(new POCO.Requests.SharedStorages.CreateSharedStorage()
            {
                Description = "description", Name = "TestStorage", Size = 50
            });

更新共享存储:

var result = client.SharedStorages.Update(new POCO.Requests.SharedStorages.UpdateSharedStorageRequest()
        {
            Description = "description", Name = "TestStorageupdated", Size = 70
        }, sharedStorageId);

删除共享存储:

var result = client.SharedStorages.Delete(sharedStorageId);

列出共享存储服务器:

var result = client.SharedStorages.GetSharedStorageServers(sharedStorageId);

获取共享的存储单个服务器:

var result = client.SharedStorages.ShowSharedStoragesServer(sharedStorageId, serverId);

将服务器附加到共享存储:

// serverstoAdd是代表服务器ID的字符串列表var result = client.SharedStorages.CreateServerSharedStorages(new POCO.Requests.SharedStorages.AttachSharedStorageServerRequest(){Servers = serverstoAdd}, sharedStorageId);

从共享存储中断开服务器的连接:

var result = client.SharedStorages.DeleteSharedStoragesServer(sharedStorageId, serverId);

返回用于访问共享存储的凭据:

var result = client.SharedStorages.ShowSharedStorageAccess();

更改用于访问共享存储的密码:

var result = client.SharedStorages.UpdateSharedStorageAccess(" test123!");

防火墙政策

列出防火墙策略:

var result = client.FirewallPolicies.Get();

获取单个防火墙策略:

var result = client.FirewallPolicies.Show(firewallId);

创建防火墙策略:

var newRules = new System.Collections.Generic.List<POCO.Requests.FirewallPolicies.CreateFirewallPocliyRule>();
        newRules.Add(new POCO.Requests.FirewallPolicies.CreateFirewallPocliyRule()
            {
                PortTo = 80, PortFrom = 80, Protocol = RuleProtocol.TCP, Source = "0.0.0.0"
            });
var result = client.FirewallPolicies.Create(new POCO.Requests.FirewallPolicies.CreateFirewallPolicyRequest()
        {
            Description = "TestFirewall", Name = "TestFW", Rules = newRules
        });

更新防火墙策略:

var result = client.FirewallPolicies.Update(new POCO.Requests.FirewallPolicies.UpdateFirewallPolicyRequest()
        {
            Name = "Updated", Description = "UpdDesc", }, firewallId);

删除防火墙策略:

var result = client.FirewallPolicies.Delete(firewallId);

返回附加到防火墙策略的服务器/ IP的列表:

var result = client.FirewallPolicies.GetFirewallPolicyServerIps(firewallpolicyId);

返回有关分配给防火墙策略的服务器/ IP的信息:

var result = client.FirewallPolicies.ShowFirewallPolicyServerIp(firewallpolicyId, serverIpId);

将服务器/ IP分配给防火墙策略:

// ServerIps是服务器ID的字符串列表var result = client.FirewallPolicies.CreateFirewallPolicyServerIPs(new POCO.Requests.FirewallPolicies.AssignFirewallServerIPRequest(){ServerIps = iptoAdd}, firewallpolicyId);

从防火墙策略中取消分配服务器/ IP:

var result = client.FirewallPolicies.DeleteFirewallPolicyServerIP(firewallpolicyId, serverIpId);

返回防火墙策略规则的列表:

var result = client.FirewallPolicies.GetFirewallPolicyRules(firewallpolicyId);

返回有关防火墙策略规则的信息:

var result = client.FirewallPolicies.ShowFirewallPolicyRule(firewallpolicyId, firewallpolicyRuleId);

向防火墙策略添加新规则:

var result = client.FirewallPolicies.CreateFirewallPolicyRule(new POCO.Requests.FirewallPolicies.AddFirewallPolicyRuleRequest()
            {
                Rules = new System.Collections.Generic.List<POCO.Requests.FirewallPolicies.RuleRequest>()
            {
                {new OneAndOne.POCO.Requests.FirewallPolicies.RuleRequest()
                {
                    PortFrom =8080, PortTo = 8070, Protocol = RuleProtocol.TCP, Source = "0.0.0.0"
                }}
            }
            }, firewallpolicyId);

从防火墙策略中删除规则:

var result = client.FirewallPolicies.DeleteFirewallPolicyRules(firewallpolicyId, firewallpolicyRulesId);

负载均衡器

返回你的负载均衡器列表:

var result = client.LoadBalancer.Get();

返回有关负载均衡器的信息:

var result = client.LoadBalancer.Show(loadBalancerId);

创建一个新的负载均衡器:

var result = client.LoadBalancer.Create(new POCO.Requests.LoadBalancer.CreateLoadBalancerRequest()
            {
                Name = "LBTest", Description = "LBdesc", HealthCheckInterval = 1, Persistence = true, PersistenceTime = 30, HealthCheckTest = HealthCheckTestTypes.NONE, Method = LoadBalancerMethod.ROUND_ROBIN, Rules = new System.Collections.Generic.List<POCO.Requests.LoadBalancer.LoadBalancerRuleRequest>()
                {
                    {new POCO.Requests.LoadBalancer.LoadBalancerRuleRequest()
                    {
                        PortBalancer=80, Protocol=LBRuleProtocol.TCP, Source="0.0.0.0", PortServer=80
                    }
                    }
                }
            });

修改负载均衡器:

var result = client.LoadBalancer.Update(new POCO.Requests.LoadBalancer.UpdateLoadBalancerRequest()
        {
            HealthCheckInterval = 100, HealthCheckTest = HealthCheckTestTypes.TCP, Method = LoadBalancerMethod.ROUND_ROBIN, Persistence = false, Name = "UpdatedLB" + loadBalancer.Name, HealthCheckPathParse = "regex", HealthCheckPath = "google.com"
        }, loadBalancerId);

卸下负载均衡器:

var result = client.LoadBalancer.Delete(loadBalancer.Id);

返回连接到负载均衡器的服务器/ IP的列表:

var result = client.LoadBalancer.GetLoadBalancerServerIps(loadBalancerId);

返回有关分配给负载均衡器的服务器/ IP的信息:

var result = client.LoadBalancer.ShowLoadBalancerServerIp(loadBalancerId, serverIpId);

将服务器/ IP分配给负载均衡器:

// iptoAdd is a list of string contains IDs of server Ips
var result = client.LoadBalancer.CreateLoadBalancerServerIPs(new POCO.Requests.LoadBalancer.AssignLoadBalancerServerIpsRequest()
                    {
                        ServerIps = iptoAdd
                    }, loadBalancerId);

从负载均衡器取消分配服务器/ IP:

var result = client.LoadBalancer.DeleteLoadBalancerServerIP(loadBalancerId, serverIpId);

返回负载均衡器的规则列表:

var result = client.LoadBalancer.GetLoadBalancerRules(loadBalancerId);

返回有关负载均衡器规则的信息:

var result = client.LoadBalancer.ShowLoadBalancerRule(loadBalancerId, ruleId);

向负载均衡器添加新规则:

var result = client.LoadBalancer.CreateLoadBalancerRule(new POCO.Requests.LoadBalancer.AddLoadBalancerRuleRequest()
        {
            Rules = new System.Collections.Generic.List<POCO.Requests.LoadBalancer.RuleRequest>()
            {
                {new OneAndOne.POCO.Requests.LoadBalancer.RuleRequest()
                {
                    PortBalancer =8080, PortServer = 8080, Protocol = LBRuleProtocol.TCP, Source = "0.0.0.0"
                }}
            }
        }, loadBalancerId);

从负载均衡器中删除规则:

var result = client.LoadBalancer.DeleteLoadBalancerRules(loadBalancerId, ruleId);

公开IP

返回你的公共IP列表:

var result = client.PublicIPs.Get();

返回有关公共IP的信息:

var result = client.PublicIPs.Show(publicIpId);

创建一个新的公共IP:

var result = client.PublicIPs.Create(new POCO.Requests.PublicIPs.CreatePublicIPRequest()
            {
                ReverseDns = "dnsNameTest", Type = IPType.IPV4
            });

修改公共IP的反向DNS:

var result = client.PublicIPs.Update(" dnsNameTest", publicIpId);

删除公共IP:

var result = client.PublicIPs.Delete(publicIpId);

私人网络

返回你的专用网络列表:

var result = client.PrivateNetworks.Get();

返回有关专用网络的信息:

var result = client.PrivateNetworks.Show(privateNetworkId);

创建一个新的专用网络:

var result = client.PrivateNetworks.Create(new POCO.Requests.PrivateNetworks.CreatePrivateNetworkRequest()
            {
                Name ="testPrivateNetwork", Description = "test description", NetworkAddress = "192.168.1.0", SubnetMask = "255.255.255.0"
            });

修改专用网络:

var result = client.PrivateNetworks.Update(new POCO.Requests.PrivateNetworks.UpdatePrivateNetworkRequest()
            {
                Name = "updated testPrivateNetwork", NetworkAddress = "192.168.1.0", SubnetMask = "255.255.255.0", }, privateNetworkId);

删除专用网络:

var result = client.PrivateNetworks.Delete(privateNetworkId);

虚拟专用网

返回你的VPN列表:

var结果= client.Vpn.Get()

返回有关VPN的信息:

var result = client.Vpn.Show(vpn.Id);

下载你的VPN配置文件, 该文件是具有OpenVPN配置的base64格式的字符串。这是一个zip文件:

var result = client.Vpn.ShowConfiguration(vpnId);

创建一个新的VPN:

var result = client.Vpn.Create(new POCO.Requests.Vpn.CreateVpnRequest
            {
                Name = "vpn test", Description = "desc", Datacenterid = datacenterId
            });

修改VPN:

var result = client.Vpn.Update(new POCO.Requests.Vpn.UpdateVpnRequest
            {
                Name = "updated name", Description = "desc update"
            }, vpnId);

删除VPN:

var result = client.Vpn.Delete(vpnId);

监控中心

列出监视服务器的用法和警报:

var mCenters = client.MonitoringCenter.Get();

返回指定时间范围内的资源使用情况:

var mCenters = client.MonitoringCenter.Show(serverId, PeriodType.CUSTOM, DateTime.Today.AddMonths(-2), DateTime.Today);

监控政策

返回监视策略列表:

var result = client.MonitoringPolicies.Get();

返回有关监视策略的信息:

var result = client.MonitoringPolicies.Show(monitoringPolicyId);

创建一个新的监视策略:

var ports = new List<POCO.Requests.MonitoringPolicies.Ports>();
        ports.Add(new POCO.Requests.MonitoringPolicies.Ports()
            {
                EmailNotification = true, AlertIf = AlertIfType.RESPONDING, Port = 22, Protocol = ProtocolType.TCP
            });
        var processes = new List<POCO.Requests.MonitoringPolicies.Processes>();
        processes.Add(new Processes()
            {
                EmailNotification = true, AlertIf = ProcessAlertType.NOT_RUNNING, Process = "test", });
        var request = new POCO.Requests.MonitoringPolicies.CreateMonitoringPolictRequest()
            {
                Name = ".netMP", Description = ".net decription", Agent = true, Ports = ports, Processes = processes, Thresholds = new POCO.Requests.MonitoringPolicies.Thresholds()
                {
                    Cpu = new POCO.Requests.MonitoringPolicies.Cpu()
                    {
                        Critical = new POCO.Requests.MonitoringPolicies.Critical()
                        {
                            Alert = false, Value = 95
                        }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                        {
                            Alert = false, Value = 90
                        }
                    }, Ram = new POCO.Requests.MonitoringPolicies.Ram()
                    {
                        Critical = new POCO.Requests.MonitoringPolicies.Critical()
                        {
                            Alert = false, Value = 95
                        }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                        {
                            Alert = false, Value = 90
                        }
                    }, Disk = new POCO.Requests.MonitoringPolicies.Disk()
                    {
                        Critical = new POCO.Requests.MonitoringPolicies.DiskCritical()
                        {
                            Alert = false, Value = 90
                        }, Warning = new POCO.Requests.MonitoringPolicies.DiskWarning()
                        {
                            Alert = false, Value = 80
                        }
                    }, InternalPing = new POCO.Requests.MonitoringPolicies.InternalPing()
                    {
                        Critical = new POCO.Requests.MonitoringPolicies.InternalPingCritical()
                        {
                            Alert = false, Value = 100
                        }, Warning = new POCO.Requests.MonitoringPolicies.InternalPingWarning()
                        {
                            Alert = false, Value = 50
                        }
                    }, Transfer = new POCO.Requests.MonitoringPolicies.Transfer()
                    {
                        Critical = new POCO.Requests.MonitoringPolicies.TransferCritical()
                        {
                            Alert = false, Value = 2000
                        }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                        {
                            Alert = false, Value = 1000
                        }
                    }
                }
            };
        var result = client.MonitoringPolicies.Create(request);

修改监控策略:

var request = new UpdateMonitoringPolicyRequest()
            {
                Name = "updated" + monitoringPolicy.Name, Thresholds = new POCO.Requests.MonitoringPolicies.Thresholds()
               {
                   Cpu = new POCO.Requests.MonitoringPolicies.Cpu()
                   {
                       Critical = new POCO.Requests.MonitoringPolicies.Critical()
                       {
                           Alert = false, Value = 95
                       }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                       {
                           Alert = false, Value = 90
                       }
                   }, Ram = new POCO.Requests.MonitoringPolicies.Ram()
                   {
                       Critical = new POCO.Requests.MonitoringPolicies.Critical()
                       {
                           Alert = false, Value = 95
                       }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                       {
                           Alert = false, Value = 90
                       }
                   }, Disk = new POCO.Requests.MonitoringPolicies.Disk()
                   {
                       Critical = new POCO.Requests.MonitoringPolicies.DiskCritical()
                       {
                           Alert = false, Value = 90
                       }, Warning = new POCO.Requests.MonitoringPolicies.DiskWarning()
                       {
                           Alert = false, Value = 80
                       }
                   }, InternalPing = new POCO.Requests.MonitoringPolicies.InternalPing()
                   {
                       Critical = new POCO.Requests.MonitoringPolicies.InternalPingCritical()
                       {
                           Alert = false, Value = 100
                       }, Warning = new POCO.Requests.MonitoringPolicies.InternalPingWarning()
                       {
                           Alert = false, Value = 50
                       }
                   }, Transfer = new POCO.Requests.MonitoringPolicies.Transfer()
                   {
                       Critical = new POCO.Requests.MonitoringPolicies.TransferCritical()
                       {
                           Alert = false, Value = 2000
                       }, Warning = new POCO.Requests.MonitoringPolicies.Warning()
                       {
                           Alert = false, Value = 1000
                       }
                   }
               }
            };
        var result = client.MonitoringPolicies.Update(request, monitoringPolicy.Id);

删除监视策略:

var结果= client.MonitoringPolicies.Delete(monitoringPolicyId);

返回监视策略的端口列表:

var result = client.MonitoringPoliciesPorts.Get(monitoringPolicyId);

返回有关监视策略的端口的信息:

var result = client.MonitoringPoliciesPorts.Show(monitoringPolicy.Id, port.Id);

将新端口添加到监视策略:

var ports = new List<POCO.Requests.MonitoringPolicies.Ports>();
        ports.Add(new POCO.Requests.MonitoringPolicies.Ports()
            {
                EmailNotification = true, AlertIf = AlertIfType.RESPONDING, Port = 97, Protocol = ProtocolType.TCP
            });
        ports.Add(new POCO.Requests.MonitoringPolicies.Ports()
            {
                EmailNotification = true, AlertIf = AlertIfType.RESPONDING, Port = 98, Protocol = ProtocolType.TCP
            });
var result = client.MonitoringPoliciesPorts.Create(ports, monitoringPolicyId);

通过监视策略修改端口:

var request = new POCO.Requests.MonitoringPolicies.Ports()
            {
                EmailNotification = true, AlertIf = AlertIfType.RESPONDING, Port = 23, Protocol = ProtocolType.TCP
            };
var result = client.MonitoringPoliciesPorts.Update(request, monitoringPolicyId, portId);`

从监视策略中删除端口:

var result = client.MonitoringPoliciesPorts.Delete(monitoringPolicyId, portId);

返回监视策略的流程列表:

var result = client.MonitoringPoliciesProcesses.Get(monitoringPolicyId);

返回有关监视策略过程的信息:

var result = client.MonitoringPoliciesProcesses.Show(monitoringPolicyId, processId);

将新流程添加到监视策略:

var processes = new List<POCO.Requests.MonitoringPolicies.Processes>();
        processes.Add(new POCO.Requests.MonitoringPolicies.Processes()
        {
            EmailNotification = true, AlertIf = ProcessAlertType.RUNNING, Process = "iexplorer"
        });
        processes.Add(new POCO.Requests.MonitoringPolicies.Processes()
        {
            EmailNotification = true, AlertIf = ProcessAlertType.RUNNING, Process = "test"
        });
var result = client.MonitoringPoliciesProcesses.Create(processes, monitoringPolicyId);

通过监视策略修改流程:

var result = client.MonitoringPoliciesProcesses.Update(new POCO.Requests.MonitoringPolicies.Processes()
            {
                EmailNotification = true, AlertIf = ProcessAlertType.RUNNING, Process = "test"
            }, monitoringPolicyId, processId);

从监视策略中删除进程:

var result = client.MonitoringPoliciesProcesses.Delete(monitoringPolicyId, processId);

返回附加到监视策略的服务器的列表:

var result = client.MonitoringPoliciesServers.Get(monitoringPolicyId);

返回有关附加到监视策略的服务器的信息:

var result = client.MonitoringPoliciesServers.Show(monitoringPolicyId, serverId);

将服务器附加到监视策略:

//服务器是服务器ID的字符串列表var result = client.MonitoringPoliciesServers.Create(servers, monitoringPolicyId);

从监视策略中断开服务器的连接:

var result = client.MonitoringPoliciesServers.Delete(monitoringPolicyId, serverId);

日志

返回带有日志的列表:

var result = client.Logs.Get(PeriodType.LAST_24H);

返回有关日志的信息:

var result = client.Logs.Show(logId);

用户数

返回所有用户的列表:

var result = client.Users.Get();

返回有关用户的信息:

var result = client.Users.Show(UserId);

创建一个新用户:

var result = client.Users.Create(new POCO.Requests.Users.CreateUserRequest()
        {
            Name = "test user", Password = "Test123!", Description = "description", });

修改用户信息:

var result = client.Users.Update(new POCO.Requests.Users.UpdateUserRequest()
        {
            Description = "description", State = UserState.ACTIVE
        }, UserId);

删除用户:

var result = client.Users.Delete(UserId);

有关API的信息:

var result = client.UserAPI.ShowUserAPI(UserId);

允许启用或禁用API:

var result = client.UserAPI.UpdateUserAPI(UserId, true);

显示API密钥:

var result = client.UserAPI.ShowUserAPIKey(UserId);

更改API密钥:

var result = client.UserAPI.UpdateAPIKey(UserId);

返回允许访问API的IP:

var result = client.UserAPI.GetUserIps(UserId);

允许新的IP:

var listOfIps = new List<string>();
listOfIps.Add("185.13.243.86");
var result = client.UserAPI.UpdateAPIIps(listOfIps, UserId);`

删除IP并禁止对其进行API访问:

var result = client.UserAPI.DeleteUserIp(UserId, allowedIp);

的角色

返回具有所有角色的列表:

var result = client.Roles.Get();

返回有关角色的信息:

var result = client.Roles.Show(roleId);

创建一个新角色:

var result = client.Roles.Create(roleName);

修改角色信息:

var result = client.Roles.Update(roleName, description, POCO.Requests.Users.UserState.ACTIVE, role.Id);

删除角色:

var result = client.Roles.Delete(roleId);

列出角色的权限:

var result = client.Roles.GetPermissions(role.Id);

向角色添加权限:

var result = client.Roles.UpdatePermissions(new Permissions
            {
                Servers = new POCO.Response.Roles.Servers
                {
                    Show = true, SetName = false, Shutdown = true
                }
            }, roleId);

返回分配给角色的用户:

var result = client.Roles.GetRoleUsers(roleId);

将用户添加到角色:

var result = client.Roles.CreateRoleUsers(new System.Collections.Generic.List <string> {{userId}}, roleId);

返回有关用户的信息:

var userInfo = client.Roles.ShowRoleUser(roleId, userId);

从角色中删除用户:

var removed = client.Roles.DeleteRoleUser(roleId, userId);

克隆角色:

var clone = client.Roles.CreateRoleClone(cloneName, roleId);

用法

返回你的用法列表:

var result = client.Usages.Get(PeriodType.LAST_24H);

服务器设备

返回可用于创建服务器的所有设备的列表:

var result = client.ServerAppliances.Get();

返回有关特定设备的信息:

var result = client.ServerAppliances.Show(appliancesId);

DVD ISO

返回可以加载到虚拟DVD单元中的所有操作系统和工具的列表:

var result = client.DVDs.Get();

有关特定ISO映像的信息:

var result = client.DVDs.Show(dvdId);

Ping API, 如果API正在运行, 则返回true:

var result = client.Common.Ping();

Ping API身份验证, 如果API令牌有效, 则返回true

var result = client.Common.PingAuthentication();

价钱

返回Cloud Panel中所有可用资源的价格:

var result = client.Common.GetPricing();

数据中心

返回有关可用数据中心的信息以创建资源:

var result = client.DataCenters.Get();

返回有关数据中心的信息:

var result = client.DataCenters.Show(dcId);

版权所有(c)2016 notlogy Internet SE

上次更新时间:2017年7月12日

一盏木

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: