code: def get_enrollments(self, course_id=None, usernames=None):
          
          params = {}
          if course_id is not None:
              params['course_id'] = course_id
          if usernames is not None and isinstance(usernames, list):
              params['username'] = ','.join(usernames)
  
          done = False
          while not done:
              enrollments, next_cursor = self._get_enrollments_list_page(params)
              for enrollment in enrollments:
                  yield Enrollment(enrollment)
  
              if next_cursor:
                  params['cursor'] = next_cursor
              else:
                  done = True
docs: List all course enrollments.
  
          Args:
              course_id (str, optional): If used enrollments will be filtered to the specified
                  course id.
              usernames (list, optional): List of usernames to filter enrollments.
  
          Notes:
              - This method returns an iterator to avoid going through the entire pagination at once.
              - The :class:`Enrollments` instance returned for each generated item will not have any
                  course details.
  
          Examples:
              Get all enrollments for a specific course id
              >>> api = EdxApi({'access_token': 'token'}, 'http://base_url')
              >>> enrollments = api.enrollments.get_enrollments(course_id='course_id')
              >>> for enrollment in enrollments:
                      do_something(enrollment)
  
              Get all enrollments for a set of usernames
              >>> api = EdxApi({'access_token': 'token'}, 'http://base_url')
              >>> enrollments = api.enrollments.get_enrollments(usernames=['user1', 'user2'])
              >>> for enrollment in enrollments:
                      do_something(enrollment)
  
          Returns:
              Generator with an instance of :class:`Enrollments` for each item.