Skip to content

Commit

Permalink
Adds performanceStandByCode (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmartorell authored Oct 9, 2023
1 parent be413f6 commit 6f2bcd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/main/java/io/github/jopenlibs/vault/api/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Debug withNameSpace(final String nameSpace) {
* </blockquote>
*/
public HealthResponse health() throws VaultException {
return health(null, null, null, null);
return health(null, null, null, null, null);
}

/**
Expand All @@ -81,14 +81,17 @@ public HealthResponse health() throws VaultException {
* node instead of the default of 429
* @param sealedCode (optional) Indicates the status code that should be returned for a sealed
* node instead of the default of 500
* @param performanceStandbyCode (optional) Indicates the status code that should be
* returned for a performanceStandbyCode node instead of the default of 473
* @return The response information returned from Vault
* @throws VaultException If an error occurs or unexpected response received from Vault
*/
public HealthResponse health(
final Boolean standbyOk,
final Integer activeCode,
final Integer standbyCode,
final Integer sealedCode
final Integer sealedCode,
final Integer performanceStandbyCode
) throws VaultException {
final String path = "sys/health";

Expand Down Expand Up @@ -116,6 +119,8 @@ public HealthResponse health(
if (sealedCode != null) {
rest.parameter("sealedcode", sealedCode.toString());
}
if (performanceStandbyCode != null) rest.parameter("performancestandbycode",
performanceStandbyCode.toString());
// Execute request
final RestResponse restResponse = rest.get();

Expand All @@ -124,6 +129,7 @@ public HealthResponse health(
validCodes.add(200);
validCodes.add(429);
validCodes.add(500);
validCodes.add(473);
if (activeCode != null) {
validCodes.add(activeCode);
}
Expand All @@ -133,6 +139,9 @@ public HealthResponse health(
if (sealedCode != null) {
validCodes.add(sealedCode);
}
if (performanceStandbyCode != null) {
validCodes.add(performanceStandbyCode);
}

if (!validCodes.contains(restResponse.getStatus())) {
throw new VaultException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testHealth_Plain() throws VaultException {

@Test
public void testHealth_WithParams() throws VaultException {
final HealthResponse response = vault.debug().health(null, 212, null, null);
final HealthResponse response = vault.debug().health(null, 212, null, null, null);
assertTrue(response.getInitialized());
assertFalse(response.getSealed());
assertFalse(response.getStandby());
Expand All @@ -67,7 +67,7 @@ public void testHealth_WithParams() throws VaultException {
@Test
public void testHealth_WonkyActiveCode() throws VaultException {
final HealthResponse response = vault.debug().health(null, 204, null,
null);
null, null);
assertNull(response.getInitialized());
assertNull(response.getSealed());
assertNull(response.getStandby());
Expand Down

0 comments on commit 6f2bcd2

Please sign in to comment.