-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from PhonePe/feature/list_orgs
Added list subcommand
- Loading branch information
Showing
6 changed files
with
101 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from mantis.db.crud_assets import read_assets | ||
|
||
async def get_orgs(): | ||
pipeline = [] | ||
|
||
pipeline.extend([ | ||
{"$group": { | ||
"_id" : None, | ||
"orgs":{ | ||
"$addToSet": "$org" | ||
} | ||
} | ||
} | ||
]) | ||
orgs = await read_assets(pipeline) | ||
|
||
if orgs: | ||
return orgs[0]["orgs"] | ||
|
||
else: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import logging | ||
from mantis.models.args_model import ArgsModel | ||
from mantis.utils.list_subcommand_utils import get_orgs | ||
|
||
class ListWorkflow: | ||
|
||
@staticmethod | ||
async def executor(args: ArgsModel): | ||
|
||
if args.list_orgs: | ||
logging.info("Getting orgs from database") | ||
orgs = await get_orgs() | ||
print() | ||
print(f'''Total Number of orgs onboarded: {len(orgs)}''') | ||
print() | ||
for org in orgs: | ||
print(org) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
from mantis.models.args_model import ArgsModel | ||
from mantis.modules.workflow import Workflow | ||
from mantis.workflows.list_workflow import ListWorkflow | ||
import asyncio | ||
|
||
class MantisWorkflow: | ||
@staticmethod | ||
def select_workflow(args: ArgsModel) -> None: | ||
|
||
asyncio.run(Workflow.workflow_executor(args)) | ||
if args.list_: | ||
asyncio.run(ListWorkflow.executor(args)) | ||
else: | ||
asyncio.run(Workflow.workflow_executor(args)) | ||
|