-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'draft' into dependabot/maven/start/org.apache.maven.plu…
…gins-maven-surefire-plugin-3.3.1
- Loading branch information
Showing
8 changed files
with
85 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
start/inventory/src/main/java/io/openliberty/guides/inventory/InventoryResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.inventory; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Properties; | ||
import java.util.logging.Logger; | ||
import java.util.stream.Collectors; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.DELETE; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
@ApplicationScoped | ||
@Path("/inventory") | ||
public class InventoryResource { | ||
|
||
private static Logger logger = Logger.getLogger(InventoryResource.class.getName()); | ||
|
||
@Inject | ||
private InventoryManager manager; | ||
|
||
@GET | ||
@Path("/systems") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response getSystems() { | ||
List<Properties> systems = manager.getSystems() | ||
.values() | ||
.stream() | ||
.collect(Collectors.toList()); | ||
return Response | ||
.status(Response.Status.OK) | ||
.entity(systems) | ||
.build(); | ||
} | ||
|
||
@GET | ||
@Path("/systems/{hostname}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response getSystem(@PathParam("hostname") String hostname) { | ||
Optional<Properties> system = manager.getSystem(hostname); | ||
if (system.isPresent()) { | ||
return Response | ||
.status(Response.Status.OK) | ||
.entity(system) | ||
.build(); | ||
} | ||
return Response | ||
.status(Response.Status.NOT_FOUND) | ||
.entity("hostname does not exist.") | ||
.build(); | ||
} | ||
|
||
@DELETE | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response resetSystems() { | ||
manager.resetSystems(); | ||
return Response | ||
.status(Response.Status.OK) | ||
.build(); | ||
} | ||
} |
Empty file.
148 changes: 0 additions & 148 deletions
148
start/inventory/src/test/java/it/io/openliberty/guides/inventory/InventoryEndpointIT.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters