Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions scripts/generate-sdk/.openapi-generator-ignore-java
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ gradle.properties
gradlew.bat
gradlew
gradle/**

# ApiException from core library should be used (avoid multiple ApiException imports in case different services are used at the same time)
**/ApiException.java

# Authentication classes are not required because the KeyFlowAuth is attached as interceptor
**/auth/**

# Service Configuration is not required. It only stores a defaultApiClient
**/Configuration.java
54 changes: 54 additions & 0 deletions templates/java/ApiCallback.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{! This template was customized to add the core ApiException class as import. }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.14.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiCallback.mustache }}
{{>licenseInfo}}

package {{invokerPackage}};

import java.io.IOException;
import cloud.stackit.sdk.core.exception.ApiException;

import java.util.Map;
import java.util.List;

/**
* Callback for asynchronous API call.
*
* @param <T> The return type
*/
public interface ApiCallback<T> {
/**
* This is called when the API call fails.
*
* @param e The exception causing the failure
* @param statusCode Status code of the response if available, otherwise it would be 0
* @param responseHeaders Headers of the response if available, otherwise it would be null
*/
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);

/**
* This is called when the API call succeeded.
*
* @param result The result deserialized from response
* @param statusCode Status code of the response
* @param responseHeaders Headers of the response
*/
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);

/**
* This is called when the API upload processing.
*
* @param bytesWritten bytes Written
* @param contentLength content length of request body
* @param done write end
*/
void onUploadProgress(long bytesWritten, long contentLength, boolean done);

/**
* This is called when the API download processing.
*
* @param bytesRead bytes Read
* @param contentLength content length of the response
* @param done Read end
*/
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
}
Loading
Loading