def update(self, metadata_entry = None,    # required for a metadata update
                             payload = None,            # required for a file update      
                             filename = None,           # required for a file update
                             mimetype=None,             # required for a file update
                             packaging=None,            # required for a file update
                             md5sum=None,               # optional; will be calculated for you otherwise
                             
                             dr = None,     # Important! Without this, you will have to set the edit_iri AND the edit_media_iri parameters.
                             
                             edit_iri = None,
                             edit_media_iri = None,

                             metadata_relevant=False,
                             in_progress=False,
                             on_behalf_of=None,
                      ):
        target_iri = None
        request_type = "Update PUT"
        if metadata_entry != None:
            metadata_relevant = True    # set this definitively, although the server shouldn't actually care
            # Metadata or Metadata + file --> Edit-IRI
            conn_l.info("Using the Edit-IRI - Metadata or Metadata + file multipart-related uses a PUT request to the Edit-IRI")
            if payload != None and filename != None:
                request_type = "Update Multipart PUT"
            else:
                request_type = "Update Metadata PUT"
            if dr != None and dr.edit != None:
                conn_l.info("Using the deposit receipt to get the Edit-IRI: %s" % dr.edit)
                target_iri = dr.edit
            elif edit_iri != None:
                conn_l.info("Using the %s receipt as the Edit-IRI" % edit_iri)
                target_iri = edit_iri
            else:
                conn_l.error("Metadata or Metadata + file multipart-related update: Cannot find the Edit-IRI from the parameters supplied.")
        elif payload != None and filename != None:
            # File-only --> Edit-Media-IRI
            conn_l.info("Using the Edit-Media-IRI - File update uses a PUT request to the Edit-Media-IRI")
            request_type = "Update File PUT"
            if dr != None and dr.edit_media != None:
                conn_l.info("Using the deposit receipt to get the Edit-Media-IRI: %s" % dr.edit_media)
                target_iri = dr.edit_media
            elif edit_media_iri != None:
                conn_l.info("Using the %s receipt as the Edit-Media-IRI" % edit_media_iri)
                target_iri = edit_media_iri
            else:
                conn_l.error("File update: Cannot find the Edit-Media-IRI from the parameters supplied.")
            
        if target_iri == None:
            raise Exception("No suitable IRI was found for the request needed.")

        return self._make_request(target_iri = target_iri,
                                  metadata_entry=metadata_entry, 
                                  payload=payload,
                                  mimetype=mimetype,
                                  filename=filename,
                                  packaging=packaging,
                                  on_behalf_of=on_behalf_of,
                                  in_progress=in_progress,
                                  metadata_relevant=str(metadata_relevant),
                                  method="PUT",
                                  request_type=request_type,
                                  md5sum=md5sum)
Replacing the Metadata and/or Files of a Resource
dataset/ETHPy150Open swordapp/python-client-sword2/sword2/connection.py/Connection.update