95 lines
3.1 KiB
Java
95 lines
3.1 KiB
Java
/**
|
|
* Auto-generated from apibuilder.io service spec.
|
|
* apidoc-version : 0.15.4
|
|
* organisation : nclazz
|
|
* service-version : 0.0.0-dev-30-gbd50cdf-bd9390b2-staging
|
|
*
|
|
* Documentation at:
|
|
* <a href="https://app.apibuilder.io/nclazz/users/0.0.0-dev-30-gbd50cdf-bd9390b2-staging">https://app.apibuilder.io/nclazz/users/0.0.0-dev-30-gbd50cdf-bd9390b2-staging</a>
|
|
*
|
|
**/
|
|
package de.nclazz.users.v0.client;
|
|
|
|
import de.nclazz.users.v0.client.UsersApiClientConfig;
|
|
import de.nclazz.users.v0.models.*;
|
|
|
|
import de.nclazz.common.v0.models.Healthcheck;
|
|
|
|
import lombok.*;
|
|
|
|
import javax.ws.rs.client.Entity;
|
|
import javax.ws.rs.client.WebTarget;
|
|
import javax.ws.rs.core.*;
|
|
import java.net.URI;
|
|
|
|
|
|
/**
|
|
* Client for API resource de.nclazz.users.v0.HealthchecksResource
|
|
* version 0.0.0-dev-30-gbd50cdf-bd9390b2-staging
|
|
*
|
|
* Simple healthcheck resource for monitoring purposes.
|
|
**/
|
|
@RequiredArgsConstructor
|
|
public class HealthchecksResource {
|
|
|
|
private final UsersApiClientConfig config;
|
|
|
|
/** Simple healthcheck endpoint to test the status of the service. **/
|
|
public Get get () {
|
|
return new Get(this.config);
|
|
}
|
|
|
|
/**
|
|
* Simple healthcheck endpoint to test the status of the service.
|
|
**/
|
|
public static class Get {
|
|
|
|
private final UsersApiClientConfig config;
|
|
|
|
public Get(@NonNull final UsersApiClientConfig config) {
|
|
this.config = config;
|
|
}
|
|
|
|
public GetResponse request() {
|
|
// /_internal_/healthcheck/healthcheck
|
|
final URI uri = UriBuilder.fromUri(this.config.getBaseUrl())
|
|
.path("_internal_")
|
|
.path("healthcheck")
|
|
.path("healthcheck")
|
|
.build();
|
|
|
|
WebTarget target = config.getClient().target(uri);
|
|
Response response = target.request(MediaType.APPLICATION_JSON)
|
|
.method("GET");
|
|
int status = response.getStatus();
|
|
switch(status) {
|
|
case 200:
|
|
|
|
Healthcheck healthcheck200Resp = response.readEntity(Healthcheck.class);
|
|
return GetResponse.builder()
|
|
.status(status)
|
|
.headers(response.getHeaders())
|
|
.healthcheck200(healthcheck200Resp)
|
|
.build();
|
|
default:
|
|
return GetResponse.builder()
|
|
.status(status)
|
|
.unexpected(response.readEntity(String.class))
|
|
.build();
|
|
}
|
|
}
|
|
|
|
|
|
@Builder
|
|
@Data
|
|
public static class GetResponse {
|
|
private Healthcheck healthcheck200;
|
|
|
|
private final int status;
|
|
private final MultivaluedMap<String, Object> headers;
|
|
private final String unexpected;
|
|
}
|
|
}
|
|
|
|
|
|
} |