use of com.amazonaws.serverless.sample.springboot2.model.Pet in project springdoc-openapi-demos by springdoc.
the class PetApiDelegateImpl method createPet.
private static Pet createPet(long id, Category category, String name, String[] urls, String[] tags, Pet.StatusEnum status) {
Pet pet = new Pet().id(id).category(category).name(name).status(status);
if (null != urls) {
pet.setPhotoUrls(Arrays.asList(urls));
}
final AtomicLong i = new AtomicLong(0);
if (null != tags && tags.length > 0) {
Arrays.stream(tags).map(tag -> new Tag().name(tag).id(i.incrementAndGet())).forEach(pet::addTagsItem);
}
return pet;
}
use of com.amazonaws.serverless.sample.springboot2.model.Pet in project aws-serverless-java-container by awslabs.
the class PetsController method createPet.
@RequestMapping(path = "/pets", method = RequestMethod.POST)
public Pet createPet(@RequestBody Pet newPet) {
if (newPet.getName() == null || newPet.getBreed() == null) {
return null;
}
Pet dbPet = newPet;
dbPet.setId(UUID.randomUUID().toString());
return dbPet;
}
use of com.amazonaws.serverless.sample.springboot2.model.Pet in project aws-serverless-java-container by awslabs.
the class PetsController method listPets.
@RequestMapping(path = "/pets", method = RequestMethod.GET)
public Pet[] listPets(@RequestParam("limit") Optional<Integer> limit, Principal principal) {
int queryLimit = 10;
if (limit.isPresent()) {
queryLimit = limit.get();
}
Pet[] outputPets = new Pet[queryLimit];
for (int i = 0; i < queryLimit; i++) {
Pet newPet = new Pet();
newPet.setId(UUID.randomUUID().toString());
newPet.setName(PetData.getRandomName());
newPet.setBreed(PetData.getRandomBreed());
newPet.setDateOfBirth(PetData.getRandomDoB());
outputPets[i] = newPet;
}
return outputPets;
}
use of com.amazonaws.serverless.sample.springboot2.model.Pet in project aws-serverless-java-container by awslabs.
the class PetsController method listPets.
@RequestMapping(path = "/pets/{petId}", method = RequestMethod.GET)
public Pet listPets() {
Pet newPet = new Pet();
newPet.setId(UUID.randomUUID().toString());
newPet.setBreed(PetData.getRandomBreed());
newPet.setDateOfBirth(PetData.getRandomDoB());
newPet.setName(PetData.getRandomName());
return newPet;
}
Aggregations