pet.store.client.Client Maven / Gradle / Ivy
package pet.store.client;
import jakarta.annotation.Generated;
import java.lang.String;
import java.lang.Void;
import java.util.List;
import java.util.Optional;
import org.davidmoten.oa3.codegen.client.runtime.ClientBuilder;
import org.davidmoten.oa3.codegen.http.Http;
import org.davidmoten.oa3.codegen.http.Http.Builder;
import org.davidmoten.oa3.codegen.http.Http.RequestBuilder;
import org.davidmoten.oa3.codegen.http.HttpMethod;
import org.davidmoten.oa3.codegen.http.Interceptor;
import org.davidmoten.oa3.codegen.http.Serializer;
import org.davidmoten.oa3.codegen.http.service.HttpService;
import pet.store.Globals;
import pet.store.path.FindPets200Response;
import pet.store.schema.Error;
import pet.store.schema.NewPet;
import pet.store.schema.Pet;
/**
* Swagger Petstore
*
A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
*/
@Generated(value = "com.github.davidmoten:openapi-codegen-runtime:0.1.22")
public class Client {
private final Serializer serializer;
private final List interceptors;
private final String basePath;
private final HttpService httpService;
private Client(Serializer serializer, List interceptors, String basePath, HttpService httpService) {
this.serializer = serializer;
this.interceptors = interceptors;
this.basePath = basePath;
this.httpService = httpService;
}
public static ClientBuilder basePath(String basePath) {
return new ClientBuilder<>(b -> new Client(b.serializer(), b.interceptors(), b.basePath(), b.httpService()), Globals.config(), basePath);
}
public static ClientBuilder basePath(Server server) {
return new ClientBuilder<>(b -> new Client(b.serializer(), b.interceptors(), b.basePath(), b.httpService()), Globals.config(), server.url());
}
public enum Server {
SERVER1("http://petstore.swagger.io/api");
private String url;
Server(String url) {
this.url = url;
}
public String url() {
return url;
}
}
private Builder http(HttpMethod method, String path) {
return Http
.method(method)
.basePath(this.basePath)
.path(path)
.serializer(this.serializer)
.interceptors(this.interceptors)
.httpService(this.httpService);
}
/**
* Returns all pets from the system that the user has access to
* Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
*
Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
*
*
[status=200, application/json] --> {@code FindPets200Response}
*
[status=default, application/json] --> {@code Error}
*
* @param limit
*
maximum number of results to return
* @param tags
*
tags to filter by
* @return call builder
*/
public RequestBuilder findPets(
Optional> tags,
int limit) {
return http(HttpMethod.GET, "/pets")
.acceptApplicationJson()
.queryParam("tags", tags)
.queryParam("limit", limit)
.responseAs(FindPets200Response.class)
.whenStatusCodeMatches("200")
.whenContentTypeMatches("application/json")
.responseAs(Error.class)
.whenStatusCodeMatches("default")
.whenContentTypeMatches("application/json")
.requestBuilder("200", "application/json");
}
/**
* Creates a new pet in the store. Duplicates are allowed
*
*
[status=200, application/json] --> {@code Pet}
*
[status=default, application/json] --> {@code Error}
*
* @param requestBody
*
requestBody
* @return call builder
*/
public RequestBuilder addPet(
NewPet requestBody) {
return http(HttpMethod.POST, "/pets")
.acceptApplicationJson()
.body(requestBody)
.contentTypeApplicationJson()
.responseAs(Pet.class)
.whenStatusCodeMatches("200")
.whenContentTypeMatches("application/json")
.responseAs(Error.class)
.whenStatusCodeMatches("default")
.whenContentTypeMatches("application/json")
.requestBuilder("200", "application/json");
}
/**
* Returns a user based on a single ID, if the user does not have access to the pet
*
*
[status=200, application/json] --> {@code Pet}
*
[status=default, application/json] --> {@code Error}
*
* @param id
*
ID of pet to fetch
* @return call builder
*/
public RequestBuilder find_pet_by_id(
long id) {
return http(HttpMethod.GET, "/pets/{id}")
.acceptApplicationJson()
.pathParam("id", id)
.responseAs(Pet.class)
.whenStatusCodeMatches("200")
.whenContentTypeMatches("application/json")
.responseAs(Error.class)
.whenStatusCodeMatches("default")
.whenContentTypeMatches("application/json")
.requestBuilder("200", "application/json");
}
/**
* deletes a single pet based on the ID supplied
*
*
[status=default, application/json] --> {@code Error}
*
* @param id
*
ID of pet to delete
* @return call builder
*/
public RequestBuilder deletePet(
long id) {
return http(HttpMethod.DELETE, "/pets/{id}")
.acceptApplicationJson()
.pathParam("id", id)
.responseAs(Error.class)
.whenStatusCodeMatches("default")
.whenContentTypeMatches("application/json")
.requestBuilder();
}
public Builder _custom(HttpMethod method, String path) {
return Http
.method(method)
.basePath(this.basePath)
.path(path)
.serializer(this.serializer)
.httpService(this.httpService);
}
}