def get_groups(self, max_results=None):
self.clean_error()<EOL>if max_results is None:<EOL><INDENT>max_results = self.max_results<EOL><DEDENT>try:<EOL><INDENT>url = self.get_url(Constants.GET_GROUPS_URL)<EOL>query_parameters = {}<EOL>groups = []<EOL>response = None<EOL>after_cursor = None<EOL>while (not response) or (len(groups) < max_results and after_cursor):<EOL><INDENT>response = self.execute_call('<STR_LIT>', url, params=query_parameters)<EOL>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>json_data = response.json()<EOL>if json_data and json_data.get('<STR_LIT:data>', None):<EOL><INDENT>for group_data in json_data['<STR_LIT:data>']:<EOL><INDENT>if group_data and len(groups) < max_results:<EOL><INDENT>groups.append(Group(group_data))<EOL><DEDENT>else:<EOL><INDENT>return groups<EOL><DEDENT><DEDENT><DEDENT>after_cursor = self.get_after_cursor(response)<EOL>if after_cursor:<EOL><INDENT>query_parameters['<STR_LIT>'] = after_cursor<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.error = str(response.status_code)<EOL>self.error_description = self.extract_error_message_from_response(response)<EOL>break<EOL><DEDENT><DEDENT>return groups<EOL><DEDENT>except Exception as e:<EOL><INDENT>self.error = <NUM_LIT><EOL>self.error_description = e.args[<NUM_LIT:0>]<EOL><DEDENT>
Gets a list of Group resources (element of groups limited with the max_results parameter, or client attribute).

:param max_results: Limit the number of groups returned (optional)
:type max_results: int

Returns the list of groups
:return: group list
:rtype: list[Group]

See https://developers.onelogin.com/api-docs/1/groups/get-groups Get Groups documentation