# Maven Java API for snapshot

**URL:** <https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317>\
**Category:** Elasticsearch\
**Created:** [March 14, 2019, 10:54am UTC](https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317 "2019-03-14T10:54:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hemant\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hemant_kumar/32/41960_2.png) [@Hemant\_Kumar](https://discuss.elastic.co/u/Hemant_Kumar)\
**Post date:** [March 14, 2019, 10:54am UTC](https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317/1 "2019-03-14T10:54:14Z")

</div>

Hi,  
I am writing java API code to take the snapshot of es. I am unable to find the maven repo for that.  
public CreateSnapshotResponse createSnapshot(Client client, String repositoryName,  
String snapshotName, String indexName){

```
    CreateSnapshotResponse createSnapshotResponse = null;
    try {

        if(isSnapshotExist(client, repositoryName, snapshotName))
            logger.info(snapshotName + " snapshot already exists");

        else {

            createSnapshotResponse = client.admin().cluster()
                                     .prepareCreateSnapshot(repositoryName, snapshotName)
                                     .setWaitForCompletion(true)
                                     .setIndices(indexName).get();

            logger.info("Snapshot was created.");
        }

    } catch (Exception ex){
        logger.error("Exception in createSnapshot method: " + ex.toString());

    } finally {
        return createSnapshotResponse;
    }
}
```

---

<div class="post-metadata">

**Author:** ![Hemant\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hemant_kumar/32/41960_2.png) [@Hemant\_Kumar](https://discuss.elastic.co/u/Hemant_Kumar)\
**Post date:** [March 14, 2019, 12:32pm UTC](https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317/2 "2019-03-14T12:32:42Z")

</div>

Help will be appreciated.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2019, 1:32pm UTC](https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317/3 "2019-03-14T13:32:21Z")

</div>

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 11, 2019, 1:32pm UTC](https://discuss.elastic.co/t/maven-java-api-for-snapshot/172317/4 "2019-04-11T13:32:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
