예제 #1
0
    def introspect_build_jobs(self, tenant_id: Uuid, config: Union[Callable[[SkillBuildJobReq], None], None] = None) -> \
            Observable[SkillBuildJobRes]:
        if config is not None:
            introspect_req: Callable[[IntrospectionReq], None] = lambda irq: irq.build_jobs(tenant_id, config)
            query_req: Callable[[QueryReq], None] = lambda qr: qr.introspect(introspect_req)
            query_res: Callable[[QueryRes], List[SkillBuildJobRes]] = lambda qs: qs.introspect.build_jobs
            obs = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
            return flat_mapQ(obs, query_res)
        else:
            def failure_cfg(f: FailureReq):
                f.failure_type()
                f.exit_code()
                f.affected_container()
                f.reason()
            def status_cfg(b: SkillStatusReq):
                b.health()
                b.pending()
                b.running()
                b.failures(failure_cfg)

            def job_cfg(b: SkillBuildJobReq):
                b.reference()
                b.name()
                b.tag()
                b.tenant_id()
                b.created()
                b.status(status_cfg)
            introspect_req: Callable[[IntrospectionReq], None] = lambda irq: irq.build_jobs(tenant_id, job_cfg)
            query_req: Callable[[QueryReq], None] = lambda qr: qr.introspect(introspect_req)
            query_res: Callable[[QueryRes], List[SkillBuildJobRes]] = lambda qs: qs.introspect.build_jobs
            obs = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
            return flat_mapQ(obs, query_res)
예제 #2
0
    def retrieve_identities(self, config: Callable[[IdentityReq], None], limit: int, offset: int) -> Observable[
        IdentityRes]:
        identities_req: Callable[[IdentityReq], None] = lambda x: x.identities(limit, offset, None, None, config)
        retrieval_req: Callable[[RetrievalReq], None] = lambda x: x.knowledge(identities_req)
        query_req: Callable[[QueryReq], None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes], IdentityRes] = lambda x: x.retrieve.knowledge.identities

        observable = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
        return flat_mapQ(observable, query_res)
예제 #3
0
    def retrieve_codes(self, identityId: Uuid, config: Callable[[CodeReq], None], limit: int, offset: int) -> \
            Observable[CodeRes]:
        code_req: Callable[[CodeReq], None] = lambda x: x.codes(identityId, limit, offset, None, None, config)
        retrieval_req: Callable[[RetrievalReq], None] = lambda x: x.knowledge(code_req)
        query_req: Callable[[QueryReq], None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes], CodeRes] = lambda x: x.retrieve.knowledge.codes

        observable = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
        return flat_mapQ(observable, query_res)
예제 #4
0
    def retrieve_edges(self, source: Uuid, config: Callable[[EdgeReq], None], limit: int, offset: int) -> Observable[
        EdgeRes]:
        knowledge_req: Callable[[KnowledgeReq], None] = lambda x: x.edges(source, limit, offset, None, None, config)
        retrieval_req: Callable[[RetrievalReq], None] = lambda x: x.knowledge(knowledge_req)
        query_req: Callable[[QueryReq], None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes], EdgeRes] = lambda x: x.retrieve.knowledge.edges

        observable = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
        return flat_mapQ(observable, query_res)
    def retrieve_codes(
            self, config: Callable[[CodeReq], None]) -> Observable[CodeRes]:
        code_req: Callable[[CodeReq], None] = lambda x: x.codes(config)
        retrieval_req: Callable[[RetrievalReq],
                                None] = lambda x: x.knowledge(code_req)
        query_req: Callable[[QueryReq],
                            None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes],
                            CodeRes] = lambda x: x.retrieve.knowledge.codes

        observable = rx.of(self.client.query(GaiaRequest.query(query_req)))
        return flat_mapQ(observable, query_res)
예제 #6
0
    def retrieve_behaviour_executions(self, identity_id: Uuid, config: Callable[[BehaviourExecutionReq], None],
                                      limit: int = None, offset: int = None, startDate: str = None, endDate: str = None) \
            -> Observable[BehaviourExecutionRes]:
        executions_req: Callable[[BehaviourExecutionReq], None] = lambda x: x.behaviour_executions(identity_id, limit,
                                                                                                   offset, startDate,
                                                                                                   endDate, config)
        retrieval_req: Callable[[RetrievalReq], None] = lambda x: x.experience(executions_req)

        query_req: Callable[[QueryReq], None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes], BehaviourExecutionRes] = lambda x: x.retrieve.experience.behaviour_executions

        observable = rx.from_callable(lambda: self.client.query(GaiaRequest.query(query_req)), self._scheduler)
        return flat_mapQ(observable, query_res)
    def retrieve_prompts(
            self, config: Callable[[PromptReq],
                                   None]) -> Observable[PromptRes]:
        prompts_req: Callable[[PromptReq], None] = lambda x: x.prompts(config)
        retrieval_req: Callable[[RetrievalReq],
                                None] = lambda x: x.knowledge(prompts_req)
        query_req: Callable[[QueryReq],
                            None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[[QueryRes],
                            PromptRes] = lambda x: x.retrieve.knowledge.prompts

        observable = rx.of(self.client.query(GaiaRequest.query(query_req)))
        return flat_mapQ(observable, query_res)
    def retrieve_behaviour(
            self, config: Callable[[BehaviourReq],
                                   None]) -> Observable[BehaviourRes]:
        behaviour_req: Callable[[BehaviourReq],
                                None] = lambda x: x.behaviours(config)
        retrieval_req: Callable[[RetrievalReq],
                                None] = lambda x: x.knowledge(behaviour_req)
        query_req: Callable[[QueryReq],
                            None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[
            [QueryRes],
            BehaviourRes] = lambda x: x.retrieve.knowledge.behaviours

        observable = rx.of(self.client.query(GaiaRequest.query(query_req)))
        return flat_mapQ(observable, query_res)
    def retrieve_fulfilments(
            self, config: Callable[[FulfilmentReq],
                                   None]) -> Observable[FulfilmentRes]:
        fulfilment_req: Callable[[FulfilmentReq],
                                 None] = lambda x: x.fulfilments(config)
        retrieval_req: Callable[[RetrievalReq],
                                None] = lambda x: x.knowledge(fulfilment_req)
        query_req: Callable[[QueryReq],
                            None] = lambda x: x.retrieve(retrieval_req)
        query_res: Callable[
            [QueryRes],
            FulfilmentRes] = lambda x: x.retrieve.knowledge.fulfilments

        observable = rx.of(self.client.query(GaiaRequest.query(query_req)))
        return flat_mapQ(observable, query_res)