[API] Migrated the utilities from the Elasticsearch repository

Related: elasticsearch/elasticsearch#8606