<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_managed_ports(self, id_or_uri, port_id_or_uri=''):
 """ Gets all ports or a specific managed target port for the specified storage system. Args: id_or_uri: Can be either the storage system id or the storage system uri. port_id_or_uri: Can be either the port id or the port uri. Returns: dict: Managed ports. """

        if port_id_or_uri:
            uri = self._client.build_uri(port_id_or_uri)
            if "/managedPorts" not in uri:
                uri = self._client.build_uri(id_or_uri) + "/managedPorts" + "/" + port_id_or_uri

        else:
            uri = self._client.build_uri(id_or_uri) + "/managedPorts"

        return self._client.get_collection(uri)