@Override
    public void publishApi(final Api api, final IAsyncResultHandler<Void> handler) {
        try {
            String id = getApiId(api);
            IndexRequest indexRequest = new IndexRequest(getIndexPrefixWithJoiner() + EsConstants.INDEX_APIS)
                    .id(id)
                    .source(JSON_MAPPER.writeValueAsBytes(api), XContentType.JSON)
                    .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);

            IndexResponse response = getClient().index(indexRequest, RequestOptions.DEFAULT);

            if (response.status().equals(RestStatus.CREATED) || response.status().equals(RestStatus.OK)) {
                handler.handle(AsyncResultImpl.create((Void) null));
            } else {
                throw new IOException(response.getResult().toString());
            }
        } catch (Exception e) {
            handler.handle(AsyncResultImpl.create(
                    new PublishingException(Messages.i18n.format("EsRegistry.ErrorPublishingApi"), e),  //$NON-NLS-1$
                    Void.class));
        }
    }
@see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/EsRegistry.java