# Curator API returns None

**URL:** https://discuss.elastic.co/t/curator-api-returns-none/161039
**Category:** Elasticsearch
**Created:** [December 16, 2018, 5:14pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039 "2018-12-16T17:14:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tomerl](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@tomerl](https://discuss.elastic.co/u/tomerl)
#### Post date: [December 16, 2018, 5:14pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/1 "2018-12-16T17:14:57Z")

</div>

Hi there,

I'm attempting to write a python code that will perform the actions that I'm currently doing in the curator-cli. The goal is to have Lambda that will perform several actions that are related but not restricted to ELK and Curator.

Some actions I was able to perform while others are not clear as to why they aren't working.  
For example, snapshots are successful, but any indices actions fails.

Using this code:

```
client = elasticsearch.Elasticsearch()
ilo = curator.IndexList(client)
print(ilo)

```

This will print all the indices, but if I'll do:

```
ilo = curator.IndexList(client).filter_by_regex(kind='prefix', value='kubernetes-')
curator.Replicas(ilo,count='2').do_action()

```

It will fail with:  
**TypeError: Not an IndexList object. Type: \<type 'NoneType'\>.**

Any idea?

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [December 16, 2018, 6:11pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/2 "2018-12-16T18:11:12Z")

</div>

You cannot do it this way. The object has to first be instantiated.

```auto
ilo = curator.IndexList(client)
ilo.filter_by_regex(kind='prefix', value='Kubernetes-')
curator.Replicas(ilo, count=2).do_action()

```

The above should work. 3 steps instead of 2. If it doesn't, then do the same with the `Replicas` object. Instantiate first, then `do_action()`.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [December 16, 2018, 6:17pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/3 "2018-12-16T18:17:27Z")

</div>

I should probably point out that you got that result because you're assigning the  
_output_ of an object `method` (`filter_by_regex`) to `ilo`, rather than making `ilo` an object by instantiating it on its own. Because of this, you cannot pass `ilo` to `curator.Replicas`, because it's not actually an `IndexList` object.

---

<div class="post-metadata">

### Author: ![tomerl](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@tomerl](https://discuss.elastic.co/u/tomerl)
#### Post date: [December 16, 2018, 6:35pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/4 "2018-12-16T18:35:04Z")

</div>

Thanks, it worked out.

So, if using the filter, how can I retrieve and print the index list that was filtered out?

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [December 16, 2018, 6:59pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/5 "2018-12-16T18:59:32Z")

</div>

Once you have an `IndexList` object, the working list is always stored in the [`indices` instance variable](https://curator.readthedocs.io/en/v5.6.0/objectclasses.html#curator.indexlist.IndexList.indices) (it's in the documentation, but the methods and variables are, unfortunately, listed alphabetically, so it's down the page pretty far).

```auto
ilo = curator.IndexList(client)
print(ilo.indices) # Prints all discovered indices (the current working list)
ilo.filter_by_regex(kind='prefix', value='kubernetes-') 
print(ilo.indices) # Prints the current working list (post-filter)

```

---

<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: [January 13, 2019, 7:13pm UTC](https://discuss.elastic.co/t/curator-api-returns-none/161039/6 "2019-01-13T19:13:36Z")

</div>

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