コード例 #1
0
ファイル: CubeService.py プロジェクト: nicolasbisurgi/tm1py
    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
ファイル: CubeService.py プロジェクト: tombrzy/tm1py
    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
ファイル: CubeService.py プロジェクト: tombrzy/tm1py
    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
ファイル: CubeService.py プロジェクト: nicolasbisurgi/tm1py
    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
ファイル: CubeService.py プロジェクト: tombrzy/tm1py
    def get(self, cube_name):
        """ get cube from TM1 Server

        :param cube_name:
        :return: instance of TM1py.Cube
        """
        request = "/api/v1/Cubes('{}')?$expand=Dimensions($select=Name)".format(cube_name)
        response = self._rest.GET(request)
        cube = Cube.from_json(response.text)
        return cube
コード例 #6
0
    def get(self, cube_name: str, **kwargs) -> Cube:
        """ get cube from TM1 Server

        :param cube_name:
        :return: instance of TM1py.Cube
        """
        url = format_url("/api/v1/Cubes('{}')?$expand=Dimensions($select=Name)", cube_name)
        response = self._rest.GET(url=url, **kwargs)
        cube = Cube.from_json(response.text)
        return cube
コード例 #7
0
ファイル: CubeService.py プロジェクト: cubewise-tryan/TM1py
    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
コード例 #8
0
ファイル: CubeService.py プロジェクト: nicolasbisurgi/tm1py
    def get(self, cube_name: str, **kwargs) -> Cube:
        """ get cube from TM1 Server

        :param cube_name:
        :return: instance of TM1py.Cube
        """
        url = format_url("/api/v1/Cubes('{}')?$expand=Dimensions($select=Name)", cube_name)
        response = self._rest.GET(url=url, **kwargs)
        cube = Cube.from_json(response.text)
        # cater for potential EnableSandboxDimension=T setup
        if case_and_space_insensitive_equals(cube.dimensions[0], "Sandboxes"):
            cube.dimensions = cube.dimensions[1:]
        return cube