-
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
30a393f
commit 0651527
Showing
10 changed files
with
4,453 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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; | ||
|
||
/** | ||
* AccountResourceHistory records the state of a AccountResource at a given point in time, where | ||
* every change (create or delete) to a AccountResource produces an AccountResourceHistory record. | ||
*/ | ||
public class AccountResourceHistory { | ||
private AccountResource accountResource; | ||
/** The complete AccountResource state at this time. */ | ||
public AccountResource getAccountResource() { | ||
return this.accountResource; | ||
} | ||
/** The complete AccountResource state at this time. */ | ||
public void setAccountResource(AccountResource in) { | ||
this.accountResource = in; | ||
} | ||
|
||
private String activityId; | ||
/** | ||
* The unique identifier of the Activity that produced this change to the AccountResource. May be | ||
* empty for some system-initiated updates. | ||
*/ | ||
public String getActivityId() { | ||
return this.activityId; | ||
} | ||
/** | ||
* The unique identifier of the Activity that produced this change to the AccountResource. May be | ||
* empty for some system-initiated updates. | ||
*/ | ||
public void setActivityId(String in) { | ||
this.activityId = in; | ||
} | ||
|
||
private Date deletedAt; | ||
/** If this AccountResource was deleted, the time it was deleted. */ | ||
public Date getDeletedAt() { | ||
return this.deletedAt; | ||
} | ||
/** If this AccountResource was deleted, the time it was deleted. */ | ||
public void setDeletedAt(Date in) { | ||
this.deletedAt = in; | ||
} | ||
|
||
private Date timestamp; | ||
/** The time at which the AccountResource state was recorded. */ | ||
public Date getTimestamp() { | ||
return this.timestamp; | ||
} | ||
/** The time at which the AccountResource state was recorded. */ | ||
public void setTimestamp(Date in) { | ||
this.timestamp = 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,111 @@ | ||
// 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.AccountResourcesHistoryGrpc; | ||
import com.strongdm.api.plumbing.AccountResourcesHistoryPlumbing; | ||
import com.strongdm.api.plumbing.PageIterator; | ||
import com.strongdm.api.plumbing.PageResult; | ||
import com.strongdm.api.plumbing.Plumbing; | ||
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; | ||
|
||
/** AccountResourcesHistory records all changes to the state of a AccountResource. */ | ||
public class AccountResourcesHistory { | ||
private final AccountResourcesHistoryGrpc.AccountResourcesHistoryBlockingStub stub; | ||
private final Client parent; | ||
|
||
public AccountResourcesHistory(ManagedChannel channel, Client client) { | ||
|
||
this.stub = AccountResourcesHistoryGrpc.newBlockingStub(channel); | ||
this.parent = client; | ||
} | ||
|
||
private AccountResourcesHistory( | ||
AccountResourcesHistoryGrpc.AccountResourcesHistoryBlockingStub stub, Client client) { | ||
this.stub = stub; | ||
this.parent = client; | ||
} | ||
|
||
/** | ||
* This function returns a copy of the AccountResourcesHistory service which has the given | ||
* deadline set for all method calls. | ||
*/ | ||
public AccountResourcesHistory withDeadlineAfter(long duration, TimeUnit units) { | ||
return new AccountResourcesHistory(this.stub.withDeadlineAfter(duration, units), this.parent); | ||
} | ||
/** List gets a list of AccountResourceHistory records matching a given set of criteria. */ | ||
public Iterable<AccountResourceHistory> list(String filter, Object... args) throws RpcException { | ||
AccountResourcesHistoryPlumbing.AccountResourceHistoryListRequest.Builder builder = | ||
AccountResourcesHistoryPlumbing.AccountResourceHistoryListRequest.newBuilder(); | ||
builder.setFilter(Plumbing.quoteFilterArgs(filter, args)); | ||
ListRequestMetadata.Builder metaBuilder = ListRequestMetadata.newBuilder(); | ||
Object pageSizeOption = this.parent.testOptions.get("PageSize"); | ||
if (pageSizeOption instanceof Integer) { | ||
metaBuilder.setLimit((int) pageSizeOption); | ||
} | ||
if (this.parent.snapshotDate != null) { | ||
metaBuilder.setSnapshotAt(Plumbing.convertTimestampToPlumbing(this.parent.snapshotDate)); | ||
} | ||
builder.setMeta(metaBuilder); | ||
|
||
Supplier<PageResult<AccountResourceHistory>> pageFetcher = | ||
() -> { | ||
// Note: this closure captures and reuses the builder to set the next page | ||
AccountResourcesHistoryPlumbing.AccountResourceHistoryListRequest req = builder.build(); | ||
AccountResourcesHistoryPlumbing.AccountResourceHistoryListResponse plumbingResponse; | ||
int tries = 0; | ||
while (true) { | ||
try { | ||
plumbingResponse = | ||
this.stub | ||
.withCallCredentials( | ||
this.parent.getCallCredentials("AccountResourcesHistory.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<AccountResourceHistory> page = | ||
Plumbing.convertRepeatedAccountResourceHistoryToPorcelain( | ||
plumbingResponse.getHistoryList()); | ||
|
||
boolean hasNextCursor = plumbingResponse.getMeta().getNextCursor() != ""; | ||
builder.setMeta( | ||
ListRequestMetadata.newBuilder() | ||
.setCursor(plumbingResponse.getMeta().getNextCursor())); | ||
|
||
return new PageResult<AccountResourceHistory>(page, hasNextCursor); | ||
}; | ||
|
||
Iterator<AccountResourceHistory> iterator = new PageIterator<>(pageFetcher); | ||
|
||
return () -> iterator; | ||
} | ||
} |
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
Oops, something went wrong.