// PutServiceID creates or updates a service. Returns true if service was created.
423984
func (c *Client) PutServiceID(id int64, svc *models.ServiceSpec) (bool, error) {
	svc.ID = id
	params := service.NewPutServiceIDParams().WithID(id).WithConfig(svc).WithTimeout(api.ClientTimeout)
	_, created, err := c.Service.PutServiceID(params)
	return created != nil, Hint(err)
}
1311880
func (proxier *Proxier) OnServiceAdd(service *v1.Service) {
	proxier.OnServiceUpdate(nil, service)
}
299283
func (ctx *ServiceContext) Service(service interface{}) error {
	element := reflect.ValueOf(service).Elem()
	if running, ok := ctx.services[element.Type()]; ok {
		element.Set(reflect.ValueOf(running))
		return nil
	}
	return ErrServiceUnknown
}
1257316
func (s *DeleteTaskSetInput) SetService(v string) *DeleteTaskSetInput {
	s.Service = &v
	return s
}
676168
func (s *EventType) SetService(v string) *EventType {
	s.Service = &v
	return s
}
700810
func (i *injector) SetService(t reflect.Type, v reflect.Value) {
	i.services[t] = v
}
880720
func UpdateService(conn client.Connection, svc *service.Service, setLockOnCreate, setLockOnUpdate bool) error {
	return UpdateServices(conn, []*service.Service{svc}, setLockOnCreate, setLockOnUpdate)
}
140182
func (s *CreateServiceOutput) SetService(v *Service) *CreateServiceOutput {
	s.Service = v
	return s
}
1338942
func (s *PolicyRole) SetRoleId(v string) *PolicyRole {
	s.RoleId = &v
	return s
}
396642
func (s *ResetServiceSpecificCredentialInput) SetServiceSpecificCredentialId(v string) *ResetServiceSpecificCredentialInput {
	s.ServiceSpecificCredentialId = &v
	return s
}
576351
func (c *Client) UpdateService(i *UpdateServiceInput) (*Service, error) {
	if i.ID == "" {
		return nil, ErrMissingID
	}

	path := fmt.Sprintf("/service/%s", i.ID)
	resp, err := c.PutForm(path, i, nil)
	if err != nil {
		return nil, err
	}

	var s *Service
	if err := decodeJSON(&s, resp.Body); err != nil {
		return nil, err
	}
	return s, nil
}
559272
func (g *Orchestrator) updateService(service *api.Service) {
	var constraints []constraint.Constraint

	if service.Spec.Task.Placement != nil && len(service.Spec.Task.Placement.Constraints) != 0 {
		constraints, _ = constraint.Parse(service.Spec.Task.Placement.Constraints)
	}

	g.globalServices[service.ID] = globalService{
		Service:     service,
		constraints: constraints,
	}
}
363256
func (s *CreateCaseInput) SetServiceCode(v string) *CreateCaseInput {
	s.ServiceCode = &v
	return s
}
891342
func (s *RoleDetail) SetRoleId(v string) *RoleDetail {
	s.RoleId = &v
	return s
}
228001
func (a *Agent) removeServiceLocked(serviceID string, persist bool) error {
	// Validate ServiceID
	if serviceID == "" {
		return fmt.Errorf("ServiceID missing")
	}

	// Shut down the config watch in the service manager if enabled.
	if a.config.EnableCentralServiceConfig {
		a.serviceManager.RemoveService(serviceID)
	}

	checks := a.State.Checks()
	var checkIDs []types.CheckID
	for id, check := range checks {
		if check.ServiceID != serviceID {
			continue
		}
		checkIDs = append(checkIDs, id)
	}

	// Remove the associated managed proxy if it exists
	// This has to be DONE before purging configuration as might might have issues
	// With ACLs otherwise
	for proxyID, p := range a.State.Proxies() {
		if p.Proxy.TargetServiceID == serviceID {
			if err := a.removeProxyLocked(proxyID, true); err != nil {
				return err
			}
		}
	}

	// Remove service immediately
	if err := a.State.RemoveServiceWithChecks(serviceID, checkIDs); err != nil {
		a.logger.Printf("[WARN] agent: Failed to deregister service %q: %s", serviceID, err)
		return nil
	}

	// Remove the service from the data dir
	if persist {
		if err := a.purgeService(serviceID); err != nil {
			return err
		}
	}

	// Deregister any associated health checks
	for checkID, check := range checks {
		if check.ServiceID != serviceID {
			continue
		}
		if err := a.removeCheckLocked(checkID, persist); err != nil {
			return err
		}
	}

	a.logger.Printf("[DEBUG] agent: removed service %q", serviceID)

	// If any Sidecar services exist for the removed service ID, remove them too.
	if sidecar := a.State.Service(a.sidecarServiceID(serviceID)); sidecar != nil {
		// Double check that it's not just an ID collision and we actually added
		// this from a sidecar.
		if sidecar.LocallyRegisteredAsSidecar {
			// Remove it!
			err := a.removeServiceLocked(a.sidecarServiceID(serviceID), persist)
			if err != nil {
				return err
			}
		}
	}

	return nil
}
1038293
func (s *UpdateServiceInput) SetService(v string) *UpdateServiceInput {
	s.Service = &v
	return s
}
1016042
func (self *BaseDispatcher) PutUdid(d *restObjUdid, id string, bundle PBundle) bool {
	allow, ok := d.put.(AllowerUdid)
	if !ok {
		return true
	}
	return allow.Allow(id, "PUT", bundle)
}