diff --git a/pinecone/manage.py b/pinecone/manage.py index b71b7ef96..f5bf5f8c5 100644 --- a/pinecone/manage.py +++ b/pinecone/manage.py @@ -21,17 +21,13 @@ ] -class IndexDescription(NamedTuple): - name: str - metric: str - replicas: int - dimension: int - shards: int - pods: int - pod_type: str - status: None - metadata_config: None - source_collection: None +class IndexDescription(object): + def __init__(self, response: dict): + for k, v in response.items(): + self.__dict__[k] = v + + def __str__(self): + return str(self.__dict__) class CollectionDescription(object): @@ -194,14 +190,18 @@ def describe_index(name: str): """ api_instance = _get_api_instance() response = api_instance.describe_index(name) - db = response['database'] - ready = response['status']['ready'] - state = response['status']['state'] - return IndexDescription(name=db['name'], metric=db['metric'], - replicas=db['replicas'], dimension=db['dimension'], shards=db['shards'], - pods=db.get('pods', db['shards'] * db['replicas']), pod_type=db.get('pod_type', 'p1'), - status={'ready': ready, 'state': state}, metadata_config=db.get('metadata_config'), - source_collection=db.get('source_collection', '')) + db_status = response.get('status', {}) + response = response['database'].to_dict() + state = db_status.get('state', None) + ready = db_status.get('ready', None) + status = {'state': state, 'ready': ready} + response['status'] = status + shards = response.get('shards', 1) + replicas = response.get('replicas', 1) + pods = shards * replicas + response['pods'] = pods + response_object = IndexDescription(response) + return response_object def scale_index(name: str, replicas: int):