<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_service_packages(self):
 """Get all service packages"""

        api = self._get_api(billing.DefaultApi)
        package_response = api.get_service_packages()
        packages = []
        for state in PACKAGE_STATES:
            # iterate states in order
            items = getattr(package_response, state) or []
            for item in ensure_listable(items):
                params = item.to_dict()
                params['state'] = state
                packages.append(ServicePackage(params))
        return packages