示例#1
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var rolesApi = client.Roles;
            var resp     = rolesApi.UpdatePermissions(new Permissions
            {
                Servers             = Servers,
                SharedStorages      = SharedStorages,
                Backups             = Backups,
                FirewallPolicies    = FirewallPolicies,
                Images              = Images,
                InteractiveInvoices = InteractiveInvoices,
                LoadBalancers       = LoadBalancers,
                Logs               = Logs,
                MonitoringCenter   = MonitoringCenter,
                MonitoringPolicies = MonitoringPolicies,
                PrivateNetwork     = PrivateNetwork,
                PublicIps          = PublicIps,
                Roles              = Roles,
                Usages             = Usages,
                Users              = Users,
                Vpn = Vpn
            }, RoleId);

            WriteObject(resp);
        }
示例#2
0
        protected override void BeginProcessing()
        {
            try
            {
                client = OneAndOneClient.Instance(Helper.Configuration);
                var lbApi  = client.LoadBalancer;
                var result = lbApi.Create(new CreateLoadBalancerRequest
                {
                    DatacenterId          = DatacenterId ?? null,
                    Description           = Description ?? null,
                    HealthCheckInterval   = HealthCheckInterval,
                    HealthCheckPath       = HealthCheckPath ?? null,
                    HealthCheckPathParser = HealthCheckPathParser ?? null,
                    HealthCheckTest       = HealthCheckTest,
                    Method          = Method,
                    Name            = Name,
                    Persistence     = Persistence,
                    PersistenceTime = PersistenceTime,
                    Rules           = new List <LoadBalancerRuleRequest>(Rules)
                });

                WriteVerbose("Creating the load balancer...");
                WriteObject(result);
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
            }
        }
示例#3
0
        protected override void BeginProcessing()
        {
            try
            {
                client = OneAndOneClient.Instance(Helper.Configuration);
                var imageApi = client.Images;
                var result   = imageApi.Create(new CreateImageRequest
                {
                    ServerId     = ServerId,
                    Description  = Description,
                    Frequency    = Frequency,
                    Name         = Name,
                    NumIimages   = NumImages,
                    Source       = Source,
                    DatacetnerId = DatacetnerId ?? null,
                    OsId         = OsId ?? null,
                    Type         = Type,
                    Url          = Url ?? null
                });


                WriteVerbose("Creating the image...");

                WriteObject(result);
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
            }
        }
        static public void TestClean()
        {
            var testclient = OneAndOneClient.Instance(new Client.RESTHelpers.Configuration(testToken));
            var result     = testclient.Users.Delete(user.Id);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Id);
        }
示例#5
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var usersApi = client.UserAPI;
            var resp     = usersApi.UpdateAPIKey(UserId);

            WriteObject(resp);
        }
示例#6
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var ipApi = client.PublicIPs;
            var resp  = ipApi.Update(ReverseDns, IpId);

            WriteObject(resp);
        }
示例#7
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var mpApi = client.MonitoringPoliciesPorts;
            var resp  = mpApi.Update(Ports, PolicyId, PortId);

            WriteObject(resp);
        }
示例#8
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var storageApi = client.SharedStorages;

            var resp = storageApi.UpdateSharedStorageAccess(Password);

            WriteObject(resp);
        }
示例#9
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var roleApi = client.Roles;
            var role    = roleApi.Show(RoleId);
            var resp    = roleApi.Update(Name, Description, State ?? role.State, RoleId);

            WriteObject(resp);
        }
        public static void WaitBlockStorageReady(string blockStorageId)
        {
            var client       = OneAndOneClient.Instance(Configuration);
            var blockStorage = client.BlockStorages.Show(blockStorageId);

            while (blockStorage != null && blockStorage.State != "POWERED_ON")
            {
                Thread.Sleep(5000);
                blockStorage = client.BlockStorages.Show(blockStorageId);
            }
        }
        public static void waitLoadBalancerReady(string lbId)
        {
            var client = OneAndOneClient.Instance(Configuration);
            var lb     = client.LoadBalancer.Show(lbId);

            while (lb.State == "CONFIGURING")
            {
                Thread.Sleep(2000);
                lb = client.LoadBalancer.Show(lb.Id);
            }
        }
        public static void waitImageReady(string imgId)
        {
            var client = OneAndOneClient.Instance(Configuration);
            var img    = client.Images.Show(imgId);

            while (img.State != "ACTIVE" && img.State != "ENABLED")
            {
                Thread.Sleep(5000);
                img = client.Images.Show(img.Id);
            }
        }
        public static void waitSharedStorageReady(string shareStorageId)
        {
            var client        = OneAndOneClient.Instance(Configuration);
            var sharedStorage = client.SharedStorages.Show(shareStorageId);

            while (sharedStorage.State == "CONFIGURING")
            {
                Thread.Sleep(2000);
                sharedStorage = client.SharedStorages.Show(sharedStorage.Id);
            }
        }
        public static void waitFirewallPolicyReady(string fwId)
        {
            var client = OneAndOneClient.Instance(Configuration);
            var fw     = client.FirewallPolicies.Show(fwId);

            while (fw.State == "CONFIGURING")
            {
                Thread.Sleep(2000);
                fw = client.FirewallPolicies.Show(fw.Id);
            }
        }
        public static void waitIpReady(string ipId)
        {
            var client   = OneAndOneClient.Instance(Configuration);
            var publicIP = client.PublicIPs.Show(ipId);

            while (publicIP.State != "ACTIVE")
            {
                Thread.Sleep(5000);
                publicIP = client.PublicIPs.Show(publicIP.Id);
            }
        }
        public static void waitPrivateNetworkReady(string pnId)
        {
            var client = OneAndOneClient.Instance(Configuration);
            var pn     = client.PrivateNetworks.Show(pnId);

            while (pn.State != "ACTIVE")
            {
                Thread.Sleep(10000);
                pn = client.PrivateNetworks.Show(pnId);
            }
        }
        public static void waitMonitoringPolicyReady(string mpId)
        {
            var client = OneAndOneClient.Instance(Configuration);
            var mp     = client.MonitoringPolicies.Show(mpId);

            while (mp.State != "ACTIVE")
            {
                Thread.Sleep(2000);
                mp = client.MonitoringPolicies.Show(mp.Id);
            }
        }
        public static void waitServerTurnedOff(string ServerId)
        {
            Thread.Sleep(5000);
            var client = OneAndOneClient.Instance(Configuration);
            var server = client.Servers.Show(ServerId);

            while (server != null && (server.Status.State != POCO.Response.Servers.ServerState.POWERED_OFF || (server.Status.Percent != 0 && server.Status.Percent != 99)))
            {
                Thread.Sleep(10000);
                server = client.Servers.Show(ServerId);
            }
        }
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var vpnApi = client.Vpn;
            var resp   = vpnApi.Update(new POCO.Requests.Vpn.UpdateVpnRequest
            {
                Name        = Name ?? null,
                Description = Description ?? null
            }, VpnId);

            WriteObject(resp);
        }
