def update_entity()

in src/libs/deploy_utils/WorkspaceUtils.py [0:0]


    def update_entity(self, entityId, componentUpdates):
        state_transition_error = "Cannot update Entity when it is in CREATING state"

        def entity_in_state_transition(error_message):
            if "Cannot update Entity" in error_message:
                if "when it is in CREATING state" in error_message:
                    return True
                elif "when it is in UPDATING state" in error_message:
                    return True
            return False
        print(f"   updating entity: {entityId}")
        while entity_in_state_transition(state_transition_error):
            try:
                self.iottwinmaker_client.update_entity(
                    componentUpdates=componentUpdates,
                    entityId=entityId,
                    workspaceId=self.workspace_id
                )
            except Exception as e:
                state_transition_error = str(e)
                if "cannot be created as it already exists" in state_transition_error:
                    pass
                elif entity_in_state_transition(state_transition_error):
                    print(f"      waiting for entity {entityId} to finish transition state before updating again: {state_transition_error}")
                    time.sleep(10)
                else:
                    raise e
        print(f"   updated entity: {entityId}")