Skip to content

Commit

Permalink
chore: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
astrothmann committed Mar 22, 2024
1 parent 0685368 commit 927b337
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,23 @@ private void addFilter(URIBuilder uriBuilder) throws UnsupportedEncodingExceptio
protected void addNamespaceFilter(URIBuilder uriBuilder) {
if (isMultiUserMode) {
var namespace = connectorRequest.getKubeflowapi().namespace();
if (kubeflowApiOperationsEnum.isNamespaceFilterRequired()) {
if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) {
uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(),
URI_PARAMETER_PAIR_V1_TYPE_NS.getValue());
uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace);
} else {
uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace);
}
} else if (KubeflowApiOperationsEnum.GET_PIPELINES.equals(kubeflowApiOperationsEnum)
&& namespace != null) {
if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) {
uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(),
URI_PARAMETER_PAIR_V1_TYPE_NS.getValue());
uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace);
} else {
uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace);
}
if (kubeflowApiOperationsEnum.isNamespaceFilterRequired() ||
(KubeflowApiOperationsEnum.GET_PIPELINES.equals(kubeflowApiOperationsEnum) && namespace != null)) {
setNamespaceParameter(uriBuilder, namespace);
}
}
}

private void setNamespaceParameter(URIBuilder uriBuilder, String namespace) {
if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) {
uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(),
URI_PARAMETER_PAIR_V1_TYPE_NS.getValue());
uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace);
} else {
uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace);
}
}

public static HttpRequest.BodyPublisher ofFormData(Map<String, Object> data) {
var builder = new StringBuilder();
for (Map.Entry<String, Object> entry : data.entrySet()) {
Expand Down

0 comments on commit 927b337

Please sign in to comment.