// Code generated by openapi-nexus. DO NOT EDIT.
//
// Test API with DELETE Response Schema — 1.0.0
// Test fixture for DELETE operations with JSON response schemas and type alias request bodies
package com.example.sdk.apis;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.example.sdk.models.*;
import com.example.sdk.runtime.ApiClient;
import com.example.sdk.runtime.ApiException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import okhttp3.Request;
import okhttp3.Response;
/**
* CreateTestResourceResponse carries the response from createTestResource.
*/
public class CreateTestResourceResponse {
private final int statusCode;
private final Response raw;
private final CreateTestResourceResponse status200;
public CreateTestResourceResponse(int statusCode, Response raw,
CreateTestResourceResponse status200) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public CreateTestResourceResponse getStatus200() {
return this.status200;
}
}
/**
* DeleteTestResourceResponse carries the response from deleteTestResource.
*/
public class DeleteTestResourceResponse {
private final int statusCode;
private final Response raw;
private final DeleteTestResourceResponse status200;
private final HttpErrorResponse status4xx;
private final HttpErrorResponse status5xx;
public DeleteTestResourceResponse(int statusCode, Response raw,
DeleteTestResourceResponse status200,
HttpErrorResponse status4xx, HttpErrorResponse status5xx) {
this.statusCode = statusCode;
this.raw = raw;
this.status200 = status200;
this.status4xx = status4xx;
this.status5xx = status5xx;
}
public int getStatusCode() {
return this.statusCode;
}
public Response getRaw() {
return this.raw;
}
public DeleteTestResourceResponse getStatus200() {
return this.status200;
}
public HttpErrorResponse getStatus4xx() {
return this.status4xx;
}
public HttpErrorResponse getStatus5xx() {
return this.status5xx;
}
}
/**
* TestResourceApi groups operations under the test-resource tag.
*/
public class TestResourceApi {
private final ApiClient client;
private final Gson gson = new Gson();
public TestResourceApi(ApiClient client) {
this.client = client;
}
/**
* createTestResource POST /v1/api/test-resource.
*/
public CreateTestResourceResponse createTestResource(CreateTestResourceRequest body) throws IOException {
String path = "/v1/api/test-resource";
String jsonBody = gson.toJson(body);
Request request = client.newRequest("POST", path, null, jsonBody);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
CreateTestResourceResponse status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<CreateTestResourceResponse>() {}.getType());
}
return new CreateTestResourceResponse(response.code(), response, status200);
}
/**
* deleteTestResource DELETE /v1/api/test-resource/{resource_id}.
*/
public DeleteTestResourceResponse deleteTestResource(String resourceId) throws IOException {
String path = "/v1/api/test-resource/{resource_id}".replace("{resource_id}", resourceId);
Request request = client.newRequest("DELETE", path, null, null);
Response response = client.execute(request);
if (!response.isSuccessful()) {
String errorBody = response.body() != null ? response.body().string() : "";
throw new ApiException(response.code(), response.message(), errorBody);
}
String responseBody = response.body() != null ? response.body().string() : "null";
DeleteTestResourceResponse status200 = null;
if (response.code() == 200) {
status200 = gson.fromJson(responseBody, new TypeToken<DeleteTestResourceResponse>() {}.getType());
}
HttpErrorResponse status4xx = null;
status4xx = gson.fromJson(responseBody, new TypeToken<HttpErrorResponse>() {}.getType());
HttpErrorResponse status5xx = null;
status5xx = gson.fromJson(responseBody, new TypeToken<HttpErrorResponse>() {}.getType());
return new DeleteTestResourceResponse(response.code(), response, status200, status4xx, status5xx);
}
}