// RemoveServiceEndpoints removes all public endpoints of a service from
// zookeeper.
189201
func (zk *zkf) RemoveServiceEndpoints(serviceID string) error {
	logger := plog.WithField("serviceid", serviceID)

	// get the root-based connection to delete the service endpoints
	rootconn, err := zzk.GetLocalConnection("/")
	if err != nil {
		logger.WithError(err).Debug("Could not acquire a root-based connection to delete the service's public endpoints in zookeeper")
		return err
	}

	zk.svcRegistry.Lock()
	defer zk.svcRegistry.Unlock()
	if zk.svcRegistry.registry == nil {
		err = zk.buildServiceRegistryCache(rootconn)
		if err != nil {
			logger.WithError(err).Debug("Could not build cache of the service registry")
			return err
		}
	}

	// delete the public endpoints for this service
	syncRequest := zkr.ServiceRegistrySyncRequest{
		ServiceID:       serviceID,
		PortsToPublish:  make(map[zkr.PublicPortKey]zkr.PublicPort),
		PortsToDelete:   []zkr.PublicPortKey{},
		VHostsToPublish: make(map[zkr.VHostKey]zkr.VHost),
		VHostsToDelete:  []zkr.VHostKey{},
	}

	serviceRegistry := zk.svcRegistry.GetRegistryForService(serviceID)
	for key, _ := range serviceRegistry.PublicPorts {
		syncRequest.PortsToDelete = append(syncRequest.PortsToDelete, key)
	}
	for key, _ := range serviceRegistry.VHosts {
		syncRequest.VHostsToDelete = append(syncRequest.VHostsToDelete, key)
	}

	// sync the registry
	if err := zkr.SyncServiceRegistry(rootconn, syncRequest); err != nil {
		logger.WithError(err).Debug("Could not delete the service's public endpoints in zookeeper")
		return err
	}

	// Update our local cache now that we know that ZK was updated successfully
	zk.svcRegistry.UpdateRegistry(serviceID, syncRequest.PortsToPublish, syncRequest.VHostsToPublish)
	logger.Debug("Deleted the service's public endpoints in zookeeper")
	return nil
}
819438
func (dp *Datapoint) RemoveProperty(key string) {
	if dp.Meta[tsProperty] != nil {
		delete(dp.GetProperties(), key)
		if len(dp.GetProperties()) == 0 {
			delete(dp.Meta, tsProperty)
		}
	}
}
1271961
func (loadBalancer *HostComputeLoadBalancer) RemoveEndpoint(endpoint *HostComputeEndpoint) (*HostComputeLoadBalancer, error) {
	logrus.Debugf("hcn::HostComputeLoadBalancer::RemoveEndpoint loadBalancer=%s endpoint=%s", loadBalancer.Id, endpoint.Id)

	err := loadBalancer.Delete()
	if err != nil {
		return nil, err
	}

	// Create a list of all the endpoints besides the one being removed
	var endpoints []string
	for _, endpointReference := range loadBalancer.HostComputeEndpoints {
		if endpointReference == endpoint.Id {
			continue
		}
		endpoints = append(endpoints, endpointReference)
	}
	loadBalancer.HostComputeEndpoints = endpoints
	return loadBalancer.Create()
}
534668
func (c *Client) RemovePublicEndpointVHost(serviceid, endpointName, vhost string) error {
	request := &PublicEndpointRequest{
		Serviceid:    serviceid,
		EndpointName: endpointName,
		Name:         vhost,
	}
	return c.call("RemovePublicEndpointVHost", request, nil)
}
1068765
func (s *ServiceOfferingService) DeleteServiceOffering(p *DeleteServiceOfferingParams) (*DeleteServiceOfferingResponse, error) {
	resp, err := s.cs.newRequest("deleteServiceOffering", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DeleteServiceOfferingResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
234948
func (c *Cluster) RemoveService(input string) error {
	return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
		service, err := getService(ctx, state.controlClient, input, false)
		if err != nil {
			return err
		}

		_, err = state.controlClient.RemoveService(ctx, &swarmapi.RemoveServiceRequest{ServiceID: service.ID})
		return err
	})
}
96441
func (c *Client) GetServiceEndpoints(serviceIDs []string, reportImports, reportExports bool, validate bool) ([]applicationendpoint.EndpointReport, error) {
	request := &EndpointRequest{
		ServiceIDs:    serviceIDs,
		ReportImports: reportImports,
		ReportExports: reportExports,
		Validate:      validate,
	}
	result := make([]applicationendpoint.EndpointReport, 0)
	err := c.call("GetServiceEndpoints", request, &result)
	if err != nil {
		return nil, err
	}
	return result, nil
}
65747
func (s *Service) RemovePort(application string, portAddr string) error {
	if s.Endpoints == nil {
		return fmt.Errorf("Service %s has no Endpoints", s.Name)
	}

	//find the matching endpoint
	for i := range s.Endpoints {
		ep := &s.Endpoints[i]

		if ep.Application == application && ep.Purpose == "export" {
			if len(ep.PortList) == 0 {
				break
			}

			portFound := false
			var ports = make([]servicedefinition.Port, 0)
			for _, port := range ep.PortList {
				if port.PortAddr != portAddr {
					ports = append(ports, port)
				} else {
					portFound = true
				}
			}

			//error removing an unknown port
			if !portFound {
				return fmt.Errorf("endpoint %s does not have a port endpoint %s", application, portAddr)
			}

			ep.PortList = ports
			return nil
		}
	}

	return fmt.Errorf("unable to find application %s in service: %s", application, s.Name)
}
1126496
func (l *State) RemoveServiceWithChecks(serviceID string, checkIDs []types.CheckID) error {
	l.Lock()
	defer l.Unlock()

	if err := l.removeServiceLocked(serviceID); err != nil {
		return err
	}

	for _, id := range checkIDs {
		if err := l.removeCheckLocked(id); err != nil {
			return err
		}
	}

	return nil
}
692142
func (d *OvsDriver) DeleteEndpoint(id string) error {
	epOper := drivers.OperEndpointState{}
	epOper.StateDriver = d.oper.StateDriver
	err := epOper.Read(id)
	if err != nil {
		return err
	}
	defer func() {
		epOper.Clear()
	}()

	// Get the network state
	cfgNw := mastercfg.CfgNetworkState{}
	cfgNw.StateDriver = d.oper.StateDriver
	err = cfgNw.Read(epOper.NetID)
	if err != nil {
		return err
	}

	// Find the switch based on network type
	var sw *OvsSwitch
	if cfgNw.PktTagType == "vxlan" {
		sw = d.switchDb["vxlan"]
	} else {
		sw = d.switchDb["vlan"]
	}

	skipVethPair := (cfgNw.NwType == "infra")
	err = sw.DeletePort(&epOper, skipVethPair)
	if err != nil {
		log.Errorf("Error deleting endpoint: %+v. Err: %v", epOper, err)
	}

	d.oper.localEpInfoMutex.Lock()
	delete(d.oper.LocalEpInfo, id)
	d.oper.localEpInfoMutex.Unlock()
	err = d.oper.Write()
	if err != nil {
		return err
	}

	return nil
}
1130006
func FilterEndpoint(name string) Filter {
	return func(old []*registry.Service) []*registry.Service {
		var services []*registry.Service

		for _, service := range old {
			for _, ep := range service.Endpoints {
				if ep.Name == name {
					services = append(services, service)
					break
				}
			}
		}

		return services
	}
}
685538
func (eps *transportEndpoints) unregisterEndpoint(id TransportEndpointID, ep TransportEndpoint) {
	eps.mu.Lock()
	defer eps.mu.Unlock()
	e, ok := eps.endpoints[id]
	if !ok {
		return
	}
	if multiPortEp, ok := e.(*multiPortEndpoint); ok {
		if !multiPortEp.unregisterEndpoint(ep) {
			return
		}
	}
	delete(eps.endpoints, id)
}
653577
func (d *Daemon) RemoveFromEndpointQueue(epID uint64) {
	d.uniqueIDMU.Lock()
	if cancel, queued := d.uniqueID[epID]; queued && cancel != nil {
		delete(d.uniqueID, epID)
		cancel()
	}
	d.uniqueIDMU.Unlock()
}
543018
func (c *Client) DeleteServiceOffering(p *DeleteServiceOfferingParameter) (*Result, error) {
	obj, err := c.Request("deleteServiceOffering", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
349233
func (pl *List) removePeerIdentifierReferences(pid peer.Identifier) (*peerThunk, error) {
	if t := pl.availablePeers[pid.Identifier()]; t != nil {
		return t, pl.removeFromAvailablePeers(t)
	}

	if t, ok := pl.unavailablePeers[pid.Identifier()]; ok && t != nil {
		pl.removeFromUnavailablePeers(t)
		return t, nil
	}

	return nil, peer.ErrPeerRemoveNotInList(pid.Identifier())
}
1002205
func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
	operation := "RemoveEndpoint"
	title := "hcsshim::PolicyList::" + operation
	logrus.Debugf(title+" id=%s, endpointId:%s", policylist.ID, endpoint.Id)

	_, err := policylist.Delete()
	if err != nil {
		return nil, err
	}

	elementToRemove := "/endpoints/" + endpoint.Id

	var references []string

	for _, endpointReference := range policylist.EndpointReferences {
		if endpointReference == elementToRemove {
			continue
		}
		references = append(references, endpointReference)
	}
	policylist.EndpointReferences = references
	return policylist.Create()
}
1125388
func (s *NetworkFabricAttributes) SetOrderingServiceEndpoint(v string) *NetworkFabricAttributes {
	s.OrderingServiceEndpoint = &v
	return s
}