示例#1
0
 def get_all(self, **kwargs) -> List[Chore]:
     """ get a List of all Chores
     :return: List of TM1py.Chore
     """
     url = "/api/v1/Chores?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))"
     response = self._rest.GET(url, **kwargs)
     return [Chore.from_dict(chore_as_dict) for chore_as_dict in response.json()['value']]
示例#2
0
    def get_all(self):
        """ get a List of all Chores

        :return: List of TM1py.Chore
        """
        request = "/api/v1/Chores?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))"
        response = self._rest.GET(request)
        response_as_dict = json.loads(response)
        return [Chore.from_dict(chore_as_dict) for chore_as_dict in response_as_dict['value']]
示例#3
0
 def get(self, chore_name):
     """ Get a chore from the TM1 Server
     :param chore_name:
     :return: instance of TM1py.Chore
     """
     request = "/api/v1/Chores('{}')?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))" \
         .format(chore_name)
     response = self._rest.GET(request)
     return Chore.from_dict(response.json())
示例#4
0
 def get(self, chore_name: str, **kwargs) -> Chore:
     """ Get a chore from the TM1 Server
     :param chore_name:
     :return: instance of TM1py.Chore
     """
     url = format_url(
         "/api/v1/Chores('{}')?$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))",
         chore_name)
     response = self._rest.GET(url, **kwargs)
     return Chore.from_dict(response.json())
示例#5
0
    def search_for_process_name(self, process_name: str,
                                **kwargs) -> List[Chore]:
        """ Return chore details for any/all chores that contain specified process name in tasks

        :param process_name: string, a valid ti process name; spaces will be elimniated
        """
        url = format_url(
            "/api/v1/Chores?$filter=Tasks/any(t: replace(tolower(t/Process/Name), ' ', '') eq '{}')"
            "&$expand=Tasks($expand=*,Chore($select=Name),Process($select=Name))",
            process_name.lower().replace(' ', ''))
        response = self._rest.GET(url, **kwargs)
        return [
            Chore.from_dict(chore_as_dict)
            for chore_as_dict in response.json()['value']
        ]
示例#6
0
    def search_for_parameter_value(self, parameter_value: str,
                                   **kwargs) -> List[Chore]:
        """ Return chore details for any/all chores that have a specified value set in the chore parameter settings
            *this will NOT check the process parameter default, rather the defined parameter value saved in the chore

        :param parameter_value: string, will search wildcard for string in parameter value using Contains(string)
        """
        url = format_url(
            "/api/v1/Chores?"
            "$filter=Tasks/any(t: t/Parameters/any(p: isof(p/Value, Edm.String) and contains(tolower(p/Value), '{}')))"
            "&$expand=Tasks($expand=*,Process($select=Name),Chore($select=Name))",
            parameter_value.lower())
        response = self._rest.GET(url, **kwargs)
        return [
            Chore.from_dict(chore_as_dict)
            for chore_as_dict in response.json()['value']
        ]