├── __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 | 5 | API_BASE_URL = 'https://api.epsagon.com' 6 | -------------------------------------------------------------------------------- /epsagonctl/__main__.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | 3 | from epsagoncli.consts import ( 4 | VARS_COMMAND, VARS_SUBCOMMAND 5 | ) 6 | from epsagoncli.utils import ( 7 | _parse_args, _list_users, _list_groups, _invite_user 8 | ) 9 | 10 | 11 | def run(): 12 | cmd = _parse_args() 13 | res = { 14 | 'iam': { 15 | 'invite-user': _invite_user, 16 | 'list-users': _list_users, 17 | 'list-groups': _list_groups, 18 | }, 19 | }[cmd[VARS_COMMAND]][cmd[VARS_SUBCOMMAND]]() 20 | 21 | print(res.status_code, res.text) 22 | 23 | 24 | if __name__ == '__main__': 25 | run() -------------------------------------------------------------------------------- /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 | # epsagon-cli 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 epsagoncli 24 | 25 | And the package will be added to your PATH under `epsagoncli`. 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 | $ epsagoncli iam invite-user 44 | 45 | list-users 46 | 47 | List all users in an account. 48 | 49 | $ epsagoncli iam list-users 50 | 51 | list-groups 52 | 53 | List all groups in an account, 54 | 55 | $ epsagoncli iam list-groups 56 | -------------------------------------------------------------------------------- /epsagonctl/utils.py: -------------------------------------------------------------------------------- 1 | 2 | from epsagoncli.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 | print(method, f'{API_BASE_URL}/{path}') 24 | return { 25 | 'get': lambda _url, _headers=None: requests.get(_url, headers=_headers or {}), 26 | 'post': lambda _url, _headers=None: requests.post(_url, headers=_headers or {}), 27 | }.get(method)(f'{API_BASE_URL}/{path}', {'Authorization': 'Bearer 87a6f6b4-b796-455d-9d5e-bba5119c7d87'}) 28 | 29 | def _invite_user(): 30 | pass 31 | 32 | def _list_users(): 33 | return _req('auth/users_in_account', 'post') 34 | 35 | def _list_groups(): 36 | return _req('groups', 'get') 37 | 38 | def _invite_user(): 39 | return _req('auth/invite_user', 'post') 40 | -------------------------------------------------------------------------------- /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='epsagoncli', 16 | version='0.0.1', 17 | description='Epsagon CLI', 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/epsagon-cli', 23 | # packages=find_packages(exclude=('tests', 'examples')), 24 | packages=['epsagoncli'], 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': ['epsagoncli = epsagoncli.__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 | -------------------------------------------------------------------------------- /.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/ --------------------------------------------------------------------------------