<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bluemix(cls, vcap_services, instance_name=None, service_name=None, **kwargs):
 """ Create a Cloudant session using a VCAP_SERVICES environment variable. :param vcap_services: VCAP_SERVICES environment variable :type vcap_services: dict or str :param str instance_name: Optional Bluemix instance name. Only required if multiple Cloudant instances are available. :param str service_name: Optional Bluemix service name. Example usage: .. code-block:: python import os from cloudant.client import Cloudant client = Cloudant.bluemix(os.getenv('VCAP_SERVICES'), 'Cloudant NoSQL DB') print client.all_dbs() """

        service_name = service_name or 'cloudantNoSQLDB'  # default service
        try:
            service = CloudFoundryService(vcap_services,
                                          instance_name=instance_name,
                                          service_name=service_name)
        except CloudantException:
            raise CloudantClientException(103)

        if hasattr(service, 'iam_api_key'):
            return Cloudant.iam(service.username,
                                service.iam_api_key,
                                url=service.url,
                                **kwargs)
        return Cloudant(service.username,
                        service.password,
                        url=service.url,
                        **kwargs)