// IPAddress1At 指定インデックスのNICのIPアドレス1
490529
func (v *VPCRouter) IPAddress1At(index int) string {
	if len(v.Interfaces) <= index {
		return ""
	}

	if index == 0 {
		if v.IsStandardPlan() {
			return v.Interfaces[0].IPAddress
		}

		if !v.HasInterfaces() {
			return ""
		}
		if len(v.Settings.Router.Interfaces[0].IPAddress) < 1 {
			return ""
		}
		return v.Settings.Router.Interfaces[0].IPAddress[0]
	}

	nic := v.Settings.Router.Interfaces[index]
	if len(nic.IPAddress) < 1 {
		return ""
	}
	return nic.IPAddress[0]
}
197176
func (s *CreateLoadBalancerInput) SetIpAddressType(v string) *CreateLoadBalancerInput {
	s.IpAddressType = &v
	return s
}
1070242
func (s *BrokerInstance) SetIpAddress(v string) *BrokerInstance {
	s.IpAddress = &v
	return s
}
551814
func (s *InstanceAccessDetails) SetIpAddress(v string) *InstanceAccessDetails {
	s.IpAddress = &v
	return s
}
1120603
func (s *ResolverEndpoint) SetIpAddressCount(v int64) *ResolverEndpoint {
	s.IpAddressCount = &v
	return s
}
204579
func ValidateIPAddress(val string) (string, error) {
	var ip = net.ParseIP(strings.TrimSpace(val))
	if ip != nil {
		return ip.String(), nil
	}
	return "", fmt.Errorf("%s is not an ip address", val)
}
302436
func GetIPv6HostID(subnetAddr string, subnetLen uint, hostAddr string) (string, error) {
	if subnetLen > 128 || subnetLen < 16 {
		return "", core.Errorf("subnet length %d not supported", subnetLen)
	}
	// Initialize hostID
	hostID := net.IPv6zero

	var offset uint

	// get the overlapping byte
	offset = subnetLen / 8
	subnetIP := net.ParseIP(subnetAddr)
	if subnetIP == nil {
		return "", core.Errorf("Invalid subnetAddr %s ", subnetAddr)
	}
	s := uint8(subnetIP[offset])
	hostIP := net.ParseIP(hostAddr)
	if hostIP == nil {
		return "", core.Errorf("Invalid hostAddr %s ", hostAddr)
	}
	h := uint8(hostIP[offset])
	hostID[offset] = byte(h - s)

	// Copy the rest of the bytes
	for i := (offset + 1); i < 16; i++ {
		hostID[i] = hostIP[i]
		offset++
	}
	return hostID.String(), nil
}
379141
func (s *Server) CIDRIPAddress() string {
	ip, maskLen := s.IPAddress(), s.NetworkMaskLen()
	if ip != "" && maskLen > 0 {
		return fmt.Sprintf("%s/%d", ip, maskLen)
	}
	return ""
}
507468
func (addr Address) NetworkAddress() network.Address {
	return network.Address{
		Value:     addr.Value,
		Type:      network.AddressType(addr.Type),
		Scope:     network.Scope(addr.Scope),
		SpaceName: network.SpaceName(addr.SpaceName),
	}
}
1313764
func (r *PURuntime) IPAddresses() ExtendedMap {
	r.Lock()
	defer r.Unlock()

	return r.ips.Copy()
}
1123234
func (addr *address) networkAddress() network.Address {
	return network.Address{
		Value:     addr.Value,
		Type:      network.AddressType(addr.AddressType),
		Scope:     network.Scope(addr.Scope),
		SpaceName: network.SpaceName(addr.SpaceName),
	}
}
319776
func (m *MobileGateway) IPAddressAt(index int) string {
	if len(m.Interfaces) <= index {
		return ""
	}
	if index == 0 {
		return m.Interfaces[0].IPAddress
	}

	ipaddresses := m.Settings.MobileGateway.Interfaces[index].IPAddress
	if len(ipaddresses) < 1 {
		return ""
	}
	return ipaddresses[0]
}
630141
func (s *CreateResolverEndpointInput) SetIpAddresses(v []*IpAddressRequest) *CreateResolverEndpointInput {
	s.IpAddresses = v
	return s
}
843767
func (s *UpdateHealthCheckInput) SetIPAddress(v string) *UpdateHealthCheckInput {
	s.IPAddress = &v
	return s
}
219869
func (api *VPCRouterAPI) DeleteInterfaceAt(routerID int64, index int) (*sacloud.VPCRouter, error) {
	router, err := api.Read(routerID)
	if err != nil {
		return nil, err
	}

	req := &sacloud.VPCRouter{Settings: &sacloud.VPCRouterSettings{}}

	if router.Settings == nil {
		req.Settings = &sacloud.VPCRouterSettings{
			// Router
			Router: &sacloud.VPCRouterSetting{
				// Interfaces
				Interfaces: []*sacloud.VPCRouterInterface{nil},
			},
		}
	} else {
		req.Settings.Router = router.Settings.Router
	}

	//disconnect to switch
	_, err = api.DisconnectFromSwitch(routerID, index)
	if err != nil {
		return nil, err
	}

	if index < len(req.Settings.Router.Interfaces) {
		req.Settings.Router.Interfaces[index] = nil
	}

	res, err := api.UpdateSetting(routerID, req)
	if err != nil {
		return nil, err
	}

	return res, nil

}
964780
func (s *CreateMountTargetInput) SetIpAddress(v string) *CreateMountTargetInput {
	s.IpAddress = &v
	return s
}
779687
func (v *VPCRouter) VirtualIPAddressAt(index int) string {
	if v.IsStandardPlan() {
		return ""
	}
	if len(v.Interfaces) <= index {
		return ""
	}

	return v.Settings.Router.Interfaces[0].VirtualIPAddress
}