├── __init__.py
├── epsagonctl
├── __init__.py
├── consts.py
├── __main__.py
└── utils.py
├── requirements.txt
├── scripts
└── build.sh
├── runner.py
├── LICENSE
├── README.md
├── setup.py
└── .gitignore
/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/epsagonctl/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | requests
--------------------------------------------------------------------------------
/scripts/build.sh:
--------------------------------------------------------------------------------
1 | cp ./main.py /usr/local/bin/epsagon
--------------------------------------------------------------------------------
/runner.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 |
4 | from epsagon.__main__ import run
5 |
6 | if __name__ == '__main__':
7 | run()
8 |
--------------------------------------------------------------------------------
/epsagonctl/consts.py:
--------------------------------------------------------------------------------
1 |
2 | VARS_COMMAND = 'command'
3 | VARS_SUBCOMMAND = 'subcommand'
4 | VARS_DEFAULT = 'default'
5 |
6 | API_BASE_URL = 'https://api.epsagon.com'
7 |
--------------------------------------------------------------------------------
/epsagonctl/__main__.py:
--------------------------------------------------------------------------------
1 | #! /usr/bin/python3
2 |
3 | from epsagonctl.consts import (
4 | VARS_COMMAND, VARS_SUBCOMMAND, VARS_DEFAULT,
5 | )
6 | from epsagonctl.utils import (
7 | _parse_args, _list_users, _list_groups, _invite_user
8 | )
9 |
10 | options = {
11 | 'iam': {
12 | 'invite-user': _invite_user,
13 | 'list-users': _list_users,
14 | 'list-groups': _list_groups,
15 | },
16 | VARS_DEFAULT: {
17 | VARS_DEFAULT: lambda: None
18 | },
19 | }
20 |
21 |
22 | def run():
23 | args = _parse_args()
24 | res = options.get(
25 | args.get(VARS_COMMAND, options[VARS_DEFAULT])
26 | ).get(
27 | args.get(VARS_SUBCOMMAND, options[VARS_DEFAULT][VARS_DEFAULT])
28 | )()
29 |
30 | print(res.json())
31 |
32 |
33 | if __name__ == '__main__':
34 | run()
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Epsagon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | # epsagonctl
10 |
11 | Epsagon's Command Line Interface.
12 |
13 | ## Table of Contents
14 |
15 | - [Installation](#installation)
16 | - [Usage](#usage)
17 |
18 |
19 | ## Installation
20 |
21 | Install the CLI with
22 |
23 | $ pip install epsagonctl
24 |
25 | And the package will be added to your PATH under `epsagon`.
26 |
27 | ## Usage
28 |
29 | The CLI expects a `command` and `subcommand` for every usage.
30 |
31 | Commands and their corresponding SubCommands include:
32 |
33 | ### IAM
34 |
35 |
36 | IAM is Epsagon's central location for all things account-related.
37 |
38 |
39 | invite-user
40 |
41 | Invite a user to an account.
42 |
43 | $ epsagon iam invite-user
44 |
45 | list-users
46 |
47 | List all users in an account.
48 |
49 | $ epsagon iam list-users
50 |
51 | list-groups
52 |
53 | List all groups in an account,
54 |
55 | $ epsagon iam list-groups
56 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env python
3 | import re
4 | import os
5 | from setuptools import setup, find_packages
6 |
7 | with open('./requirements.txt', 'r') as reqs_file:
8 | reqs = reqs_file.readlines()
9 |
10 | # Get version
11 | # with open(os.path.join('epsagon', 'constants.py'), 'rt') as consts_file:
12 | # version = re.search(r'__version__ = \'(.*?)\'', consts_file.read()).group(1)
13 |
14 | setup(
15 | name='epsagonctl',
16 | version='0.0.1',
17 | description='Epsagon CTL',
18 | long_description=open('README.md').read(),
19 | long_description_content_type='text/markdown',
20 | author='Epsagon',
21 | author_email='support@epsagon.com',
22 | url='https://github.com/epsagon/epsagonctl',
23 | # packages=find_packages(exclude=('tests', 'examples')),
24 | packages=['epsagonctl'],
25 | package_data={'epsagon': ['*.pem']},
26 | install_requires=reqs,
27 | license='MIT',
28 | # setup_requires=['pytest-runner'],
29 | # tests_require=['pytest'],
30 | entry_points={
31 | 'console_scripts': ['epsagon = epsagonctl.__main__:run']
32 | },
33 | keywords=[
34 | 'serverless',
35 | 'microservices',
36 | 'epsagon',
37 | 'tracing',
38 | 'distributed-tracing',
39 | 'lambda',
40 | 'aws-lambda',
41 | 'debugging',
42 | 'monitoring'
43 | ],
44 | classifiers=(
45 | 'Intended Audience :: Developers',
46 | 'Operating System :: OS Independent',
47 | 'Programming Language :: Python',
48 | 'Programming Language :: Python :: 2',
49 | 'Programming Language :: Python :: 2.7',
50 | 'Programming Language :: Python :: 3',
51 | 'Programming Language :: Python :: 3.6',
52 | 'Programming Language :: Python :: 3.7',
53 | 'Programming Language :: Python :: 3.8',
54 | 'Topic :: Software Development :: Libraries',
55 | 'Topic :: Software Development :: Libraries :: Python Modules',
56 | )
57 | )
58 |
--------------------------------------------------------------------------------
/epsagonctl/utils.py:
--------------------------------------------------------------------------------
1 |
2 | from epsagonctl.consts import (
3 | VARS_COMMAND, VARS_SUBCOMMAND, API_BASE_URL
4 | )
5 |
6 | import argparse
7 | import requests
8 |
9 |
10 | def _parse_args():
11 | parser = argparse.ArgumentParser(
12 | description='Epsagon CLI Parser'
13 | )
14 | commands = parser.add_subparsers(title='Epsagon Command', dest=VARS_COMMAND)
15 |
16 | users_parser = commands.add_parser('iam', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
17 | users_parser.add_argument(VARS_SUBCOMMAND, help='IAM Operation to Perform', type=str)
18 |
19 | return vars(parser.parse_args())
20 |
21 |
22 | def _req(path, method, headers=None, body=None):
23 | return {
24 | 'get': lambda _url, _headers=None: requests.get(_url, headers=_headers or {}),
25 | 'post': lambda _url, _headers=None: requests.post(_url, headers=_headers or {}),
26 | }.get(method)(f'{API_BASE_URL}/{path}', {'Authorization': 'Bearer 2db3136a-bcc2-458c-b717-a1f78cd74942'})
27 |
28 | def _invite_user():
29 | pass
30 |
31 | def _list_users():
32 | return _req('auth/users_in_account', 'post')
33 |
34 | def _list_groups():
35 | return _req('groups', 'get')
36 |
37 | def _invite_user():
38 | return _req('auth/invite_user', 'post')
39 |
40 |
41 |
42 |
43 |
44 | def init_cli():
45 | epsagon_path = os.path.expanduser('~/.epsagon')
46 | if not os.path.exists(epsagon_path):
47 | with open(epsagon_path, 'w+') as epsagon_file:
48 | epsagon_file.write()
49 | # cmd('mkdir', PIPS_PATH)
50 | # if not os.path.exists(CREDENTIALS_PATH):
51 | name = input('Org Name: ')
52 | pips_id = input('PIPS id: ')
53 | with open(CREDENTIALS_PATH, 'w+') as creds_f:
54 | toml.dump({'credentials': {'name': name, 'pips_id': pips_id}}, creds_f)
55 | # cmd('echo', f'"{creds_toml}"', '>', CREDENTIALS_PATH, log=True)
56 |
57 |
58 | def verify_action():
59 | res = input('Continue? [y/N]\n -> ')
60 | if 'y' in res:
61 | return True
62 | print('Bye.')
63 | return False
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
131 | # IDE
132 | *.idea
133 | .idea/
--------------------------------------------------------------------------------