'Update a service.
Args:
service (string): A service identifier (either its name or service
ID).
version (int): The version number of the service object being
updated. This is required to avoid conflicting writes.
task_template (TaskTemplate): Specification of the updated task to
start as part of the service.
name (string): New name for the service. Optional.
labels (dict): A map of labels to associate with the service.
Optional.
mode (ServiceMode): Scheduling mode for the service (replicated
or global). Defaults to replicated.
update_config (UpdateConfig): Specification for the update strategy
of the service. Default: ``None``.
networks (:py:class:`list`): List of network names or IDs to attach
the service to. Default: ``None``.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: ``None``.
Returns:
``True`` if successful.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.'

@utils.minimum_version('1.24')
@utils.check_resource('service')
def update_service(self, service, version, task_template=None, name=None, labels=None, mode=None, update_config=None, networks=None, endpoint_config=None, endpoint_spec=None):

    if (endpoint_config is not None):
        warnings.warn('endpoint_config    has    been    renamed    to    endpoint_spec.', DeprecationWarning)
        endpoint_spec = endpoint_config
    _check_api_features(self._version, task_template, update_config)
    url = self._url('/services/{0}/update', service)
    data = {}
    headers = {}
    if (name is not None):
        data['Name'] = name
    if (labels is not None):
        data['Labels'] = labels
    if (mode is not None):
        if (not isinstance(mode, dict)):
            mode = ServiceMode(mode)
        data['Mode'] = mode
    if (task_template is not None):
        image = task_template.get('ContainerSpec', {}).get('Image', None)
        if (image is not None):
            (registry, repo_name) = auth.resolve_repository_name(image)
            auth_header = auth.get_config_header(self, registry)
            if auth_header:
                headers['X-Registry-Auth'] = auth_header
        data['TaskTemplate'] = task_template
    if (update_config is not None):
        data['UpdateConfig'] = update_config
    if (networks is not None):
        data['Networks'] = utils.convert_service_networks(networks)
    if (endpoint_spec is not None):
        data['EndpointSpec'] = endpoint_spec
    resp = self._post_json(url, data=data, params={'version': version}, headers=headers)
    self._raise_for_status(resp)
    return True
