Update a resource by bson ObjectId

        :returns: json string representation
        :rtype: JSON
189693
def put(self, id):
        
        try:
            #Async update flow
            object_ = json_util.loads(self.request.body)

            toa = self.request.headers.get("Caesium-TOA", None)

            obj_check = yield self.client.find_one_by_id(id)
            if not obj_check:
                self.raise_error(404, "Resource not found: %s" % id)
                self.finish()
                return

            if toa:

                stack = AsyncSchedulableDocumentRevisionStack(self.client.collection_name, self.settings, master_id=id)
                revision_id = yield stack.push(object_, int(toa), meta=self._get_meta_data())

                if isinstance(revision_id, str):
                    self.set_header("Caesium-TOA", toa)

                    #We add the id of the original request, because we don't want to infer this
                    #On the client side, as the state of the client code could change easily
                    #We want this request to return with the originating ID as well.
                    object_["id"] = id
                    self.return_resource(object_)
                else:
                    self.raise_error(404, "Revision not scheduled for object: %s" % id)

            else:
                if object_.get("_id"):
                    del object_["_id"]

                response = yield self.client.update(id, object_)

                if response.get("updatedExisting"):
                    object_ = yield self.client.find_one_by_id(id)
                    self.return_resource(object_)
                else:
                    self.raise_error(404, "Resource not found: %s" % id)

        except ValidationError as vex:
            self.logger.error("%s validation error" % self.object_name, vex)
            self.raise_error(400, "Your %s cannot be updated because it is missing required fields, see docs" % self.object_name)
        except ValueError as ex:
            self.raise_error(400, "Invalid JSON Body, check formatting. %s" % ex[0])
        except InvalidId as ex:
            self.raise_error(message="Your ID is malformed: %s" % id)
        except Exception as ex:
            self.logger.error(ex)
            self.raise_error()
1355470
def update(self, id, **kwargs):
        

        response = self.ghost.execute_put('%s/%s/' % (self._type_name, id), json={
            self._type_name: [
                kwargs
            ]
        })

        return self._model_type(response.get(self._type_name)[0])
1242595
def update(self, body):
        
        json = None
        if body:
            json = self._json(self._post(self._api, data={'body': body}), 200)

        if json:
            self._update_(json)
            return True
        return False
847964
def update(self, collection_name, instance):
        
        assert isinstance(instance, SiteStatistics)
        if instance.db_id:
            query = {'_id': ObjectId(instance.db_id)}
        else:
            query = {DOMAIN_NAME: instance.domain_name,
                     TIMEPERIOD: instance.timeperiod}
        self.ds.update(collection_name, query, instance)
        return instance.db_id
392258
def update(self, **kwargs):
        

        old_json = self.__json__()

        for prop in kwargs:
            setattr(self, prop, kwargs[prop])

        # We send notif only if object has changed
        if old_json != self.__json__():
            self.controller.notification.emit("project.updated", self.__json__())
            self.dump()
1027216
def update(self, auth, resource, desc={}, defer=False):
        
        return self._call('update', auth, [resource, desc], defer)
672965
def update(self, doc: dict, doc_id: str):
        
        body = {
            'doc': doc
        }
        self.instance.update(self.index, self.doc_type, doc_id, body=body)
68209
async def update(self, fields=''):
    '''
    '''
    path = 'Users/{{UserId}}/Items/{}'.format(self.id)
    info = await self.connector.getJson(path,
                                        remote=False,
                                        Fields='Path,Overview,'+fields
    )
    self.object_dict.update(info)
    self.extras = {}
    return self
9900
def update(self):
        """"""
        self.json = c.get_document(self.uri.did).json()
        self.e_list = c.element_list(self.uri.as_dict()).json()
38284
def update_many(self, **kwargs):
        
        db_objects = self.get_dbcollection_with_es(**kwargs)
        return self.Model._update_many(
            db_objects, self._json_params, self.request)
1107307
def update_from_json(self, path=join('config', 'hdx_dataset_static.json')):
        # type: (str) -> None
        
        super(Dataset, self).update_from_json(path)
        self.separate_resources()
442222
def update(self, query, payload):
        

        if not isinstance(payload, dict):
            raise InvalidUsage("Update payload must be of type dict")

        record = self.get(query).one()

        self._url = self._url_builder.get_appended_custom("/{0}".format(record['sys_id']))
        return self._get_response('PUT', data=json.dumps(payload))
119404
def update(self, document_id, update_spec, namespace, timestamp):
        
        db, coll = self._db_and_collection(namespace)

        meta_collection_name = self._get_meta_collection(namespace)

        self.meta_database[meta_collection_name].replace_one(
            {self.id_field: document_id, "ns": namespace},
            {self.id_field: document_id, "_ts": timestamp, "ns": namespace},
            upsert=True,
        )

        no_obj_error = "No matching object found"
        update_spec.pop("$v", None)
        updated = self.mongo[db].command(
            SON(
                [
                    ("findAndModify", coll),
                    ("query", {"_id": document_id}),
                    ("update", update_spec),
                    ("new", True),
                ]
            ),
            allowable_errors=[no_obj_error],
        )["value"]
        return updated
596014
def _update(collection_name, upsert, multi, spec, doc, check_keys, opts):
    """"""
    flags = 0
    if upsert:
        flags += 1
    if multi:
        flags += 2
    encode = _dict_to_bson  # Make local. Uses extensions.
    encoded_update = encode(doc, check_keys, opts)
    return b"".join([
        _ZERO_32,
        _make_c_string(collection_name),
        _pack_int(flags),
        encode(spec, False, opts),
        encoded_update]), len(encoded_update)
517724
def build(self, update=True):
        
        query_str = "?page={}".format(self.page)
        if self.order:
            query_str += "".join(("&field=", self.order[0], "&sorder=",self.order[1]))

        ret = "".join((self.base, self.user, "/uploads/", query_str))

        if update:
            self.max_page = self._get_max_page(ret)
        return ret
620336
def update_release(id, **kwargs):
    
    data = update_release_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
1045291
def jsonify(*args, **kwargs):
    
    return Response(
        json.dumps(
            dict(
                *args,
                **kwargs),
            cls=MongoJSONEncoder),
        mimetype='application/json')