@Override public MixedOperation<ResourceQuota, ResourceQuotaList, DoneableResourceQuota, Resource<ResourceQuota, DoneableResourceQuota>> resourceQuotas() { return delegate.resourceQuotas(); }
@Override public MixedOperation<ResourceQuota, ResourceQuotaList, DoneableResourceQuota, Resource<ResourceQuota, DoneableResourceQuota>> resourceQuotas() { return delegate.resourceQuotas(); }
protected void doList(Exchange exchange, String operation) throws Exception { ResourceQuotaList resList = getEndpoint().getKubernetesClient() .resourceQuotas().inAnyNamespace().list(); MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true); exchange.getOut().setBody(resList.getItems()); }
protected void doGetResourceQuota(Exchange exchange, String operation) throws Exception { ResourceQuota rq = null; String rqName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_NAME, String.class); String namespaceName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class); if (ObjectHelper.isEmpty(rqName)) { LOG.error("Get a specific Resource Quota require specify a Resource Quota name"); throw new IllegalArgumentException( "Get a specific Resource Quota require specify a Resource Quota name"); } if (ObjectHelper.isEmpty(namespaceName)) { LOG.error("Get a specific Resource Quota require specify a namespace name"); throw new IllegalArgumentException( "Get a specific Resource Quota require specify a namespace name"); } rq = getEndpoint().getKubernetesClient().resourceQuotas() .inNamespace(namespaceName).withName(rqName).get(); MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true); exchange.getOut().setBody(rq); }
protected void doDeleteResourceQuota(Exchange exchange, String operation) throws Exception { String rqName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_NAME, String.class); String namespaceName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class); if (ObjectHelper.isEmpty(rqName)) { LOG.error("Delete a specific resource quota require specify a resource quota name"); throw new IllegalArgumentException( "Delete a specific resource quota require specify a resource quota name"); } if (ObjectHelper.isEmpty(namespaceName)) { LOG.error("Delete a specific resource quota require specify a namespace name"); throw new IllegalArgumentException( "Delete a specific resource quota require specify a namespace name"); } boolean rqDeleted = getEndpoint().getKubernetesClient() .resourceQuotas().inNamespace(namespaceName).withName(rqName) .delete(); MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true); exchange.getOut().setBody(rqDeleted); } }
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()); }
.withNewMetadata().withName(rqName).withLabels(labels) .endMetadata().withSpec(rqSpec).build(); rq = getEndpoint().getKubernetesClient().resourceQuotas() .inNamespace(namespaceName).create(rqCreating);
log("Create resource quota", client.resourceQuotas().inNamespace("thisisatest").create(quota));