UPSERT, INSERT OR UPDATE, etc.

I need a way to UPDATE various columns of a row identified by a unique index, or INSERT a new row if it doesn't yet exist. That is, given

CREATE TABLE objects (
  namespace        string NOT NULL,
  identifier       string NOT NULL,
  created_at       time,
  last_accessed_at time,
  deleted_at       time,
);

CREATE UNIQUE INDEX idx_objects_key ON objects (namespace, identifier);

I'd like to be able to express things like

BEGIN TRANSACTION;
  INSERT INTO objects IF NOT EXISTS
   (namespace, identifier, created_at) VALUES ($1, $2, $3);
  UPDATE objects SET last_accessed_at = $3 WHERE namespace == $1 && identifier == $2;
COMMIT;

and

BEGIN TRANSACTION;
  INSERT OR UPDATE objects
   (namespace, identifier, last_accessed_at) VALUES ($1, $2, $3);
COMMIT;