/
list.py
39 lines (29 loc) · 918 Bytes
/
list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
import click
from .deployment import deployment
from ..AsciiTable import AsciiTable
from ... import Client
@deployment.group(name="list")
def lst():
"""List all instances of an entity related to deployment.
For example, to list all endpoints, run
`verta deployment list endpoint`
"""
pass
@lst.command(name="endpoint")
@click.option("--workspace", "-w", help="Workspace to use.")
def lst_endpoint(workspace):
"""List all endpoints available."""
client = Client()
endpoints = client.endpoints
if workspace:
endpoints = endpoints.with_workspace(workspace)
table_data = [["PATH", "ID", "DATE CREATED"]] + list(
sorted(
map(lambda endpoint: endpoint._get_info_list_by_id(), endpoints),
key=lambda data: data[0],
)
)
table = AsciiTable(table_data)
click.echo()
click.echo(table.table)