Ejemplo n.º 1
0
        public Interface(Mapping.Interface iface, DataCenter[] dataCenters = null, IpAddress[] ips = null)
        {
            this.Id = iface.Id;
            this.DataCenterId = iface.DataCenterId;
            if (dataCenters != null)
                this.DataCenter = dataCenters.SingleOrDefault(d => d.Id == iface.DataCenterId);
            this.Created = iface.Created;
            this.LastUpdated = iface.LastUpdated;
            if (iface.Num != null)
                this.Index = Convert.ToInt32(iface.Num);
            this.Status = Converter.ToInterfaceStatus(iface.State);
            this.Bandwidth = iface.Bandwidth;
            this.Type = Converter.ToInterfaceType(iface.Type);
            if (iface.VirtualMachineId != null)
                this.VirtualMachineId = Convert.ToInt32(iface.VirtualMachineId);
            this.VirtualMachine = null;
            this.IpAddressIds = iface.IpAddressIds;
            if (ips != null)
            {
                List<IpAddress> ipList = new List<IpAddress>();
                foreach (int ipId in iface.IpAddressIds)
                {
                    IpAddress ipAddress = ips.SingleOrDefault(i => i.Id == ipId);

                    if (ipAddress.Interface == null)
                        ipAddress.Interface = this;

                    ipList.Add(ipAddress);
                }
                this.IpAddresses = ipList.ToArray();
            }
        }
Ejemplo n.º 2
0
        public Interface Single(int interfaceId, DataCenter[] dataCenters = null, IpAddress[] ipAddresses = null)
        {
            Mapping.Interface mappingInterface = this.service.InterfaceInfo(this.apiKey, interfaceId);

            if (mappingInterface != null)
                return new Interface(mappingInterface, dataCenters, ipAddresses);
            else
                return null;
        }
Ejemplo n.º 3
0
        public Interface[] List(DataCenter[] dataCenters = null, IpAddress[] ipAddresses = null)
        {
            Mapping.Interface[] mappingInterfaces = this.service.InterfaceList(this.apiKey);

            List<Interface> interfaceList = new List<Interface>();
            foreach (Mapping.Interface mappingInterface in mappingInterfaces)
                interfaceList.Add(new Interface(mappingInterface, dataCenters, ipAddresses));

            Interface[] interfaces = interfaceList.ToArray();

            return interfaces;
        }
        public IpAddressResourceDetail(IpAddress ipAddress)
        {
            this.ipAddress = ipAddress;

            this.Value = ipAddress.Ip.ToString();

            ResourceDetailAction copyAction = new ResourceDetailAction(IpAddressResourceDetail.CopyCommandName);
            copyAction.Command = new RelayCommand((parameter) => this.Copy(parameter));

            ResourceDetailAction detachAction = new ResourceDetailAction(IpAddressResourceDetail.DetachCommandName, true);
            detachAction.Command = new RelayCommand((parameter) => this.Detach(parameter));

            ResourceDetailAction editAction = new ResourceDetailAction(IpAddressResourceDetail.EditCommandName);
            editAction.Command = new RelayCommand((parameter) => this.Edit(parameter));

            this.Actions = new ResourceDetailAction[]
            {
                copyAction,
                //detachAction,
                editAction
            };
        }
Ejemplo n.º 5
0
        public IpAddressOperation Update(IpAddress ipAddress, IpAddressUpdate ipAddressUpdate)
        {
            Mapping.IpAddressUpdate mappingIpAddressUpdate = new Mapping.IpAddressUpdate(ipAddressUpdate);

            return new IpAddressOperation(this.service.IpAddressUpdate(this.apiKey, ipAddress.Id, mappingIpAddressUpdate), ipAddress);
        }
Ejemplo n.º 6
0
        public IpAddressOperation Delete(IpAddress ipAddress)
        {
            throw new System.NotImplementedException();

            return new IpAddressOperation(this.service.IpAddressDelete(this.apiKey, ipAddress.Id), ipAddress);
        }
Ejemplo n.º 7
0
        public InterfaceOperation DetachIpAddress(Interface iface, IpAddress ipAddress)
        {
            throw new System.NotImplementedException();

            return new InterfaceOperation(this.service.InterfaceDetachIp(this.apiKey, iface.Id, ipAddress.Id), iface, ipAddress);
        }