Replaces a Azure Cosmos resource and returns it.

        :param dict resource:
        :param str path:
        :param str type:
        :param str id:
        :param dict initial_headers:
        :param dict options:
            The request options for the request.

        :return:
            The new Azure Cosmos resource.
        :rtype:
            dict

def Replace(self, resource, path, type, id, initial_headers, options=None):
        """Replaces a Azure Cosmos resource and returns it.

        :param dict resource:
        :param str path:
        :param str type:
        :param str id:
        :param dict initial_headers:
        :param dict options:
            The request options for the request.

        :return:
            The new Azure Cosmos resource.
        :rtype:
            dict

        """
        if options is None:
            options = {}

        initial_headers = initial_headers or self.default_headers
        headers = base.GetHeaders(self,
                                  initial_headers,
                                  'put',
                                  path,
                                  id,
                                  type,
                                  options)
        # Replace will use WriteEndpoint since it uses PUT operation
        request = request_object._RequestObject(type, documents._OperationType.Replace)
        result, self.last_response_headers = self.__Put(path,
                                                        request,
                                                        resource,
                                                        headers)
        
        # update session for request mutates data on server side
        self._UpdateSessionIfRequired(headers, result, self.last_response_headers)
        return result