Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.fluent.func.dsl;

import io.serverlessworkflow.fluent.func.FuncCallHttpTaskBuilder;
import io.serverlessworkflow.fluent.func.FuncTaskItemListBuilder;
import io.serverlessworkflow.fluent.spec.dsl.BaseCallHttpSpec;
import io.serverlessworkflow.fluent.spec.spi.CallHttpTaskFluent;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class FuncCallHttpStep extends Step<FuncCallHttpStep, FuncCallHttpTaskBuilder>
implements BaseCallHttpSpec<FuncCallHttpStep> {

private final List<Consumer<CallHttpTaskFluent<?>>> steps = new ArrayList<>();

private String name;

public FuncCallHttpStep(String name) {
this.name = name;
}

public FuncCallHttpStep() {}

@Override
public FuncCallHttpStep self() {
return this;
}

protected void configure(FuncTaskItemListBuilder list, Consumer<FuncCallHttpTaskBuilder> post) {
list.http(
name,
builder -> {
this.accept(builder);
post.accept(builder);
});
}

@Override
public List<Consumer<CallHttpTaskFluent<?>>> steps() {
return steps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import io.serverlessworkflow.api.types.OpenAPIArguments;
import io.serverlessworkflow.fluent.func.FuncCallOpenAPITaskBuilder;
import io.serverlessworkflow.fluent.func.configurers.FuncCallOpenAPIConfigurer;
import io.serverlessworkflow.fluent.func.FuncTaskItemListBuilder;
import io.serverlessworkflow.fluent.spec.configurers.AuthenticationConfigurer;
import io.serverlessworkflow.fluent.spec.spi.CallOpenAPITaskFluent;
import java.net.URI;
Expand All @@ -26,65 +26,83 @@
import java.util.Map;
import java.util.function.Consumer;

public class FuncCallOpenAPISpec implements FuncCallOpenAPIConfigurer {
public class FuncCallOpenAPIStep extends Step<FuncCallOpenAPIStep, FuncCallOpenAPITaskBuilder> {

private final List<Consumer<CallOpenAPITaskFluent<?>>> steps = new ArrayList<>();

public FuncCallOpenAPISpec document(String uri) {
private String name;

public FuncCallOpenAPIStep(String name) {
this.name = name;
}

public FuncCallOpenAPIStep() {}

public void setName(String name) {
this.name = name;
}

public FuncCallOpenAPIStep document(String uri) {
steps.add(b -> b.document(uri));
return this;
}

public FuncCallOpenAPISpec document(
public FuncCallOpenAPIStep document(
String uri, AuthenticationConfigurer authenticationConfigurer) {
steps.add(b -> b.document(uri, authenticationConfigurer));
return this;
}

public FuncCallOpenAPISpec document(URI uri) {
public FuncCallOpenAPIStep document(URI uri) {
steps.add(b -> b.document(uri));
return this;
}

public FuncCallOpenAPISpec document(URI uri, AuthenticationConfigurer authenticationConfigurer) {
public FuncCallOpenAPIStep document(URI uri, AuthenticationConfigurer authenticationConfigurer) {
steps.add(b -> b.document(uri, authenticationConfigurer));
return this;
}

public FuncCallOpenAPISpec operation(String operationId) {
public FuncCallOpenAPIStep operation(String operationId) {
steps.add(b -> b.operation(operationId));
return this;
}

public FuncCallOpenAPISpec parameters(Map<String, Object> params) {
public FuncCallOpenAPIStep parameters(Map<String, Object> params) {
steps.add(b -> b.parameters(params));
return this;
}

public FuncCallOpenAPISpec parameter(String name, String value) {
public FuncCallOpenAPIStep parameter(String name, String value) {
steps.add(b -> b.parameter(name, value));
return this;
}

public FuncCallOpenAPISpec redirect(boolean redirect) {
public FuncCallOpenAPIStep redirect(boolean redirect) {
steps.add(b -> b.redirect(redirect));
return this;
}

public FuncCallOpenAPISpec authentication(AuthenticationConfigurer authenticationConfigurer) {
public FuncCallOpenAPIStep authentication(AuthenticationConfigurer authenticationConfigurer) {
steps.add(b -> b.authentication(authenticationConfigurer));
return this;
}

public FuncCallOpenAPISpec output(OpenAPIArguments.WithOpenAPIOutput output) {
public FuncCallOpenAPIStep output(OpenAPIArguments.WithOpenAPIOutput output) {
steps.add(b -> b.output(output));
return this;
}

@Override
public void accept(FuncCallOpenAPITaskBuilder builder) {
for (var s : steps) {
s.accept(builder);
}
protected void configure(
FuncTaskItemListBuilder list, Consumer<FuncCallOpenAPITaskBuilder> post) {
list.openapi(
name,
builder -> {
for (Consumer<CallOpenAPITaskFluent<?>> c : steps) {
c.accept(builder);
}
post.accept(builder);
});
}
}
Loading