Apply all the changes on the current model.

        :param wait:    Whether to wait until the operation is completed
        :param timeout: The maximum amount of time required for this
                        operation to be completed.

        If optional :param wait: is True and timeout is None (the default),
        block if necessary until the resource is available. If timeout is a
        positive number, it blocks at most timeout seconds and raises the
        `TimeOut` exception if no item was available within that time.

        Otherwise (block is false), return a resource if one is immediately
        available, else raise the `NotFound` exception (timeout is ignored
        in that case).

def commit(self, if_match=None, wait=True, timeout=None):
        """Apply all the changes on the current model.

        :param wait:    Whether to wait until the operation is completed
        :param timeout: The maximum amount of time required for this
                        operation to be completed.

        If optional :param wait: is True and timeout is None (the default),
        block if necessary until the resource is available. If timeout is a
        positive number, it blocks at most timeout seconds and raises the
        `TimeOut` exception if no item was available within that time.

        Otherwise (block is false), return a resource if one is immediately
        available, else raise the `NotFound` exception (timeout is ignored
        in that case).
        """
        if not self._changes:
            LOG.debug("No changes available for %s: %s",
                      self.__class__.__name__, self.resource_id)
            return

        LOG.debug("Apply all the changes on the current %s: %s",
                  self.__class__.__name__, self.resource_id)
        client = self._get_client()
        endpoint = self._endpoint.format(
            resource_id=self.resource_id or "",
            parent_id=self.parent_id or "",
            grandparent_id=self.grandparent_id or "")
        request_body = self.dump(include_read_only=False)
        response = client.update_resource(endpoint, data=request_body,
                                          if_match=if_match)

        elapsed_time = 0
        while wait:
            self.refresh()  # Update the representation of the current model
            if self.is_ready():
                break
            elapsed_time += CONFIG.HNV.retry_interval
            if timeout and elapsed_time > timeout:
                raise exception.TimeOut("The request timed out.")
            time.sleep(CONFIG.HNV.retry_interval)
        else:
            self._reset_model(response)

        # NOTE(alexcoman): In order to keep backwards compatibility the
        # `method: commit` will return a reference to itself.
        # An example for that can be the following use case:
        # label = client.Model().commit()
        return self