Search in sources :

Example 1 with ResourceQuotaList

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

the class KubernetesResourcesQuotaProducer method doListResourceQuotasByLabels.

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

Example 2 with ResourceQuotaList

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

the class KubernetesResourcesQuotaProducer method doList.

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

Aggregations

ResourceQuotaList (io.fabric8.kubernetes.api.model.ResourceQuotaList)2 DoneableResourceQuota (io.fabric8.kubernetes.api.model.DoneableResourceQuota)1 ResourceQuota (io.fabric8.kubernetes.api.model.ResourceQuota)1 Resource (io.fabric8.kubernetes.client.dsl.Resource)1 Map (java.util.Map)1