Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds performanceStandByCode #54

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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