Search in sources :

Example 1 with PersistentVolumeClaimList

use of io.fabric8.kubernetes.api.model.PersistentVolumeClaimList in project camel by apache.

the class KubernetesPersistentVolumesClaimsProducer method doListPersistentVolumesClaimsByLabels.

protected void doListPersistentVolumesClaimsByLabels(Exchange exchange, String operation) throws Exception {
    PersistentVolumeClaimList pvcList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<PersistentVolumeClaim, PersistentVolumeClaimList, DoneablePersistentVolumeClaim, Resource<PersistentVolumeClaim, DoneablePersistentVolumeClaim>> pvcs = getEndpoint().getKubernetesClient().persistentVolumeClaims().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            pvcs.withLabel(entry.getKey(), entry.getValue());
        }
        pvcList = pvcs.list();
    } else {
        MixedOperation<PersistentVolumeClaim, PersistentVolumeClaimList, DoneablePersistentVolumeClaim, Resource<PersistentVolumeClaim, DoneablePersistentVolumeClaim>> pvcs = getEndpoint().getKubernetesClient().persistentVolumeClaims();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            pvcs.withLabel(entry.getKey(), entry.getValue());
        }
        pvcList = pvcs.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(pvcList.getItems());
}
Also used : PersistentVolumeClaimList(io.fabric8.kubernetes.api.model.PersistentVolumeClaimList) Resource(io.fabric8.kubernetes.client.dsl.Resource) DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) Map(java.util.Map)

Example 2 with PersistentVolumeClaimList

use of io.fabric8.kubernetes.api.model.PersistentVolumeClaimList in project camel by apache.

the class KubernetesPersistentVolumesClaimsProducer method doList.

protected void doList(Exchange exchange, String operation) throws Exception {
    PersistentVolumeClaimList persistentVolumeClaimList = getEndpoint().getKubernetesClient().persistentVolumeClaims().list();
    exchange.getOut().setBody(persistentVolumeClaimList.getItems());
}
Also used : PersistentVolumeClaimList(io.fabric8.kubernetes.api.model.PersistentVolumeClaimList)

Aggregations

PersistentVolumeClaimList (io.fabric8.kubernetes.api.model.PersistentVolumeClaimList)2 DoneablePersistentVolumeClaim (io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim)1 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Map (java.util.Map)1