예제 #1
0
    def search_for_rule_substring(self, substring: str, skip_control_cubes: bool = False, case_insensitive=True,
                                  space_insensitive=True, **kwargs) -> List[Cube]:
        """ get all cubes from TM1 Server as TM1py.Cube instances where rules for given cube contain specified substring

        :param substring: string to search for in rules
        :param skip_control_cubes: bool, True will exclude control cubes from result
        :param case_insensitive: case agnostic search
        :param space_insensitive: space agnostic search
        :return: List of TM1py.Cube instances
        """
        substring = substring.lower().replace(' ', '')

        url_filter = "Rules ne null and contains("
        if case_insensitive and space_insensitive:
            url_filter += format_url("tolower(replace(Rules, ' ', '')),'{}')", substring)
        elif case_insensitive:
            url_filter += format_url("tolower(Rules),'{}')", substring)
        elif space_insensitive:
            url_filter += format_url("replace(Rules, ' ', ''),'{}')", substring)
        else:
            url_filter += format_url("Rules,'{}')", substring)

        url = f"/api/v1/{'ModelCubes()' if skip_control_cubes else 'Cubes'}?$filter={url_filter}" \
              f"&$expand=Dimensions($select=Name)"

        response = self._rest.GET(url, **kwargs)
        cubes = [Cube.from_dict(cube_as_dict=cube) for cube in response.json()['value']]
        return cubes   
예제 #2
0
    def get_control_cubes(self):
        """ Get all Cubes with } prefix from TM1 Server as TM1py.Cube instances

        :return: List of TM1py.Cube instances
        """
        request = "/api/v1/ControlCubes()?$expand=Dimensions($select=Name)"
        response = self._rest.GET(request)
        cubes = [Cube.from_dict(cube_as_dict=cube) for cube in response.json()['value']]
        return cubes
예제 #3
0
    def get_all(self):
        """ get all cubes from TM1 Server as TM1py.Cube instances

        :return: List of TM1py.Cube instances
        """
        request = "/api/v1/Cubes?$expand=Dimensions($select=Name)"
        response = self._rest.GET(request)
        cubes = [Cube.from_dict(cube_as_dict=cube) for cube in response.json()['value']]
        return cubes
예제 #4
0
    def get_model_cubes(self, **kwargs) -> List[Cube]:
        """ Get all Cubes without } prefix from TM1 Server as TM1py.Cube instances

        :return: List of TM1py.Cube instances
        """
        url = "/api/v1/ModelCubes()?$expand=Dimensions($select=Name)"
        response = self._rest.GET(url, **kwargs)
        cubes = [Cube.from_dict(cube_as_dict=cube) for cube in response.json()['value']]
        return cubes
예제 #5
0
    def get_model_cubes(self):
        """ Get all Cubes without } prefix from TM1 Server as TM1py.Cube instances

        :return: List of TM1py.Cube instances
        """
        request = "/api/v1/ModelCubes()?$expand=Dimensions($select=Name)"
        response = self._rest.GET(request)
        response_as_dict = json.loads(response)
        cubes = [
            Cube.from_dict(cube_as_dict=cube)
            for cube in response_as_dict['value']
        ]
        return cubes