-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
394cf36
commit 02c953d
Showing
10 changed files
with
9,154 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// Copyright 2020 StrongDM Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Code generated by protogen. DO NOT EDIT. | ||
|
||
package com.strongdm.api; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
/** | ||
* SecretStoreHealth denotes a secret store's health status. Note a secret store is not healthy in | ||
* terms of a simple boolean, but rather healthy with respect to a particular node or set of nodes. | ||
*/ | ||
public class SecretStoreHealth { | ||
private Date changedAt; | ||
/** The time when the status last changed */ | ||
public Date getChangedAt() { | ||
return this.changedAt; | ||
} | ||
/** The time when the status last changed */ | ||
public void setChangedAt(Date in) { | ||
this.changedAt = in; | ||
} | ||
|
||
private Date checkedAt; | ||
/** The time when the status was last checked by the node */ | ||
public Date getCheckedAt() { | ||
return this.checkedAt; | ||
} | ||
/** The time when the status was last checked by the node */ | ||
public void setCheckedAt(Date in) { | ||
this.checkedAt = in; | ||
} | ||
|
||
private String error; | ||
/** | ||
* The error associated with this health check, if it occurred after reachability checks | ||
* succeeded. | ||
*/ | ||
public String getError() { | ||
return this.error; | ||
} | ||
/** | ||
* The error associated with this health check, if it occurred after reachability checks | ||
* succeeded. | ||
*/ | ||
public void setError(String in) { | ||
this.error = in; | ||
} | ||
|
||
private List<String> flags; | ||
/** Any specific status or error flags associated with this health check. */ | ||
public List<String> getFlags() { | ||
return this.flags; | ||
} | ||
/** Any specific status or error flags associated with this health check. */ | ||
public void setFlags(List<String> in) { | ||
this.flags = in; | ||
} | ||
|
||
private String nodeId; | ||
/** Associated node id for this health */ | ||
public String getNodeId() { | ||
return this.nodeId; | ||
} | ||
/** Associated node id for this health */ | ||
public void setNodeId(String in) { | ||
this.nodeId = in; | ||
} | ||
|
||
private String reachability; | ||
/** The error associated with this health check, if it occurred during reachability checks. */ | ||
public String getReachability() { | ||
return this.reachability; | ||
} | ||
/** The error associated with this health check, if it occurred during reachability checks. */ | ||
public void setReachability(String in) { | ||
this.reachability = in; | ||
} | ||
|
||
private String secretStoreId; | ||
/** Associated secret store for this health */ | ||
public String getSecretStoreId() { | ||
return this.secretStoreId; | ||
} | ||
/** Associated secret store for this health */ | ||
public void setSecretStoreId(String in) { | ||
this.secretStoreId = in; | ||
} | ||
|
||
private String status; | ||
/** The status of the link between the node and secret store */ | ||
public String getStatus() { | ||
return this.status; | ||
} | ||
/** The status of the link between the node and secret store */ | ||
public void setStatus(String in) { | ||
this.status = in; | ||
} | ||
} |
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,30 @@ | ||
// Copyright 2020 StrongDM Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Code generated by protogen. DO NOT EDIT. | ||
|
||
package com.strongdm.api; | ||
|
||
public class SecretStoreHealthListResponse { | ||
private RateLimitMetadata rateLimit; | ||
/** Rate limit information. */ | ||
public RateLimitMetadata getRateLimit() { | ||
return this.rateLimit; | ||
} | ||
/** Rate limit information. */ | ||
public void setRateLimit(RateLimitMetadata in) { | ||
this.rateLimit = in; | ||
} | ||
} |
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,30 @@ | ||
// Copyright 2020 StrongDM Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Code generated by protogen. DO NOT EDIT. | ||
|
||
package com.strongdm.api; | ||
|
||
public class SecretStoreHealthcheckResponse { | ||
private RateLimitMetadata rateLimit; | ||
/** Rate limit information. */ | ||
public RateLimitMetadata getRateLimit() { | ||
return this.rateLimit; | ||
} | ||
/** Rate limit information. */ | ||
public void setRateLimit(RateLimitMetadata in) { | ||
this.rateLimit = in; | ||
} | ||
} |
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,141 @@ | ||
// Copyright 2020 StrongDM Inc | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Code generated by protogen. DO NOT EDIT. | ||
|
||
package com.strongdm.api; | ||
|
||
import com.strongdm.api.plumbing.PageIterator; | ||
import com.strongdm.api.plumbing.PageResult; | ||
import com.strongdm.api.plumbing.Plumbing; | ||
import com.strongdm.api.plumbing.SecretStoreHealthsGrpc; | ||
import com.strongdm.api.plumbing.SecretStoreHealthsPlumbing; | ||
import com.strongdm.api.plumbing.Spec.ListRequestMetadata; | ||
import io.grpc.ManagedChannel; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
|
||
/** SecretStoreHealths exposes health states for secret stores. */ | ||
public class SecretStoreHealths { | ||
private final SecretStoreHealthsGrpc.SecretStoreHealthsBlockingStub stub; | ||
private final Client parent; | ||
|
||
public SecretStoreHealths(ManagedChannel channel, Client client) { | ||
|
||
this.stub = SecretStoreHealthsGrpc.newBlockingStub(channel); | ||
this.parent = client; | ||
} | ||
|
||
private SecretStoreHealths( | ||
SecretStoreHealthsGrpc.SecretStoreHealthsBlockingStub stub, Client client) { | ||
this.stub = stub; | ||
this.parent = client; | ||
} | ||
|
||
/** | ||
* This function returns a copy of the SecretStoreHealths service which has the given deadline set | ||
* for all method calls. | ||
*/ | ||
public SecretStoreHealths withDeadlineAfter(long duration, TimeUnit units) { | ||
return new SecretStoreHealths(this.stub.withDeadlineAfter(duration, units), this.parent); | ||
} | ||
/** List reports the health status of node to secret store pairs. */ | ||
public Iterable<SecretStoreHealth> list(String filter, Object... args) throws RpcException { | ||
SecretStoreHealthsPlumbing.SecretStoreHealthListRequest.Builder builder = | ||
SecretStoreHealthsPlumbing.SecretStoreHealthListRequest.newBuilder(); | ||
builder.setFilter(Plumbing.quoteFilterArgs(filter, args)); | ||
ListRequestMetadata.Builder metaBuilder = ListRequestMetadata.newBuilder(); | ||
if (this.parent.pageLimit > 0) { | ||
metaBuilder.setLimit(this.parent.pageLimit); | ||
} | ||
if (this.parent.snapshotDate != null) { | ||
metaBuilder.setSnapshotAt(Plumbing.convertTimestampToPlumbing(this.parent.snapshotDate)); | ||
} | ||
builder.setMeta(metaBuilder); | ||
|
||
Supplier<PageResult<SecretStoreHealth>> pageFetcher = | ||
() -> { | ||
// Note: this closure captures and reuses the builder to set the next page | ||
SecretStoreHealthsPlumbing.SecretStoreHealthListRequest req = builder.build(); | ||
SecretStoreHealthsPlumbing.SecretStoreHealthListResponse plumbingResponse; | ||
int tries = 0; | ||
while (true) { | ||
try { | ||
plumbingResponse = | ||
this.stub | ||
.withCallCredentials( | ||
this.parent.getCallCredentials("SecretStoreHealths.List", req)) | ||
.list(req); | ||
} catch (Exception e) { | ||
if (this.parent.shouldRetry(tries, e)) { | ||
tries++; | ||
this.parent.jitterSleep(tries); | ||
continue; | ||
} | ||
throw Plumbing.convertExceptionToPorcelain(e); | ||
} | ||
break; | ||
} | ||
|
||
List<SecretStoreHealth> page = | ||
Plumbing.convertRepeatedSecretStoreHealthToPorcelain( | ||
plumbingResponse.getSecretStoreHealthsList()); | ||
|
||
boolean hasNextCursor = plumbingResponse.getMeta().getNextCursor() != ""; | ||
builder.setMeta( | ||
ListRequestMetadata.newBuilder() | ||
.setCursor(plumbingResponse.getMeta().getNextCursor())); | ||
|
||
return new PageResult<SecretStoreHealth>(page, hasNextCursor); | ||
}; | ||
|
||
Iterator<SecretStoreHealth> iterator = new PageIterator<>(pageFetcher); | ||
|
||
return () -> iterator; | ||
} | ||
/** | ||
* Healthcheck triggers a remote healthcheck request for a secret store. It may take minutes to | ||
* propagate across a large network of Nodes. The call will return immediately, and the updated | ||
* health of the Secret Store can be retrieved via List. | ||
*/ | ||
public SecretStoreHealthcheckResponse healthcheck(String secretStoreId) throws RpcException { | ||
SecretStoreHealthsPlumbing.SecretStoreHealthcheckRequest.Builder builder = | ||
SecretStoreHealthsPlumbing.SecretStoreHealthcheckRequest.newBuilder(); | ||
builder.setSecretStoreId((secretStoreId)); | ||
SecretStoreHealthsPlumbing.SecretStoreHealthcheckRequest req = builder.build(); | ||
SecretStoreHealthsPlumbing.SecretStoreHealthcheckResponse plumbingResponse; | ||
int tries = 0; | ||
while (true) { | ||
try { | ||
plumbingResponse = | ||
this.stub | ||
.withCallCredentials( | ||
this.parent.getCallCredentials("SecretStoreHealths.Healthcheck", req)) | ||
.healthcheck(req); | ||
} catch (Exception e) { | ||
if (this.parent.shouldRetry(tries, e)) { | ||
tries++; | ||
this.parent.jitterSleep(tries); | ||
continue; | ||
} | ||
throw Plumbing.convertExceptionToPorcelain(e); | ||
} | ||
break; | ||
} | ||
return Plumbing.convertSecretStoreHealthcheckResponseToPorcelain(plumbingResponse); | ||
} | ||
} |
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
Oops, something went wrong.