code: def list_deployments(self, namespace=None):
          
  
          if namespace:
              return [Deployment(name=d.metadata.name,
                                 namespace=d.metadata.namespace,
                                 labels=d.metadata.labels, selector=d.spec.selector,
                                 image_metadata=ImageMetadata(
                                     name=d.spec.template.spec.containers[0].name.split("-", 1)[0]))
                      for d in self.apps_api.list_namespaced_deployment(namespace, watch=False).items]
  
          return [Deployment(name=d.metadata.name,
                             namespace=d.metadata.namespace,
                             labels=d.metadata.labels, selector=d.spec.selector,
                             image_metadata=ImageMetadata(
                                 name=d.spec.template.spec.containers[0].name.split("-", 1)[0]))
                  for d in self.apps_api.list_deployment_for_all_namespaces(watch=False).items]
docs: List all available deployments.
  
          :param namespace: str, if not specified list deployments for all namespaces
          :return: collection of instances of :class:`conu.backend.k8s.deployment.Deployment`