From d5f88f6c8c0b182170c405ccaa8f6159fecb4a86 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 27 Apr 2020 14:54:43 -0700 Subject: [PATCH] feat!: remove legacy resource name (#125) * chore: Update gapic-generator version The updated version is required to migrate Python clients generation from artman to bazel. PiperOrigin-RevId: 307739946 Source-Author: Google APIs Source-Date: Tue Apr 21 21:16:30 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 862cd840dbb0101a0630913217bf8b6d4101c84c Source-Link: https://github.com/googleapis/googleapis/commit/862cd840dbb0101a0630913217bf8b6d4101c84c * chore: allow breaking resource name changes * chore: remove legacy resource name types Co-authored-by: Jeff Ching --- .../v1/SecurityCenterClientTest.java | 3 +- .../v1p1beta1/SecurityCenterClientTest.java | 6 +- .../clirr-ignored-differences.xml | 46 +++- .../v1/AssetSecurityMarksName.java | 187 --------------- .../v1/FindingSecurityMarksName.java | 215 ------------------ .../securitycenter/v1/SecurityMarksName.java | 70 +++--- .../securitycenter/v1/SecurityMarksNames.java | 38 ---- .../v1/UntypedSecurityMarksName.java | 106 --------- .../clirr-ignored-differences.xml | 6 +- .../v1p1beta1/SecurityMarksName.java | 70 +++--- synth.metadata | 12 +- 11 files changed, 140 insertions(+), 619 deletions(-) delete mode 100644 proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/AssetSecurityMarksName.java delete mode 100644 proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingSecurityMarksName.java delete mode 100644 proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksNames.java delete mode 100644 proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/UntypedSecurityMarksName.java diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientTest.java index 9a4e263cc..121b481ac 100644 --- a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientTest.java +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientTest.java @@ -1285,7 +1285,8 @@ public void updateSourceExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void updateSecurityMarksTest() { - SecurityMarksName name = SecurityMarksName.ofOrganizationAssetName("[ORGANIZATION]", "[ASSET]"); + SecurityMarksName name = + SecurityMarksName.ofOrganizationAssetSecurityMarksName("[ORGANIZATION]", "[ASSET]"); SecurityMarks expectedResponse = SecurityMarks.newBuilder().setName(name.toString()).build(); mockSecurityCenter.addResponse(expectedResponse); diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientTest.java index 0824cc91b..c752f1cca 100644 --- a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientTest.java +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientTest.java @@ -1374,7 +1374,8 @@ public void updateSourceExceptionTest2() throws Exception { @Test @SuppressWarnings("all") public void updateSecurityMarksTest() { - SecurityMarksName name = SecurityMarksName.ofOrganizationAssetName("[ORGANIZATION]", "[ASSET]"); + SecurityMarksName name = + SecurityMarksName.ofOrganizationAssetSecurityMarksName("[ORGANIZATION]", "[ASSET]"); SecurityMarks expectedResponse = SecurityMarks.newBuilder().setName(name.toString()).build(); mockSecurityCenter.addResponse(expectedResponse); @@ -1413,7 +1414,8 @@ public void updateSecurityMarksExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void updateSecurityMarksTest2() { - SecurityMarksName name = SecurityMarksName.ofOrganizationAssetName("[ORGANIZATION]", "[ASSET]"); + SecurityMarksName name = + SecurityMarksName.ofOrganizationAssetSecurityMarksName("[ORGANIZATION]", "[ASSET]"); SecurityMarks expectedResponse = SecurityMarks.newBuilder().setName(name.toString()).build(); mockSecurityCenter.addResponse(expectedResponse); diff --git a/proto-google-cloud-securitycenter-v1/clirr-ignored-differences.xml b/proto-google-cloud-securitycenter-v1/clirr-ignored-differences.xml index d1cd44c13..4bf2ff5e8 100644 --- a/proto-google-cloud-securitycenter-v1/clirr-ignored-differences.xml +++ b/proto-google-cloud-securitycenter-v1/clirr-ignored-differences.xml @@ -17,15 +17,55 @@ boolean has*(*) - + 7002 com/google/cloud/securitycenter/v1/SecurityMarksName - java.util.List parse(java.util.List) + java.lang.String formatOrganizationAssetName(java.lang.String, java.lang.String) 7002 com/google/cloud/securitycenter/v1/SecurityMarksName - java.util.List toStrings(java.util.List) + java.lang.String formatOrganizationSourceFindingName(java.lang.String, java.lang.String, java.lang.String) + + + 7002 + com/google/cloud/securitycenter/v1/SecurityMarksName + com.google.cloud.securitycenter.v1.SecurityMarksName$Builder newOrganizationAssetBuilder() + + + 7002 + com/google/cloud/securitycenter/v1/SecurityMarksName + com.google.cloud.securitycenter.v1.SecurityMarksName$OrganizationSourceFindingBuilder newOrganizationSourceFindingBuilder() + + + 7002 + com/google/cloud/securitycenter/v1/SecurityMarksName + com.google.cloud.securitycenter.v1.SecurityMarksName ofOrganizationAssetName(java.lang.String, java.lang.String) + + + 7002 + com/google/cloud/securitycenter/v1/SecurityMarksName + com.google.cloud.securitycenter.v1.SecurityMarksName ofOrganizationSourceFindingName(java.lang.String, java.lang.String, java.lang.String) + + + 8001 + com/google/cloud/securitycenter/v1/SecurityMarksName$OrganizationSourceFindingBuilder + + + 8001 + com/google/cloud/securitycenter/v1/AssetSecurityMarksName* + + + 8001 + com/google/cloud/securitycenter/v1/FindingSecurityMarksName* + + + 8001 + com/google/cloud/securitycenter/v1/SecurityMarksNames + + + 8001 + com/google/cloud/securitycenter/v1/UntypedSecurityMarksName diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/AssetSecurityMarksName.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/AssetSecurityMarksName.java deleted file mode 100644 index e09f9a2ca..000000000 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/AssetSecurityMarksName.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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 - * - * https://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. - */ - -package com.google.cloud.securitycenter.v1; - -import com.google.api.pathtemplate.PathTemplate; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * AUTO-GENERATED DOCUMENTATION AND CLASS - * - * @deprecated This resource name class will be removed in the next major version. - */ -@javax.annotation.Generated("by GAPIC protoc plugin") -@Deprecated -public class AssetSecurityMarksName extends SecurityMarksName { - - private static final PathTemplate PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "organizations/{organization}/assets/{asset}/securityMarks"); - - private volatile Map fieldValuesMap; - - private final String organization; - private final String asset; - - public String getOrganization() { - return organization; - } - - public String getAsset() { - return asset; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - private AssetSecurityMarksName(Builder builder) { - organization = Preconditions.checkNotNull(builder.getOrganization()); - asset = Preconditions.checkNotNull(builder.getAsset()); - } - - public static AssetSecurityMarksName of(String organization, String asset) { - return newBuilder().setOrganization(organization).setAsset(asset).build(); - } - - public static String format(String organization, String asset) { - return newBuilder().setOrganization(organization).setAsset(asset).build().toString(); - } - - public static AssetSecurityMarksName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - PATH_TEMPLATE.validatedMatch( - formattedString, "AssetSecurityMarksName.parse: formattedString not in valid format"); - return of(matchMap.get("organization"), matchMap.get("asset")); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList(values.size()); - for (AssetSecurityMarksName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); - } - - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("organization", organization); - fieldMapBuilder.put("asset", asset); - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return PATH_TEMPLATE.instantiate("organization", organization, "asset", asset); - } - - /** Builder for AssetSecurityMarksName. */ - public static class Builder extends SecurityMarksName.Builder { - - private String organization; - private String asset; - - public String getOrganization() { - return organization; - } - - public String getAsset() { - return asset; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setAsset(String asset) { - this.asset = asset; - return this; - } - - private Builder() {} - - private Builder(AssetSecurityMarksName assetSecurityMarksName) { - organization = assetSecurityMarksName.organization; - asset = assetSecurityMarksName.asset; - } - - public AssetSecurityMarksName build() { - return new AssetSecurityMarksName(this); - } - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AssetSecurityMarksName) { - AssetSecurityMarksName that = (AssetSecurityMarksName) o; - return (this.organization.equals(that.organization)) && (this.asset.equals(that.asset)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= organization.hashCode(); - h *= 1000003; - h ^= asset.hashCode(); - return h; - } -} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingSecurityMarksName.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingSecurityMarksName.java deleted file mode 100644 index 7bda84131..000000000 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingSecurityMarksName.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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 - * - * https://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. - */ - -package com.google.cloud.securitycenter.v1; - -import com.google.api.pathtemplate.PathTemplate; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * AUTO-GENERATED DOCUMENTATION AND CLASS - * - * @deprecated This resource name class will be removed in the next major version. - */ -@javax.annotation.Generated("by GAPIC protoc plugin") -@Deprecated -public class FindingSecurityMarksName extends SecurityMarksName { - - private static final PathTemplate PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "organizations/{organization}/sources/{source}/findings/{finding}/securityMarks"); - - private volatile Map fieldValuesMap; - - private final String organization; - private final String source; - private final String finding; - - public String getOrganization() { - return organization; - } - - public String getSource() { - return source; - } - - public String getFinding() { - return finding; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - private FindingSecurityMarksName(Builder builder) { - organization = Preconditions.checkNotNull(builder.getOrganization()); - source = Preconditions.checkNotNull(builder.getSource()); - finding = Preconditions.checkNotNull(builder.getFinding()); - } - - public static FindingSecurityMarksName of(String organization, String source, String finding) { - return newBuilder().setOrganization(organization).setSource(source).setFinding(finding).build(); - } - - public static String format(String organization, String source, String finding) { - return newBuilder() - .setOrganization(organization) - .setSource(source) - .setFinding(finding) - .build() - .toString(); - } - - public static FindingSecurityMarksName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - PATH_TEMPLATE.validatedMatch( - formattedString, "FindingSecurityMarksName.parse: formattedString not in valid format"); - return of(matchMap.get("organization"), matchMap.get("source"), matchMap.get("finding")); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList(values.size()); - for (FindingSecurityMarksName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); - } - - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("organization", organization); - fieldMapBuilder.put("source", source); - fieldMapBuilder.put("finding", finding); - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return PATH_TEMPLATE.instantiate( - "organization", organization, "source", source, "finding", finding); - } - - /** Builder for FindingSecurityMarksName. */ - public static class Builder extends SecurityMarksName.Builder { - - private String organization; - private String source; - private String finding; - - public String getOrganization() { - return organization; - } - - public String getSource() { - return source; - } - - public String getFinding() { - return finding; - } - - public Builder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public Builder setSource(String source) { - this.source = source; - return this; - } - - public Builder setFinding(String finding) { - this.finding = finding; - return this; - } - - private Builder() {} - - private Builder(FindingSecurityMarksName findingSecurityMarksName) { - organization = findingSecurityMarksName.organization; - source = findingSecurityMarksName.source; - finding = findingSecurityMarksName.finding; - } - - public FindingSecurityMarksName build() { - return new FindingSecurityMarksName(this); - } - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FindingSecurityMarksName) { - FindingSecurityMarksName that = (FindingSecurityMarksName) o; - return (this.organization.equals(that.organization)) - && (this.source.equals(that.source)) - && (this.finding.equals(that.finding)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= organization.hashCode(); - h *= 1000003; - h ^= source.hashCode(); - h *= 1000003; - h ^= finding.hashCode(); - return h; - } -} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksName.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksName.java index 8ba67f567..0a39cf715 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksName.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksName.java @@ -32,10 +32,10 @@ public class SecurityMarksName implements ResourceName { @Deprecated protected SecurityMarksName() {} - private static final PathTemplate ORGANIZATION_ASSET_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/assets/{asset}/securityMarks"); - private static final PathTemplate ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/sources/{source}/findings/{finding}/securityMarks"); @@ -67,14 +67,14 @@ public String getFinding() { private SecurityMarksName(Builder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); asset = Preconditions.checkNotNull(builder.getAsset()); - pathTemplate = ORGANIZATION_ASSET_PATH_TEMPLATE; + pathTemplate = ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE; } - private SecurityMarksName(OrganizationSourceFindingBuilder builder) { + private SecurityMarksName(OrganizationSourceFindingSecurityMarksBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); source = Preconditions.checkNotNull(builder.getSource()); finding = Preconditions.checkNotNull(builder.getFinding()); - pathTemplate = ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE; + pathTemplate = ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE; } public static Builder newBuilder() { @@ -82,13 +82,14 @@ public static Builder newBuilder() { } @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static Builder newOrganizationAssetBuilder() { + public static Builder newOrganizationAssetSecurityMarksBuilder() { return new Builder(); } @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static OrganizationSourceFindingBuilder newOrganizationSourceFindingBuilder() { - return new OrganizationSourceFindingBuilder(); + public static OrganizationSourceFindingSecurityMarksBuilder + newOrganizationSourceFindingSecurityMarksBuilder() { + return new OrganizationSourceFindingSecurityMarksBuilder(); } public Builder toBuilder() { @@ -96,18 +97,25 @@ public Builder toBuilder() { } public static SecurityMarksName of(String organization, String asset) { - return newOrganizationAssetBuilder().setOrganization(organization).setAsset(asset).build(); + return newOrganizationAssetSecurityMarksBuilder() + .setOrganization(organization) + .setAsset(asset) + .build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static SecurityMarksName ofOrganizationAssetName(String organization, String asset) { - return newOrganizationAssetBuilder().setOrganization(organization).setAsset(asset).build(); + public static SecurityMarksName ofOrganizationAssetSecurityMarksName( + String organization, String asset) { + return newOrganizationAssetSecurityMarksBuilder() + .setOrganization(organization) + .setAsset(asset) + .build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static SecurityMarksName ofOrganizationSourceFindingName( + public static SecurityMarksName ofOrganizationSourceFindingSecurityMarksName( String organization, String source, String finding) { - return newOrganizationSourceFindingBuilder() + return newOrganizationSourceFindingSecurityMarksBuilder() .setOrganization(organization) .setSource(source) .setFinding(finding) @@ -119,14 +127,14 @@ public static String format(String organization, String asset) { } @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatOrganizationAssetName(String organization, String asset) { + public static String formatOrganizationAssetSecurityMarksName(String organization, String asset) { return newBuilder().setOrganization(organization).setAsset(asset).build().toString(); } @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatOrganizationSourceFindingName( + public static String formatOrganizationSourceFindingSecurityMarksName( String organization, String source, String finding) { - return newOrganizationSourceFindingBuilder() + return newOrganizationSourceFindingSecurityMarksBuilder() .setOrganization(organization) .setSource(source) .setFinding(finding) @@ -138,21 +146,23 @@ public static SecurityMarksName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (ORGANIZATION_ASSET_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = ORGANIZATION_ASSET_PATH_TEMPLATE.match(formattedString); - return ofOrganizationAssetName(matchMap.get("organization"), matchMap.get("asset")); - } else if (ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.matches(formattedString)) { + if (ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString)) { + Map matchMap = + ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.match(formattedString); + return ofOrganizationAssetSecurityMarksName( + matchMap.get("organization"), matchMap.get("asset")); + } else if (ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString)) { Map matchMap = - ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.match(formattedString); - return ofOrganizationSourceFindingName( + ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.match(formattedString); + return ofOrganizationSourceFindingSecurityMarksName( matchMap.get("organization"), matchMap.get("source"), matchMap.get("finding")); } throw new ValidationException("JobName.parse: formattedString not in valid format"); } public static boolean isParsableFrom(String formattedString) { - return ORGANIZATION_ASSET_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.matches(formattedString); + return ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString) + || ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString); } @Override @@ -217,7 +227,7 @@ public Builder setAsset(String asset) { private Builder(SecurityMarksName securityMarksName) { Preconditions.checkArgument( - securityMarksName.pathTemplate == ORGANIZATION_ASSET_PATH_TEMPLATE, + securityMarksName.pathTemplate == ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE, "toBuilder is only supported when SecurityMarksName has the pattern of " + "organizations/{organization}/assets/{asset}/securityMarks."); organization = securityMarksName.organization; @@ -231,13 +241,13 @@ public SecurityMarksName build() { /** Builder for organizations/{organization}/sources/{source}/findings/{finding}/securityMarks. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static class OrganizationSourceFindingBuilder { + public static class OrganizationSourceFindingSecurityMarksBuilder { private String organization; private String source; private String finding; - private OrganizationSourceFindingBuilder() {} + private OrganizationSourceFindingSecurityMarksBuilder() {} public String getOrganization() { return organization; @@ -251,17 +261,17 @@ public String getFinding() { return finding; } - public OrganizationSourceFindingBuilder setOrganization(String organization) { + public OrganizationSourceFindingSecurityMarksBuilder setOrganization(String organization) { this.organization = organization; return this; } - public OrganizationSourceFindingBuilder setSource(String source) { + public OrganizationSourceFindingSecurityMarksBuilder setSource(String source) { this.source = source; return this; } - public OrganizationSourceFindingBuilder setFinding(String finding) { + public OrganizationSourceFindingSecurityMarksBuilder setFinding(String finding) { this.finding = finding; return this; } diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksNames.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksNames.java deleted file mode 100644 index 6f82499af..000000000 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/SecurityMarksNames.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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 - * - * https://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. - */ - -package com.google.cloud.securitycenter.v1; - -/** - * AUTO-GENERATED DOCUMENTATION AND CLASS - * - * @deprecated This resource name class will be removed in the next major version. - */ -@javax.annotation.Generated("by GAPIC protoc plugin") -@Deprecated -public class SecurityMarksNames { - private SecurityMarksNames() {} - - public static SecurityMarksName parse(String resourceNameString) { - if (AssetSecurityMarksName.isParsableFrom(resourceNameString)) { - return AssetSecurityMarksName.parse(resourceNameString); - } - if (FindingSecurityMarksName.isParsableFrom(resourceNameString)) { - return FindingSecurityMarksName.parse(resourceNameString); - } - return UntypedSecurityMarksName.parse(resourceNameString); - } -} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/UntypedSecurityMarksName.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/UntypedSecurityMarksName.java deleted file mode 100644 index a3233a065..000000000 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/UntypedSecurityMarksName.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2020 Google LLC - * - * 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 - * - * https://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. - */ - -package com.google.cloud.securitycenter.v1; - -import com.google.api.resourcenames.ResourceName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * AUTO-GENERATED DOCUMENTATION AND CLASS - * - * @deprecated This resource name class will be removed in the next major version. - */ -@javax.annotation.Generated("by GAPIC protoc plugin") -@Deprecated -public class UntypedSecurityMarksName extends SecurityMarksName { - - private final String rawValue; - private Map valueMap; - - private UntypedSecurityMarksName(String rawValue) { - this.rawValue = Preconditions.checkNotNull(rawValue); - this.valueMap = ImmutableMap.of("", rawValue); - } - - public static UntypedSecurityMarksName from(ResourceName resourceName) { - return new UntypedSecurityMarksName(resourceName.toString()); - } - - public static UntypedSecurityMarksName parse(String formattedString) { - return new UntypedSecurityMarksName(formattedString); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList(values.size()); - for (UntypedSecurityMarksName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return true; - } - - /** Return a map with a single value rawValue keyed on an empty String "". */ - public Map getFieldValuesMap() { - return valueMap; - } - - /** Return the initial rawValue if @param fieldName is an empty String, else return null. */ - public String getFieldValue(String fieldName) { - return valueMap.get(fieldName); - } - - @Override - public String toString() { - return rawValue; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UntypedSecurityMarksName) { - UntypedSecurityMarksName that = (UntypedSecurityMarksName) o; - return this.rawValue.equals(that.rawValue); - } - return false; - } - - @Override - public int hashCode() { - return rawValue.hashCode(); - } -} diff --git a/proto-google-cloud-securitycenter-v1p1beta1/clirr-ignored-differences.xml b/proto-google-cloud-securitycenter-v1p1beta1/clirr-ignored-differences.xml index fa5f0a2a7..c5baf1f61 100644 --- a/proto-google-cloud-securitycenter-v1p1beta1/clirr-ignored-differences.xml +++ b/proto-google-cloud-securitycenter-v1p1beta1/clirr-ignored-differences.xml @@ -17,7 +17,7 @@ boolean has*(*) - + 7002 com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName @@ -31,4 +31,8 @@ 8001 com/google/cloud/securitycenter/v1p1beta1/UntypedSecurityMarksName + + 8001 + com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName$OrganizationSourceFindingBuilder + diff --git a/proto-google-cloud-securitycenter-v1p1beta1/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName.java b/proto-google-cloud-securitycenter-v1p1beta1/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName.java index 967432d30..6d7b62b14 100644 --- a/proto-google-cloud-securitycenter-v1p1beta1/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName.java +++ b/proto-google-cloud-securitycenter-v1p1beta1/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityMarksName.java @@ -34,10 +34,10 @@ public class SecurityMarksName implements ResourceName { @Deprecated protected SecurityMarksName() {} - private static final PathTemplate ORGANIZATION_ASSET_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/assets/{asset}/securityMarks"); - private static final PathTemplate ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/sources/{source}/findings/{finding}/securityMarks"); @@ -69,14 +69,14 @@ public String getFinding() { private SecurityMarksName(Builder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); asset = Preconditions.checkNotNull(builder.getAsset()); - pathTemplate = ORGANIZATION_ASSET_PATH_TEMPLATE; + pathTemplate = ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE; } - private SecurityMarksName(OrganizationSourceFindingBuilder builder) { + private SecurityMarksName(OrganizationSourceFindingSecurityMarksBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); source = Preconditions.checkNotNull(builder.getSource()); finding = Preconditions.checkNotNull(builder.getFinding()); - pathTemplate = ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE; + pathTemplate = ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE; } public static Builder newBuilder() { @@ -84,13 +84,14 @@ public static Builder newBuilder() { } @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static Builder newOrganizationAssetBuilder() { + public static Builder newOrganizationAssetSecurityMarksBuilder() { return new Builder(); } @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static OrganizationSourceFindingBuilder newOrganizationSourceFindingBuilder() { - return new OrganizationSourceFindingBuilder(); + public static OrganizationSourceFindingSecurityMarksBuilder + newOrganizationSourceFindingSecurityMarksBuilder() { + return new OrganizationSourceFindingSecurityMarksBuilder(); } public Builder toBuilder() { @@ -98,18 +99,25 @@ public Builder toBuilder() { } public static SecurityMarksName of(String organization, String asset) { - return newOrganizationAssetBuilder().setOrganization(organization).setAsset(asset).build(); + return newOrganizationAssetSecurityMarksBuilder() + .setOrganization(organization) + .setAsset(asset) + .build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static SecurityMarksName ofOrganizationAssetName(String organization, String asset) { - return newOrganizationAssetBuilder().setOrganization(organization).setAsset(asset).build(); + public static SecurityMarksName ofOrganizationAssetSecurityMarksName( + String organization, String asset) { + return newOrganizationAssetSecurityMarksBuilder() + .setOrganization(organization) + .setAsset(asset) + .build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static SecurityMarksName ofOrganizationSourceFindingName( + public static SecurityMarksName ofOrganizationSourceFindingSecurityMarksName( String organization, String source, String finding) { - return newOrganizationSourceFindingBuilder() + return newOrganizationSourceFindingSecurityMarksBuilder() .setOrganization(organization) .setSource(source) .setFinding(finding) @@ -121,14 +129,14 @@ public static String format(String organization, String asset) { } @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatOrganizationAssetName(String organization, String asset) { + public static String formatOrganizationAssetSecurityMarksName(String organization, String asset) { return newBuilder().setOrganization(organization).setAsset(asset).build().toString(); } @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatOrganizationSourceFindingName( + public static String formatOrganizationSourceFindingSecurityMarksName( String organization, String source, String finding) { - return newOrganizationSourceFindingBuilder() + return newOrganizationSourceFindingSecurityMarksBuilder() .setOrganization(organization) .setSource(source) .setFinding(finding) @@ -140,13 +148,15 @@ public static SecurityMarksName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (ORGANIZATION_ASSET_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = ORGANIZATION_ASSET_PATH_TEMPLATE.match(formattedString); - return ofOrganizationAssetName(matchMap.get("organization"), matchMap.get("asset")); - } else if (ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.matches(formattedString)) { + if (ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString)) { + Map matchMap = + ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.match(formattedString); + return ofOrganizationAssetSecurityMarksName( + matchMap.get("organization"), matchMap.get("asset")); + } else if (ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString)) { Map matchMap = - ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.match(formattedString); - return ofOrganizationSourceFindingName( + ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.match(formattedString); + return ofOrganizationSourceFindingSecurityMarksName( matchMap.get("organization"), matchMap.get("source"), matchMap.get("finding")); } throw new ValidationException("JobName.parse: formattedString not in valid format"); @@ -173,8 +183,8 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return ORGANIZATION_ASSET_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_SOURCE_FINDING_PATH_TEMPLATE.matches(formattedString); + return ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString) + || ORGANIZATION_SOURCE_FINDING_SECURITY_MARKS_PATH_TEMPLATE.matches(formattedString); } @Override @@ -239,7 +249,7 @@ public Builder setAsset(String asset) { private Builder(SecurityMarksName securityMarksName) { Preconditions.checkArgument( - securityMarksName.pathTemplate == ORGANIZATION_ASSET_PATH_TEMPLATE, + securityMarksName.pathTemplate == ORGANIZATION_ASSET_SECURITY_MARKS_PATH_TEMPLATE, "toBuilder is only supported when SecurityMarksName has the pattern of " + "organizations/{organization}/assets/{asset}/securityMarks."); organization = securityMarksName.organization; @@ -253,13 +263,13 @@ public SecurityMarksName build() { /** Builder for organizations/{organization}/sources/{source}/findings/{finding}/securityMarks. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static class OrganizationSourceFindingBuilder { + public static class OrganizationSourceFindingSecurityMarksBuilder { private String organization; private String source; private String finding; - private OrganizationSourceFindingBuilder() {} + private OrganizationSourceFindingSecurityMarksBuilder() {} public String getOrganization() { return organization; @@ -273,17 +283,17 @@ public String getFinding() { return finding; } - public OrganizationSourceFindingBuilder setOrganization(String organization) { + public OrganizationSourceFindingSecurityMarksBuilder setOrganization(String organization) { this.organization = organization; return this; } - public OrganizationSourceFindingBuilder setSource(String source) { + public OrganizationSourceFindingSecurityMarksBuilder setSource(String source) { this.source = source; return this; } - public OrganizationSourceFindingBuilder setFinding(String finding) { + public OrganizationSourceFindingSecurityMarksBuilder setFinding(String finding) { this.finding = finding; return this; } diff --git a/synth.metadata b/synth.metadata index 67dc92bcf..4a2f36c12 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,24 +11,24 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ee4ea76504aa60c2bff9b7c11269c155d8c21e0d", - "internalRef": "305619145" + "sha": "862cd840dbb0101a0630913217bf8b6d4101c84c", + "internalRef": "307739946" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ee4ea76504aa60c2bff9b7c11269c155d8c21e0d", - "internalRef": "305619145" + "sha": "862cd840dbb0101a0630913217bf8b6d4101c84c", + "internalRef": "307739946" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ee4ea76504aa60c2bff9b7c11269c155d8c21e0d", - "internalRef": "305619145" + "sha": "862cd840dbb0101a0630913217bf8b6d4101c84c", + "internalRef": "307739946" } }, {