示例#20
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var storageApi = client.SharedStorages;
            var storage    = client.SharedStorages.Show(StorageId);

            var resp = storageApi.Update(new POCO.Requests.SharedStorages.UpdateSharedStorageRequest {
                Name = Name ?? null, Description = Description ?? null, Size = Size ?? storage.Size
            }, StorageId);

            WriteObject(resp);
        }
示例#21
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var imageApi = client.Images;
            var image    = client.Images.Show(ImageId);

            var resp = imageApi.Update(new UpdateImageRequest {
                Name = Name ?? null, Description = Description ?? null, Frequency = Frequency ?? image.Frequency
            }, ImageId);

            WriteObject(resp);
        }
        public void UpdateUsersAPIKey()
        {
            var result = client.UserAPI.UpdateAPIKey(user.Id);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Id);
            //test the new API KEY
            var test = OneAndOneClient.Instance(new Client.RESTHelpers.Configuration {
                ApiUrl = "https://cloudpanel-api.1and1.com/v1", ApiKey = result.Api.Key
            }).Users.Get(null, null, null, "dotnetTest");

            Assert.IsNotNull(test);
        }
示例#23
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var usersApi = client.UserAPI;
         var resp     = usersApi.DeleteUserIp(UserId, IP);
         WriteObject(resp);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#24
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var roleApi = client.Roles;
         var result  = roleApi.DeleteRoleUser(UserId, RoleId);
         WriteObject(result);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#25
0
        protected override void BeginProcessing()
        {
            client = OneAndOneClient.Instance(Helper.Configuration);
            var firewallApi = client.FirewallPolicies;
            var firewall    = client.FirewallPolicies.Show(FirewallId);

            var resp = firewallApi.Update(new UpdateFirewallPolicyRequest
            {
                Name        = Name ?? null,
                Description = Description ?? null
            }, FirewallId);

            WriteObject(resp);
        }
示例#26
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var userApi = client.UserAPI;
         var userKey = userApi.ShowUserAPIKey(UserId);
         WriteObject(userKey);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#27
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var mpApi = client.MonitoringPoliciesServers;
         var resp  = mpApi.Delete(PolicyId, ServerId);
         WriteObject(resp);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#28
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var pnApi = client.PrivateNetworks;
         var resp  = pnApi.DeletePrivateNetworksServer(NetworkId, ServerId);
         WriteObject(resp);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#29
0
 protected override void BeginProcessing()
 {
     try
     {
         client = OneAndOneClient.Instance(Helper.Configuration);
         var firewallApi = client.FirewallPolicies;
         var resp        = firewallApi.DeleteFirewallPolicyRules(FirewallId, RuleId);
         WriteObject(resp);
     }
     catch (Exception ex)
     {
         WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
     }
 }
示例#30
0
        public void UpdateUsersAPIKey()
        {
            Random random = new Random();
            var    Users  = client.Users.Get(null, null, null, "aliba");
            var    User   = Users[0];
            var    result = client.UserAPI.UpdateAPIKey(User.Id);

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Id);
            //test the new API KEY
            var test = OneAndOneClient.Instance("https://cloudpanel-api.1and1.com/v1", result.Api.Key).Users.Get(null, null, null, "aliba");

            Assert.IsNotNull(test);
        }