Exemplo 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))
Exemplo 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))
Exemplo n.º 3
0
    def toggle(self, id: int, is_active: bool, client: AdonaiClient = None):
        mutation = client.mutation()

        args = get_arguments(is_active=is_active)
        client.fields(
            mutation.toggle_project(id=id, **args).project(),
            **get_fields_dict(self.DEFAULT_FIELDS))

        project = client.execute(mutation,
                                 interpret=False)["toggleProject"]["project"]

        print(get_table(project, self.DEFAULT_FIELDS))
Exemplo n.º 4
0
    def toggle(self, id: int, is_active: bool, client: AdonaiClient = None):
        mutation = client.mutation()

        args = get_arguments(is_active=is_active)
        client.fields(
            mutation.toggle_domain(id=id, **args).domain(),
            **get_fields_dict(self.DEFAULT_FIELDS))

        domain = client.execute(mutation,
                                interpret=False)["toggleDomain"]["domain"]

        print(get_table(domain, self.DEFAULT_FIELDS))
Exemplo n.º 5
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))
Exemplo n.º 6
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))
Exemplo n.º 7
0
    def update(
        self, id: int, description: str = Defaults.NO_INPUT, client: AdonaiClient = None
    ):
        mutation = client.mutation()

        args = get_arguments(description=description)
        client.fields(
            mutation.update_permission(id=id, **args).permission(),
            **get_fields_dict(self.DEFAULT_FIELDS)
        )

        permission = client.execute(mutation, interpret=False)["updatePermission"][
            "permission"
        ]

        print(get_table(permission, self.DEFAULT_FIELDS))
Exemplo n.º 8
0
    def create(
        self,
        name: str,
        description: str = Defaults.NO_INPUT,
        client: AdonaiClient = None,
    ):
        mutation = client.mutation()

        args = get_arguments(name=name, description=description)
        client.fields(
            mutation.create_domain(**args).domain(),
            **get_fields_dict(self.DEFAULT_FIELDS))

        domain = client.execute(mutation,
                                interpret=False)["createDomain"]["domain"]

        print(get_table(domain, self.DEFAULT_FIELDS))
Exemplo n.º 9
0
    def update(
        self,
        id: int,
        name: str = Defaults.NO_INPUT,
        description: str = Defaults.NO_INPUT,
        client: AdonaiClient = None,
    ):
        mutation = client.mutation()

        args = get_arguments(name=name, description=description)
        client.fields(
            mutation.update_project(id=id, **args).project(),
            **get_fields_dict(self.DEFAULT_FIELDS))

        project = client.execute(mutation,
                                 interpret=False)["updateProject"]["project"]

        print(get_table(project, self.DEFAULT_FIELDS))
Exemplo n.º 10
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))
Exemplo n.º 11
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))
Exemplo n.º 12
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,
        )
Exemplo n.º 13
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))
Exemplo n.º 14
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))
Exemplo n.º 15
0
    def create(
        self,
        name: str,
        type: str,
        project_id: int = Defaults.NO_INPUT,
        description: str = Defaults.NO_INPUT,
        client: AdonaiClient = None,
    ):
        mutation = client.mutation()

        args = get_arguments(
            name=name, description=description, type=type, project_id=project_id
        )
        client.fields(
            mutation.create_permission(**args).permission(),
            **get_fields_dict(self.DEFAULT_FIELDS)
        )

        permission = client.execute(mutation, interpret=False)["createPermission"][
            "permission"
        ]

        print(get_table(permission, self.DEFAULT_FIELDS))