Esempio n. 1
0
    def get(self, annotation_id: str, **kwargs) -> Annotation:
        """ get an annotation from any cube through its unique id

        :param annotation_id: String, the id of the annotation
        """
        request = format_url(
            "/api/v1/Annotations('{}')?$expand=DimensionalContext($select=Name)",
            annotation_id)
        response = self._rest.GET(url=request, **kwargs)
        return Annotation.from_json(response.text)
Esempio n. 2
0
 def get(self, annotation_id):
     """ get an annotation from any cube in TM1 Server through its id
 
         :param annotation_id: String, the id of the annotation
 
         :return:
             Annotation: an instance of TM1py.Annoation
     """
     request = "/api/v1/Annotations('{}')?$expand=DimensionalContext($select=Name)".format(annotation_id)
     annotation_as_json = self._rest.GET(request=request)
     return Annotation.from_json(annotation_as_json)
Esempio n. 3
0
 def get_all(self, cube_name):
     """ get all annotations from given cube as a List.
 
     :param cube_name:
     :return: list of instances of TM1py.Annotation
     """
     request = "/api/v1/Cubes('{}')/Annotations?$expand=DimensionalContext($select=Name)".format(cube_name)
     response = self._rest.GET(request, '')
     annotations_as_dict = json.loads(response)['value']
     annotations = [Annotation.from_json(json.dumps(element)) for element in annotations_as_dict]
     return annotations
Esempio n. 4
0
    def get_all(self, cube_name: str, **kwargs) -> List[Annotation]:
        """ get all annotations from given cube as a List.

        :param cube_name:
        """
        url = format_url(
            "/api/v1/Cubes('{}')/Annotations?$expand=DimensionalContext($select=Name)",
            cube_name)
        response = self._rest.GET(url, **kwargs)

        annotations_as_dict = response.json()['value']
        annotations = [
            Annotation.from_json(json.dumps(element))
            for element in annotations_as_dict
        ]
        return annotations