Ejemplo n.º 1
0
    def all(self, client: AdonaiClient = None):
        query = client.query()

        client.fields(query.permissions(), **get_fields_dict(self.DEFAULT_FIELDS))

        permissions = client.execute(query, interpret=False)["permissions"]

        print(get_table(permissions, self.DEFAULT_FIELDS))
Ejemplo n.º 2
0
    def all(self, client: AdonaiClient = None):
        query = client.query()

        client.fields(query.projects(), **get_fields_dict(self.DEFAULT_FIELDS))

        projects = client.execute(query, interpret=False)["projects"]

        if len(projects) == 0:
            print(colored("Empty!", "red"))
            return

        print(get_table(projects, self.DEFAULT_FIELDS))
Ejemplo n.º 3
0
    def get(self, id: int, client: AdonaiClient = None):
        query = client.query()

        client.fields(query.get_project(id=id),
                      **get_fields_dict(self.DEFAULT_FIELDS))

        project = client.execute(query, interpret=False)["getProject"]

        if project is None:
            print(colored("Not found!", "red"))
            return

        print(get_table(project, self.DEFAULT_FIELDS))
Ejemplo n.º 4
0
    def get(self, id: int, client: AdonaiClient = None):
        query = client.query()

        client.fields(query.get_domain(id=id),
                      **get_fields_dict(self.DEFAULT_FIELDS))

        domain = client.execute(query, interpret=False)["getDomain"]

        if domain is None:
            print(colored("Not found!", "red"))
            return

        print(get_table(domain, self.DEFAULT_FIELDS))
Ejemplo n.º 5
0
    def permissions(self, id: int, client: AdonaiClient = None):
        from .permission import PermissionMenu

        query = client.query()

        client.fields(
            query.get_project(id=id).permissions(),
            **get_fields_dict(PermissionMenu.DEFAULT_FIELDS))

        project = client.execute(query, interpret=False)["getProject"]

        if project is None:
            print(colored("Not found!", "red"))
            return

        permissions = project["permissions"]

        print(get_table(permissions, PermissionMenu.DEFAULT_FIELDS))
Ejemplo n.º 6
0
    def projects(self, id: int, client: AdonaiClient = None):
        from .project import ProjectMenu

        query = client.query()

        client.fields(
            query.get_domain(id=id).projects(),
            **get_fields_dict(ProjectMenu.DEFAULT_FIELDS))

        domain = client.execute(query, interpret=False)["getDomain"]

        if domain is None:
            print(colored("Not found!", "red"))
            return

        projects = domain["projects"]

        print(get_table(projects, ProjectMenu.DEFAULT_FIELDS))
Ejemplo n.º 7
0
    def login(self, root_endpoint: str, username: str, password: str):
        client = AdonaiClient(root_endpoint, username, password)

        config.username = username
        config.password = password
        config.root_endpoint = root_endpoint

        query = client.query()
        current_user_query = query.current_user()

        fields = ["first_name", "last_name", "login"]

        client.fields(current_user_query, **{field: True for field in fields})

        user = client.execute(query).current_user

        print(
            f"{colored('Hi!', 'green')} {user.first_name} {user.last_name} ({user.login}) you are loggined!",
            CONFIG_FILE_PATH,
        )
Ejemplo n.º 8
0
    def domain(self, id: int, client: AdonaiClient = None):
        from .domain import DomainMenu

        query = client.query()

        client.fields(
            query.get_project(id=id).domain(),
            **get_fields_dict(DomainMenu.DEFAULT_FIELDS))

        project = client.execute(query, interpret=False)["getProject"]

        if project is None:
            print(colored("Not found!", "red"))
            return

        domain = project["domain"]

        if domain is None:
            print(colored("Domain not found!", "red"))
            return

        print(get_table(domain, DomainMenu.DEFAULT_FIELDS))
Ejemplo n.º 9
0
    def project(self, id: int, client: AdonaiClient = None):
        from .project import ProjectMenu

        query = client.query()

        client.fields(
            query.get_permission(id=id).project(),
            **get_fields_dict(ProjectMenu.DEFAULT_FIELDS)
        )

        permission = client.execute(query, interpret=False)["getPermission"]

        if permission is None:
            print(colored("Not found!", "red"))
            return

        project = permission["project"]

        if project is None:
            print(colored("Project is None!", "red"))
            return

        print(get_table(project, ProjectMenu.DEFAULT_FIELDS))