def extract_cellset(self, cellset_id, cell_properties=None, top=None, delete_cellset=True, skip_contexts=False): """ Execute Cellset and return the cells with their properties :param skip_contexts: :param delete_cellset: :param cellset_id: :param cell_properties: properties to be queried from the cell. E.g. Value, Ordinal, RuleDerived, ... :param top: integer :return: Content in sweet consice strcuture. """ if not cell_properties: cell_properties = ['Value'] raw_cellset = self.extract_cellset_raw( cellset_id, cell_properties=cell_properties, elem_properties=['UniqueName'], member_properties=['UniqueName'], top=top, skip_contexts=skip_contexts, delete_cellset=delete_cellset) return Utils.build_content_from_cellset( raw_cellset_as_dict=raw_cellset, top=top)
def get_view_content(self, cube_name, view_name, cell_properties=None, private=True, top=None): """ get view content as dictionary with sweet and concise structure. Works on NativeView and MDXView ! Not Hierarchy aware ! :param cube_name: String :param view_name: String :param cell_properties: List, cell properties: [Values, Status, HasPicklist, etc.] :param private: Boolean :param top: Int, number of cells :return: Dictionary : {([dim1].[elem1], [dim2][elem6]): {'Value':3127.312, 'Ordinal':12} .... } """ if not cell_properties: cell_properties = ['Value', 'Ordinal'] cellset_as_dict = self._get_cellset_from_view(cube_name, view_name, cell_properties, private, top) content_as_dict = Utils.build_content_from_cellset( cellset_as_dict, cell_properties, top) return content_as_dict
def execute_mdx(self, mdx, cell_properties=None, top=None): """ Execute MDX and return the cells with their properties :param mdx: MDX Query, as string :param cell_properties: properties to be queried from the cell. Like Value, Ordinal, etc as iterable :param top: integer :return: content in sweet consice strcuture. """ if not cell_properties: cell_properties = ['Value', 'Ordinal'] if top: request = '/api/v1/ExecuteMDX?$expand=Cube($select=Dimensions;$expand=Dimensions($select=Name)),' \ 'Axes($expand=Tuples($expand=Members($select=UniqueName);$top={})),Cells($select={};$top={})' \ .format(str(top), ','.join(cell_properties), str(top)) else: request = '/api/v1/ExecuteMDX?$expand=Cube($select=Dimensions;$expand=Dimensions($select=Name)),' \ 'Axes($expand=Tuples($expand=Members($select=UniqueName))),Cells($select={})' \ .format(','.join(cell_properties)) data = {'MDX': mdx} cellset = self._rest.POST(request=request, data=json.dumps(data, ensure_ascii=False)) return Utils.build_content_from_cellset( raw_cellset_as_dict=json.loads(cellset), cell_properties=cell_properties, top=top)
def execute_mdx(self, mdx, cell_properties=None, top=None): """ Execute MDX and return the cells with their properties :param mdx: MDX Query, as string :param cell_properties: properties to be queried from the cell. E.g. Value, Ordinal, RuleDerived, ... :param top: integer :return: content in sweet consice strcuture. """ if not cell_properties: cell_properties = ['Value', 'Ordinal'] elif 'Ordinal' not in cell_properties: cell_properties.append('Ordinal') request = '/api/v1/ExecuteMDX?$expand=' \ 'Cube($select=Name;$expand=Dimensions($select=Name)),' \ 'Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)){})),' \ 'Cells($select={}{})'.format(';$top=' + str(top) if top else '', ','.join(cell_properties), ';$top=' + str(top) if top else '') data = {'MDX': mdx} response = self._rest.POST(request=request, data=json.dumps(data, ensure_ascii=False)) return Utils.build_content_from_cellset( raw_cellset_as_dict=response.json(), cell_properties=cell_properties, top=top)
def execute_cellset(self, cellset_id, cell_properties=None, top=None): """ Execute Cellset and return the cells with their properties :param cellset_id: :param cell_properties: properties to be queried from the cell. E.g. Value, Ordinal, RuleDerived, ... :param top: integer :return: Content in sweet consice strcuture. """ if not cell_properties: cell_properties = ['Value', 'Ordinal'] elif 'Ordinal' not in cell_properties: cell_properties.append('Ordinal') request = "/api/v1/Cellsets('{cellset_id}')?$expand=" \ "Cube($select=Name;$expand=Dimensions($select=Name))," \ "Axes($expand=Tuples($expand=Members($select=Name;$expand=Element($select=UniqueName)){top_rows}))," \ "Cells($select={cell_properties}{top_cells})" \ .format(cellset_id=cellset_id, top_rows=";$top={}".format(top) if top else "", cell_properties=",".join(cell_properties), top_cells=";$top={}".format(top) if top else "") response = self._rest.GET(request=request) return Utils.build_content_from_cellset( raw_cellset_as_dict=response.json(), cell_properties=cell_properties, top=top)
def get_view_content(self, cube_name, view_name, cell_properties=None, private=True, top=None): warnings.simplefilter('always', PendingDeprecationWarning) warnings.warn("Function deprecated. Use execute_view instead.", PendingDeprecationWarning) warnings.simplefilter('default', PendingDeprecationWarning) if not cell_properties: cell_properties = ['Value', 'Ordinal'] elif 'Ordinal' not in cell_properties: cell_properties.append('Ordinal') cellset_as_dict = self._get_cellset_from_view(cube_name, view_name, cell_properties, private, top) content_as_dict = Utils.build_content_from_cellset( cellset_as_dict, cell_properties, top) return content_as_dict