Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: In Secret Manager, users can now use filter to customize the ou…
…tput of ListSecrets/ListSecretVersions calls (#544)

PiperOrigin-RevId: 387156636

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Jul 27 11:29:48 2021 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 2948f31dd210514f87ce6e1e08bce48ecf4660d1
Source-Link: googleapis/googleapis@2948f31

Co-authored-by: Neenu Shaji <Neenu1995@users.noreply.github.com>
  • Loading branch information
yoshi-automation and Neenu1995 committed Aug 10, 2021
1 parent ed61ecb commit bd2d8b3
Show file tree
Hide file tree
Showing 8 changed files with 625 additions and 124 deletions.
Expand Up @@ -235,6 +235,7 @@ public final ListSecretsPagedResponse listSecrets(String parent) {
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* for (Secret element : secretManagerServiceClient.listSecrets(request).iterateAll()) {
* // doThingsWith(element);
Expand Down Expand Up @@ -263,6 +264,7 @@ public final ListSecretsPagedResponse listSecrets(ListSecretsRequest request) {
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* ApiFuture<Secret> future =
* secretManagerServiceClient.listSecretsPagedCallable().futureCall(request);
Expand Down Expand Up @@ -292,6 +294,7 @@ public final ListSecretsPagedResponse listSecrets(ListSecretsRequest request) {
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* while (true) {
* ListSecretsResponse response =
Expand Down Expand Up @@ -896,6 +899,7 @@ public final ListSecretVersionsPagedResponse listSecretVersions(String parent) {
* .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* for (SecretVersion element :
* secretManagerServiceClient.listSecretVersions(request).iterateAll()) {
Expand Down Expand Up @@ -927,6 +931,7 @@ public final ListSecretVersionsPagedResponse listSecretVersions(
* .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* ApiFuture<SecretVersion> future =
* secretManagerServiceClient.listSecretVersionsPagedCallable().futureCall(request);
Expand Down Expand Up @@ -957,6 +962,7 @@ public final ListSecretVersionsPagedResponse listSecretVersions(
* .setParent(SecretName.of("[PROJECT]", "[SECRET]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setFilter("filter-1274492040")
* .build();
* while (true) {
* ListSecretVersionsResponse response =
Expand Down
Expand Up @@ -40,6 +40,7 @@ private ListSecretVersionsRequest(com.google.protobuf.GeneratedMessageV3.Builder
private ListSecretVersionsRequest() {
parent_ = "";
pageToken_ = "";
filter_ = "";
}

@java.lang.Override
Expand Down Expand Up @@ -90,6 +91,13 @@ private ListSecretVersionsRequest(
pageToken_ = s;
break;
}
case 34:
{
java.lang.String s = input.readStringRequireUtf8();

filter_ = s;
break;
}
default:
{
if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
Expand Down Expand Up @@ -252,6 +260,63 @@ public com.google.protobuf.ByteString getPageTokenBytes() {
}
}

public static final int FILTER_FIELD_NUMBER = 4;
private volatile java.lang.Object filter_;
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The filter.
*/
@java.lang.Override
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
filter_ = s;
return s;
}
}
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for filter.
*/
@java.lang.Override
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}

private byte memoizedIsInitialized = -1;

@java.lang.Override
Expand All @@ -275,6 +340,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io
if (!getPageTokenBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_);
}
if (!getFilterBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, filter_);
}
unknownFields.writeTo(output);
}

Expand All @@ -293,6 +361,9 @@ public int getSerializedSize() {
if (!getPageTokenBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_);
}
if (!getFilterBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, filter_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
Expand All @@ -312,6 +383,7 @@ public boolean equals(final java.lang.Object obj) {
if (!getParent().equals(other.getParent())) return false;
if (getPageSize() != other.getPageSize()) return false;
if (!getPageToken().equals(other.getPageToken())) return false;
if (!getFilter().equals(other.getFilter())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
Expand All @@ -329,6 +401,8 @@ public int hashCode() {
hash = (53 * hash) + getPageSize();
hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER;
hash = (53 * hash) + getPageToken().hashCode();
hash = (37 * hash) + FILTER_FIELD_NUMBER;
hash = (53 * hash) + getFilter().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
Expand Down Expand Up @@ -481,6 +555,8 @@ public Builder clear() {

pageToken_ = "";

filter_ = "";

return this;
}

Expand Down Expand Up @@ -511,6 +587,7 @@ public com.google.cloud.secretmanager.v1.ListSecretVersionsRequest buildPartial(
result.parent_ = parent_;
result.pageSize_ = pageSize_;
result.pageToken_ = pageToken_;
result.filter_ = filter_;
onBuilt();
return result;
}
Expand Down Expand Up @@ -572,6 +649,10 @@ public Builder mergeFrom(com.google.cloud.secretmanager.v1.ListSecretVersionsReq
pageToken_ = other.pageToken_;
onChanged();
}
if (!other.getFilter().isEmpty()) {
filter_ = other.filter_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
Expand Down Expand Up @@ -897,6 +978,132 @@ public Builder setPageTokenBytes(com.google.protobuf.ByteString value) {
return this;
}

private java.lang.Object filter_ = "";
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The filter.
*/
public java.lang.String getFilter() {
java.lang.Object ref = filter_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
filter_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for filter.
*/
public com.google.protobuf.ByteString getFilterBytes() {
java.lang.Object ref = filter_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
filter_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The filter to set.
* @return This builder for chaining.
*/
public Builder setFilter(java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}

filter_ = value;
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return This builder for chaining.
*/
public Builder clearFilter() {

filter_ = getDefaultInstance().getFilter();
onChanged();
return this;
}
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @param value The bytes for filter to set.
* @return This builder for chaining.
*/
public Builder setFilterBytes(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);

filter_ = value;
onChanged();
return this;
}

@java.lang.Override
public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
Expand Down
Expand Up @@ -97,4 +97,37 @@ public interface ListSecretVersionsRequestOrBuilder
* @return The bytes for pageToken.
*/
com.google.protobuf.ByteString getPageTokenBytes();

/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The filter.
*/
java.lang.String getFilter();
/**
*
*
* <pre>
* Optional. Filter string, adhering to the rules in
* [List-operation
* filtering](https://cloud.google.com/secret-manager/docs/filtering). List
* only secret versions matching the filter. If filter is empty, all secret
* versions are listed.
* </pre>
*
* <code>string filter = 4 [(.google.api.field_behavior) = OPTIONAL];</code>
*
* @return The bytes for filter.
*/
com.google.protobuf.ByteString getFilterBytes();
}

0 comments on commit bd2d8b3

Please sign in to comment.