diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a79f06271..a454a61e8 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:2567a120ce90fadb6201999b87d649d9f67459de28815ad239bce9ebfaa18a74 -# created: 2022-05-19T15:12:45.278246753Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index 6b4692334..a3ea4c664 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -16,6 +16,7 @@ docker: image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest" deep-remove-regex: +- "/samples/snippets/generated" - "/grpc-google-.*/src" - "/proto-google-.*/src" - "/google-.*/src" @@ -35,3 +36,5 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-securitycenter-$1/src" - source: "/google/cloud/securitycenter/(v.*)/.*-java/gapic-google-.*/src" dest: "/owl-bot-staging/$1/google-cloud-securitycenter/src" +- source: "/google/cloud/securitycenter/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/$1/samples/snippets/generated" diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d6956..dd5626f32 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,7 +11,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (8) - units (11) - 'Kokoro - Test: Integration' @@ -26,7 +25,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (7) - units (8) - units (11) diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45a..f8f957af1 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f0..1dba8de10 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index dc2ff91b6..7630e1e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## [2.7.0](https://github.com/googleapis/java-securitycenter/compare/v2.6.0...v2.7.0) (2022-07-01) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#849](https://github.com/googleapis/java-securitycenter/issues/849)) ([2eb2edf](https://github.com/googleapis/java-securitycenter/commit/2eb2edfd80ce43e474d4337b06039f0c5bfc89b6)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#853](https://github.com/googleapis/java-securitycenter/issues/853)) ([26d3646](https://github.com/googleapis/java-securitycenter/commit/26d3646ee2c74d81ce8ec4ff071c11ca4140e538)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-bigquery to v2.12.0 ([#836](https://github.com/googleapis/java-securitycenter/issues/836)) ([c8dcabf](https://github.com/googleapis/java-securitycenter/commit/c8dcabf1bb533a78cb887f3d53c4e7b13fc07865)) +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.1 ([#840](https://github.com/googleapis/java-securitycenter/issues/840)) ([d0b018e](https://github.com/googleapis/java-securitycenter/commit/d0b018e2e33adcbdc06df0b4ca9bc59bbba573f9)) +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.3 ([#844](https://github.com/googleapis/java-securitycenter/issues/844)) ([b487515](https://github.com/googleapis/java-securitycenter/commit/b4875153dbfad101fe9d817f0d581dbd114e9b70)) +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.4 ([#847](https://github.com/googleapis/java-securitycenter/issues/847)) ([c1e1204](https://github.com/googleapis/java-securitycenter/commit/c1e120467156c331475d1040f941e25f5e213c7b)) +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([#850](https://github.com/googleapis/java-securitycenter/issues/850)) ([3f37ffc](https://github.com/googleapis/java-securitycenter/commit/3f37ffc482a7943d1f93f6fca05bd7110f245742)) +* update dependency com.google.cloud:google-cloud-pubsub to v1.119.0 ([#841](https://github.com/googleapis/java-securitycenter/issues/841)) ([1898c33](https://github.com/googleapis/java-securitycenter/commit/1898c33042ea4a1da43234a12a80c3301fcf02df)) +* update dependency com.google.cloud:google-cloud-pubsub to v1.119.1 ([#843](https://github.com/googleapis/java-securitycenter/issues/843)) ([23d8b4c](https://github.com/googleapis/java-securitycenter/commit/23d8b4cbd2b5e530986b9b2e10b86df520c15f16)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#848](https://github.com/googleapis/java-securitycenter/issues/848)) ([4b71b62](https://github.com/googleapis/java-securitycenter/commit/4b71b6295e2db4e595e62e734c6bad2aa2ce2c0e)) +* update dependency com.google.protobuf:protobuf-java-util to v3.21.0 ([#837](https://github.com/googleapis/java-securitycenter/issues/837)) ([0bc9294](https://github.com/googleapis/java-securitycenter/commit/0bc9294d4e68595d7c56389eb3d39e243f97b947)) +* update dependency com.google.protobuf:protobuf-java-util to v3.21.1 ([#838](https://github.com/googleapis/java-securitycenter/issues/838)) ([c4f717e](https://github.com/googleapis/java-securitycenter/commit/c4f717eebf0aeff089ff82d1bbcd0c189cd0ae32)) +* update dependency com.google.protobuf:protobuf-java-util to v3.21.2 ([#851](https://github.com/googleapis/java-securitycenter/issues/851)) ([56a566b](https://github.com/googleapis/java-securitycenter/commit/56a566b1fb95f91cf065c301d1a89381135aeafa)) + ## [2.6.0](https://github.com/googleapis/java-securitycenter/compare/v2.5.6...v2.6.0) (2022-05-19) diff --git a/README.md b/README.md index a927ea8f2..5d6cb2f57 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -30,7 +30,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud google-cloud-securitycenter - 2.5.6 + 2.6.0 @@ -52,7 +52,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-securitycenter - 2.5.6 + 2.6.0 ``` @@ -60,20 +60,20 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:25.3.0') +implementation platform('com.google.cloud:libraries-bom:25.4.0') implementation 'com.google.cloud:google-cloud-securitycenter' ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-securitycenter:2.5.6' +implementation 'com.google.cloud:google-cloud-securitycenter:2.6.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-securitycenter" % "2.5.6" +libraryDependencies += "com.google.cloud" % "google-cloud-securitycenter" % "2.6.0" ``` ## Authentication diff --git a/google-cloud-securitycenter-bom/pom.xml b/google-cloud-securitycenter-bom/pom.xml index 3570387cd..899ab4559 100644 --- a/google-cloud-securitycenter-bom/pom.xml +++ b/google-cloud-securitycenter-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-securitycenter-bom - 2.6.0 + 2.7.0 pom com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Cloud Security Command Center BOM @@ -53,37 +53,37 @@ com.google.cloud google-cloud-securitycenter - 2.6.0 + 2.7.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc proto-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 com.google.api.grpc proto-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc proto-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 diff --git a/google-cloud-securitycenter/pom.xml b/google-cloud-securitycenter/pom.xml index 8e08451c8..89432c0c4 100644 --- a/google-cloud-securitycenter/pom.xml +++ b/google-cloud-securitycenter/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-securitycenter - 2.6.0 + 2.7.0 jar Google Cloud Security Command Center https://github.com/googleapis/java-securitycenter @@ -11,7 +11,7 @@ com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 google-cloud-securitycenter @@ -66,6 +66,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -98,12 +102,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java index c2d78dd2d..aba5d6b99 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -37,7 +38,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; @@ -111,13 +111,28 @@ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SecurityCenterSettings securityCenterSettings =
+ *     SecurityCenterSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class SecurityCenterClient implements BackgroundResource { private final SecurityCenterSettings settings; private final SecurityCenterStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of SecurityCenterClient with default settings. */ public static final SecurityCenterClient create() throws IOException { @@ -137,7 +152,6 @@ public static final SecurityCenterClient create(SecurityCenterSettings settings) * Constructs an instance of SecurityCenterClient, using the given stub for making calls. This is * for advanced usage - prefer using create(SecurityCenterSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final SecurityCenterClient create(SecurityCenterStub stub) { return new SecurityCenterClient(stub); } @@ -150,21 +164,23 @@ public static final SecurityCenterClient create(SecurityCenterStub stub) { protected SecurityCenterClient(SecurityCenterSettings settings) throws IOException { this.settings = settings; this.stub = ((SecurityCenterStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected SecurityCenterClient(SecurityCenterStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final SecurityCenterSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub getStub() { return stub; } @@ -173,10 +189,19 @@ public SecurityCenterStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Kicks off an LRO to bulk mute findings for a parent based on a filter. The parent can be either @@ -1407,7 +1432,7 @@ public final UnaryCallable getBigQuery * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * Policy response = securityCenterClient.getIamPolicy(resource); * } * } @@ -1460,7 +1485,8 @@ public final Policy getIamPolicy(String resource) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = securityCenterClient.getIamPolicy(request); @@ -1486,7 +1512,8 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); @@ -2003,7 +2030,7 @@ public final GroupAssetsPagedResponse groupAssets(GroupAssetsRequest request) { * .build(); * while (true) { * GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2231,7 +2258,7 @@ public final GroupFindingsPagedResponse groupFindings(GroupFindingsRequest reque * .build(); * while (true) { * GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2340,7 +2367,7 @@ public final UnaryCallable listAsset * .build(); * while (true) { * ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); - * for (ListAssetsResponse.ListAssetsResult element : response.getResponsesList()) { + * for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2462,7 +2489,8 @@ public final ListFindingsPagedResponse listFindings(ListFindingsRequest request) * .build(); * while (true) { * ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); - * for (ListFindingsResponse.ListFindingsResult element : response.getResponsesList()) { + * for (ListFindingsResponse.ListFindingsResult element : + * response.getListFindingsResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2670,7 +2698,7 @@ public final ListMuteConfigsPagedResponse listMuteConfigs(ListMuteConfigsRequest * while (true) { * ListMuteConfigsResponse response = * securityCenterClient.listMuteConfigsCallable().call(request); - * for (MuteConfig element : response.getResponsesList()) { + * for (MuteConfig element : response.getMuteConfigsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2827,7 +2855,7 @@ public final ListNotificationConfigsPagedResponse listNotificationConfigs( * while (true) { * ListNotificationConfigsResponse response = * securityCenterClient.listNotificationConfigsCallable().call(request); - * for (NotificationConfig element : response.getResponsesList()) { + * for (NotificationConfig element : response.getNotificationConfigsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -3035,7 +3063,7 @@ public final ListSourcesPagedResponse listSources(ListSourcesRequest request) { * .build(); * while (true) { * ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); - * for (Source element : response.getResponsesList()) { + * for (Source element : response.getSourcesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -3460,7 +3488,7 @@ public final UnaryCallable setMuteCallable() { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * Policy policy = Policy.newBuilder().build(); * Policy response = securityCenterClient.setIamPolicy(resource, policy); * } @@ -3523,7 +3551,8 @@ public final Policy setIamPolicy(String resource, Policy policy) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -3550,7 +3579,8 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -3574,7 +3604,7 @@ public final UnaryCallable setIamPolicyCallable() { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * List permissions = new ArrayList<>(); * TestIamPermissionsResponse response = * securityCenterClient.testIamPermissions(resource, permissions); @@ -3644,7 +3674,8 @@ public final TestIamPermissionsResponse testIamPermissions( * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); @@ -3670,7 +3701,8 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = @@ -4899,7 +4931,7 @@ public final ListBigQueryExportsPagedResponse listBigQueryExports( * while (true) { * ListBigQueryExportsResponse response = * securityCenterClient.listBigQueryExportsCallable().call(request); - * for (BigQueryExport element : response.getResponsesList()) { + * for (BigQueryExport element : response.getBigQueryExportsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java index ace062fcf..380ad1d6d 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/SecurityCenterSettings.java @@ -30,6 +30,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -328,11 +329,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SecurityCenterStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SecurityCenterStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SecurityCenterStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SecurityCenterStubSettings.defaultTransportChannelProvider(); } @@ -342,11 +350,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SecurityCenterStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -384,6 +398,11 @@ private static Builder createDefault() { return new Builder(SecurityCenterStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SecurityCenterStubSettings.newHttpJsonBuilder()); + } + public SecurityCenterStubSettings.Builder getStubSettingsBuilder() { return ((SecurityCenterStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterCallableFactory.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000..022ee1219 --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SecurityCenter service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSecurityCenterCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000..e1cb0e6cb --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/HttpJsonSecurityCenterStub.java @@ -0,0 +1,2340 @@ +/* + * Copyright 2022 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.stub; + +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListMuteConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse; +import com.google.cloud.securitycenter.v1.CreateBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1.CreateMuteConfigRequest; +import com.google.cloud.securitycenter.v1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1.DeleteBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.DeleteMuteConfigRequest; +import com.google.cloud.securitycenter.v1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.ExternalSystem; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.GetBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.GetMuteConfigRequest; +import com.google.cloud.securitycenter.v1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1.GetSourceRequest; +import com.google.cloud.securitycenter.v1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsResponse; +import com.google.cloud.securitycenter.v1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1.ListMuteConfigsRequest; +import com.google.cloud.securitycenter.v1.ListMuteConfigsResponse; +import com.google.cloud.securitycenter.v1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1.ListNotificationConfigsResponse; +import com.google.cloud.securitycenter.v1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1.SecurityMarks; +import com.google.cloud.securitycenter.v1.SetFindingStateRequest; +import com.google.cloud.securitycenter.v1.SetMuteRequest; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.UpdateBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.UpdateExternalSystemRequest; +import com.google.cloud.securitycenter.v1.UpdateFindingRequest; +import com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest; +import com.google.cloud.securitycenter.v1.UpdateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.UpdateOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1.UpdateSecurityMarksRequest; +import com.google.cloud.securitycenter.v1.UpdateSourceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SecurityCenter service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSecurityCenterStub extends SecurityCenterStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(RunAssetDiscoveryResponse.getDescriptor()) + .add(BulkMuteFindingsResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + bulkMuteFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/BulkMuteFindings") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/findings:bulkMute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/findings:bulkMute", + "/v1/{parent=projects/*}/findings:bulkMute") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BulkMuteFindingsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/CreateSource") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/CreateFinding") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "findingId", request.getFindingId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createMuteConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/CreateMuteConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/muteConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/muteConfigs", + "/v1/{parent=projects/*}/muteConfigs") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "muteConfigId", request.getMuteConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("muteConfig", request.getMuteConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(MuteConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/CreateNotificationConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/notificationConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "configId", request.getConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("notificationConfig", request.getNotificationConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteMuteConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/DeleteMuteConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/muteConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/muteConfigs/*}", + "/v1/{name=projects/*/muteConfigs/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/DeleteNotificationConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getBigQueryExportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GetBigQueryExport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/bigQueryExports/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/bigQueryExports/*}", + "/v1/{name=projects/*/bigQueryExports/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BigQueryExport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=organizations/*/sources/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getMuteConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GetMuteConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/muteConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/muteConfigs/*}", + "/v1/{name=projects/*/muteConfigs/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(MuteConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/GetNotificationConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/GetOrganizationSettings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GetSource") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GroupAssets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/assets:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/assets:group", + "/v1/{parent=projects/*}/assets:group") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/GroupFindings") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*/sources/*}/findings:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*/sources/*}/findings:group", + "/v1/{parent=projects/*/sources/*}/findings:group") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/ListAssets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/assets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/assets", "/v1/{parent=projects/*}/assets") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "compareDuration", request.getCompareDuration()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*/sources/*}/findings", + "/v1/{parent=projects/*/sources/*}/findings") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "compareDuration", request.getCompareDuration()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listMuteConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/ListMuteConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/muteConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/muteConfigs", + "/v1/{parent=projects/*}/muteConfigs") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListMuteConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListNotificationConfigsRequest, ListNotificationConfigsResponse> + listNotificationConfigsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/ListNotificationConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/notificationConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListNotificationConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSourcesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/ListSources") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/sources", "/v1/{parent=projects/*}/sources") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSourcesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runAssetDiscoveryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/RunAssetDiscovery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/assets:runDiscovery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RunAssetDiscoveryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setFindingStateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/SetFindingState") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/sources/*/findings/*}:setState", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/sources/*/findings/*}:setState", + "/v1/{name=projects/*/sources/*/findings/*}:setState") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor setMuteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/SetMute") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/sources/*/findings/*}:setMute", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/sources/*/findings/*}:setMute", + "/v1/{name=projects/*/sources/*/findings/*}:setMute") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=organizations/*/sources/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=organizations/*/sources/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateExternalSystemMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/UpdateExternalSystem") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{externalSystem.name=organizations/*/sources/*/findings/*/externalSystems/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "externalSystem.name", + request.getExternalSystem().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{externalSystem.name=folders/*/sources/*/findings/*/externalSystems/*}", + "/v1/{externalSystem.name=projects/*/sources/*/findings/*/externalSystems/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("externalSystem", request.getExternalSystem())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ExternalSystem.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/UpdateFinding") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{finding.name=organizations/*/sources/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "finding.name", request.getFinding().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{finding.name=folders/*/sources/*/findings/*}", + "/v1/{finding.name=projects/*/sources/*/findings/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateMuteConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/UpdateMuteConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{muteConfig.name=organizations/*/muteConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "muteConfig.name", request.getMuteConfig().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{muteConfig.name=folders/*/muteConfigs/*}", + "/v1/{muteConfig.name=projects/*/muteConfigs/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("muteConfig", request.getMuteConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(MuteConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/UpdateNotificationConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{notificationConfig.name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "notificationConfig.name", + request.getNotificationConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("notificationConfig", request.getNotificationConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/UpdateOrganizationSettings") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{organizationSettings.name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "organizationSettings.name", + request.getOrganizationSettings().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "organizationSettings", request.getOrganizationSettings())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1.SecurityCenter/UpdateSource") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{source.name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "source.name", request.getSource().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSecurityMarksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/UpdateSecurityMarks") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{securityMarks.name=organizations/*/assets/*/securityMarks}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "securityMarks.name", request.getSecurityMarks().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{securityMarks.name=folders/*/assets/*/securityMarks}", + "/v1/{securityMarks.name=projects/*/assets/*/securityMarks}", + "/v1/{securityMarks.name=organizations/*/sources/*/findings/*/securityMarks}", + "/v1/{securityMarks.name=folders/*/sources/*/findings/*/securityMarks}", + "/v1/{securityMarks.name=projects/*/sources/*/findings/*/securityMarks}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "startTime", request.getStartTime()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("securityMarks", request.getSecurityMarks())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SecurityMarks.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createBigQueryExportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/CreateBigQueryExport") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/bigQueryExports", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/bigQueryExports", + "/v1/{parent=projects/*}/bigQueryExports") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "bigQueryExportId", request.getBigQueryExportId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("bigQueryExport", request.getBigQueryExport())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BigQueryExport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBigQueryExportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/DeleteBigQueryExport") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=organizations/*/bigQueryExports/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{name=folders/*/bigQueryExports/*}", + "/v1/{name=projects/*/bigQueryExports/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBigQueryExportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/UpdateBigQueryExport") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{bigQueryExport.name=organizations/*/bigQueryExports/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "bigQueryExport.name", + request.getBigQueryExport().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1/{bigQueryExport.name=folders/*/bigQueryExports/*}", + "/v1/{bigQueryExport.name=projects/*/bigQueryExports/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("bigQueryExport", request.getBigQueryExport())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BigQueryExport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBigQueryExportsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1.SecurityCenter/ListBigQueryExports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=organizations/*}/bigQueryExports", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=folders/*}/bigQueryExports", + "/v1/{parent=projects/*}/bigQueryExports") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBigQueryExportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable bulkMuteFindingsCallable; + private final OperationCallable + bulkMuteFindingsOperationCallable; + private final UnaryCallable createSourceCallable; + private final UnaryCallable createFindingCallable; + private final UnaryCallable createMuteConfigCallable; + private final UnaryCallable + createNotificationConfigCallable; + private final UnaryCallable deleteMuteConfigCallable; + private final UnaryCallable + deleteNotificationConfigCallable; + private final UnaryCallable getBigQueryExportCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable getMuteConfigCallable; + private final UnaryCallable + getNotificationConfigCallable; + private final UnaryCallable + getOrganizationSettingsCallable; + private final UnaryCallable getSourceCallable; + private final UnaryCallable groupAssetsCallable; + private final UnaryCallable + groupAssetsPagedCallable; + private final UnaryCallable groupFindingsCallable; + private final UnaryCallable + groupFindingsPagedCallable; + private final UnaryCallable listAssetsCallable; + private final UnaryCallable listAssetsPagedCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable + listMuteConfigsCallable; + private final UnaryCallable + listMuteConfigsPagedCallable; + private final UnaryCallable + listNotificationConfigsCallable; + private final UnaryCallable + listNotificationConfigsPagedCallable; + private final UnaryCallable listSourcesCallable; + private final UnaryCallable + listSourcesPagedCallable; + private final UnaryCallable runAssetDiscoveryCallable; + private final OperationCallable + runAssetDiscoveryOperationCallable; + private final UnaryCallable setFindingStateCallable; + private final UnaryCallable setMuteCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + private final UnaryCallable + updateExternalSystemCallable; + private final UnaryCallable updateFindingCallable; + private final UnaryCallable updateMuteConfigCallable; + private final UnaryCallable + updateNotificationConfigCallable; + private final UnaryCallable + updateOrganizationSettingsCallable; + private final UnaryCallable updateSourceCallable; + private final UnaryCallable + updateSecurityMarksCallable; + private final UnaryCallable + createBigQueryExportCallable; + private final UnaryCallable deleteBigQueryExportCallable; + private final UnaryCallable + updateBigQueryExportCallable; + private final UnaryCallable + listBigQueryExportsCallable; + private final UnaryCallable + listBigQueryExportsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSecurityCenterStub create(SecurityCenterStubSettings settings) + throws IOException { + return new HttpJsonSecurityCenterStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSecurityCenterStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSecurityCenterStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSecurityCenterCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings bulkMuteFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(bulkMuteFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createMuteConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createMuteConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteMuteConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteMuteConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getBigQueryExportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBigQueryExportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getMuteConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getMuteConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOrganizationSettingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings groupAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + groupFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listMuteConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listMuteConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listNotificationConfigsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listNotificationConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listSourcesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSourcesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runAssetDiscoveryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runAssetDiscoveryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setFindingStateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setFindingStateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setMuteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setMuteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateExternalSystemTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateExternalSystemMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateMuteConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateMuteConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOrganizationSettingsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSecurityMarksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSecurityMarksMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createBigQueryExportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBigQueryExportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteBigQueryExportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBigQueryExportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateBigQueryExportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBigQueryExportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listBigQueryExportsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listBigQueryExportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.bulkMuteFindingsCallable = + callableFactory.createUnaryCallable( + bulkMuteFindingsTransportSettings, settings.bulkMuteFindingsSettings(), clientContext); + this.bulkMuteFindingsOperationCallable = + callableFactory.createOperationCallable( + bulkMuteFindingsTransportSettings, + settings.bulkMuteFindingsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createSourceCallable = + callableFactory.createUnaryCallable( + createSourceTransportSettings, settings.createSourceSettings(), clientContext); + this.createFindingCallable = + callableFactory.createUnaryCallable( + createFindingTransportSettings, settings.createFindingSettings(), clientContext); + this.createMuteConfigCallable = + callableFactory.createUnaryCallable( + createMuteConfigTransportSettings, settings.createMuteConfigSettings(), clientContext); + this.createNotificationConfigCallable = + callableFactory.createUnaryCallable( + createNotificationConfigTransportSettings, + settings.createNotificationConfigSettings(), + clientContext); + this.deleteMuteConfigCallable = + callableFactory.createUnaryCallable( + deleteMuteConfigTransportSettings, settings.deleteMuteConfigSettings(), clientContext); + this.deleteNotificationConfigCallable = + callableFactory.createUnaryCallable( + deleteNotificationConfigTransportSettings, + settings.deleteNotificationConfigSettings(), + clientContext); + this.getBigQueryExportCallable = + callableFactory.createUnaryCallable( + getBigQueryExportTransportSettings, + settings.getBigQueryExportSettings(), + clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.getMuteConfigCallable = + callableFactory.createUnaryCallable( + getMuteConfigTransportSettings, settings.getMuteConfigSettings(), clientContext); + this.getNotificationConfigCallable = + callableFactory.createUnaryCallable( + getNotificationConfigTransportSettings, + settings.getNotificationConfigSettings(), + clientContext); + this.getOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + getOrganizationSettingsTransportSettings, + settings.getOrganizationSettingsSettings(), + clientContext); + this.getSourceCallable = + callableFactory.createUnaryCallable( + getSourceTransportSettings, settings.getSourceSettings(), clientContext); + this.groupAssetsCallable = + callableFactory.createUnaryCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupAssetsPagedCallable = + callableFactory.createPagedCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupFindingsCallable = + callableFactory.createUnaryCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.groupFindingsPagedCallable = + callableFactory.createPagedCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.listAssetsCallable = + callableFactory.createUnaryCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listAssetsPagedCallable = + callableFactory.createPagedCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listMuteConfigsCallable = + callableFactory.createUnaryCallable( + listMuteConfigsTransportSettings, settings.listMuteConfigsSettings(), clientContext); + this.listMuteConfigsPagedCallable = + callableFactory.createPagedCallable( + listMuteConfigsTransportSettings, settings.listMuteConfigsSettings(), clientContext); + this.listNotificationConfigsCallable = + callableFactory.createUnaryCallable( + listNotificationConfigsTransportSettings, + settings.listNotificationConfigsSettings(), + clientContext); + this.listNotificationConfigsPagedCallable = + callableFactory.createPagedCallable( + listNotificationConfigsTransportSettings, + settings.listNotificationConfigsSettings(), + clientContext); + this.listSourcesCallable = + callableFactory.createUnaryCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.listSourcesPagedCallable = + callableFactory.createPagedCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.runAssetDiscoveryCallable = + callableFactory.createUnaryCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoverySettings(), + clientContext); + this.runAssetDiscoveryOperationCallable = + callableFactory.createOperationCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoveryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setFindingStateCallable = + callableFactory.createUnaryCallable( + setFindingStateTransportSettings, settings.setFindingStateSettings(), clientContext); + this.setMuteCallable = + callableFactory.createUnaryCallable( + setMuteTransportSettings, settings.setMuteSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + this.updateExternalSystemCallable = + callableFactory.createUnaryCallable( + updateExternalSystemTransportSettings, + settings.updateExternalSystemSettings(), + clientContext); + this.updateFindingCallable = + callableFactory.createUnaryCallable( + updateFindingTransportSettings, settings.updateFindingSettings(), clientContext); + this.updateMuteConfigCallable = + callableFactory.createUnaryCallable( + updateMuteConfigTransportSettings, settings.updateMuteConfigSettings(), clientContext); + this.updateNotificationConfigCallable = + callableFactory.createUnaryCallable( + updateNotificationConfigTransportSettings, + settings.updateNotificationConfigSettings(), + clientContext); + this.updateOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + updateOrganizationSettingsTransportSettings, + settings.updateOrganizationSettingsSettings(), + clientContext); + this.updateSourceCallable = + callableFactory.createUnaryCallable( + updateSourceTransportSettings, settings.updateSourceSettings(), clientContext); + this.updateSecurityMarksCallable = + callableFactory.createUnaryCallable( + updateSecurityMarksTransportSettings, + settings.updateSecurityMarksSettings(), + clientContext); + this.createBigQueryExportCallable = + callableFactory.createUnaryCallable( + createBigQueryExportTransportSettings, + settings.createBigQueryExportSettings(), + clientContext); + this.deleteBigQueryExportCallable = + callableFactory.createUnaryCallable( + deleteBigQueryExportTransportSettings, + settings.deleteBigQueryExportSettings(), + clientContext); + this.updateBigQueryExportCallable = + callableFactory.createUnaryCallable( + updateBigQueryExportTransportSettings, + settings.updateBigQueryExportSettings(), + clientContext); + this.listBigQueryExportsCallable = + callableFactory.createUnaryCallable( + listBigQueryExportsTransportSettings, + settings.listBigQueryExportsSettings(), + clientContext); + this.listBigQueryExportsPagedCallable = + callableFactory.createPagedCallable( + listBigQueryExportsTransportSettings, + settings.listBigQueryExportsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(bulkMuteFindingsMethodDescriptor); + methodDescriptors.add(createSourceMethodDescriptor); + methodDescriptors.add(createFindingMethodDescriptor); + methodDescriptors.add(createMuteConfigMethodDescriptor); + methodDescriptors.add(createNotificationConfigMethodDescriptor); + methodDescriptors.add(deleteMuteConfigMethodDescriptor); + methodDescriptors.add(deleteNotificationConfigMethodDescriptor); + methodDescriptors.add(getBigQueryExportMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(getMuteConfigMethodDescriptor); + methodDescriptors.add(getNotificationConfigMethodDescriptor); + methodDescriptors.add(getOrganizationSettingsMethodDescriptor); + methodDescriptors.add(getSourceMethodDescriptor); + methodDescriptors.add(groupAssetsMethodDescriptor); + methodDescriptors.add(groupFindingsMethodDescriptor); + methodDescriptors.add(listAssetsMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listMuteConfigsMethodDescriptor); + methodDescriptors.add(listNotificationConfigsMethodDescriptor); + methodDescriptors.add(listSourcesMethodDescriptor); + methodDescriptors.add(runAssetDiscoveryMethodDescriptor); + methodDescriptors.add(setFindingStateMethodDescriptor); + methodDescriptors.add(setMuteMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + methodDescriptors.add(updateExternalSystemMethodDescriptor); + methodDescriptors.add(updateFindingMethodDescriptor); + methodDescriptors.add(updateMuteConfigMethodDescriptor); + methodDescriptors.add(updateNotificationConfigMethodDescriptor); + methodDescriptors.add(updateOrganizationSettingsMethodDescriptor); + methodDescriptors.add(updateSourceMethodDescriptor); + methodDescriptors.add(updateSecurityMarksMethodDescriptor); + methodDescriptors.add(createBigQueryExportMethodDescriptor); + methodDescriptors.add(deleteBigQueryExportMethodDescriptor); + methodDescriptors.add(updateBigQueryExportMethodDescriptor); + methodDescriptors.add(listBigQueryExportsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable bulkMuteFindingsCallable() { + return bulkMuteFindingsCallable; + } + + @Override + public OperationCallable + bulkMuteFindingsOperationCallable() { + return bulkMuteFindingsOperationCallable; + } + + @Override + public UnaryCallable createSourceCallable() { + return createSourceCallable; + } + + @Override + public UnaryCallable createFindingCallable() { + return createFindingCallable; + } + + @Override + public UnaryCallable createMuteConfigCallable() { + return createMuteConfigCallable; + } + + @Override + public UnaryCallable + createNotificationConfigCallable() { + return createNotificationConfigCallable; + } + + @Override + public UnaryCallable deleteMuteConfigCallable() { + return deleteMuteConfigCallable; + } + + @Override + public UnaryCallable deleteNotificationConfigCallable() { + return deleteNotificationConfigCallable; + } + + @Override + public UnaryCallable getBigQueryExportCallable() { + return getBigQueryExportCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable getMuteConfigCallable() { + return getMuteConfigCallable; + } + + @Override + public UnaryCallable + getNotificationConfigCallable() { + return getNotificationConfigCallable; + } + + @Override + public UnaryCallable + getOrganizationSettingsCallable() { + return getOrganizationSettingsCallable; + } + + @Override + public UnaryCallable getSourceCallable() { + return getSourceCallable; + } + + @Override + public UnaryCallable groupAssetsCallable() { + return groupAssetsCallable; + } + + @Override + public UnaryCallable groupAssetsPagedCallable() { + return groupAssetsPagedCallable; + } + + @Override + public UnaryCallable groupFindingsCallable() { + return groupFindingsCallable; + } + + @Override + public UnaryCallable + groupFindingsPagedCallable() { + return groupFindingsPagedCallable; + } + + @Override + public UnaryCallable listAssetsCallable() { + return listAssetsCallable; + } + + @Override + public UnaryCallable listAssetsPagedCallable() { + return listAssetsPagedCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable listMuteConfigsCallable() { + return listMuteConfigsCallable; + } + + @Override + public UnaryCallable + listMuteConfigsPagedCallable() { + return listMuteConfigsPagedCallable; + } + + @Override + public UnaryCallable + listNotificationConfigsCallable() { + return listNotificationConfigsCallable; + } + + @Override + public UnaryCallable + listNotificationConfigsPagedCallable() { + return listNotificationConfigsPagedCallable; + } + + @Override + public UnaryCallable listSourcesCallable() { + return listSourcesCallable; + } + + @Override + public UnaryCallable listSourcesPagedCallable() { + return listSourcesPagedCallable; + } + + @Override + public UnaryCallable runAssetDiscoveryCallable() { + return runAssetDiscoveryCallable; + } + + @Override + public OperationCallable + runAssetDiscoveryOperationCallable() { + return runAssetDiscoveryOperationCallable; + } + + @Override + public UnaryCallable setFindingStateCallable() { + return setFindingStateCallable; + } + + @Override + public UnaryCallable setMuteCallable() { + return setMuteCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public UnaryCallable updateExternalSystemCallable() { + return updateExternalSystemCallable; + } + + @Override + public UnaryCallable updateFindingCallable() { + return updateFindingCallable; + } + + @Override + public UnaryCallable updateMuteConfigCallable() { + return updateMuteConfigCallable; + } + + @Override + public UnaryCallable + updateNotificationConfigCallable() { + return updateNotificationConfigCallable; + } + + @Override + public UnaryCallable + updateOrganizationSettingsCallable() { + return updateOrganizationSettingsCallable; + } + + @Override + public UnaryCallable updateSourceCallable() { + return updateSourceCallable; + } + + @Override + public UnaryCallable updateSecurityMarksCallable() { + return updateSecurityMarksCallable; + } + + @Override + public UnaryCallable createBigQueryExportCallable() { + return createBigQueryExportCallable; + } + + @Override + public UnaryCallable deleteBigQueryExportCallable() { + return deleteBigQueryExportCallable; + } + + @Override + public UnaryCallable updateBigQueryExportCallable() { + return updateBigQueryExportCallable; + } + + @Override + public UnaryCallable + listBigQueryExportsCallable() { + return listBigQueryExportsCallable; + } + + @Override + public UnaryCallable + listBigQueryExportsPagedCallable() { + return listBigQueryExportsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java index 52740ed22..4207bbc3a 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStub.java @@ -99,7 +99,11 @@ public abstract class SecurityCenterStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java index 7ac41698b..ddb4873ae 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1/stub/SecurityCenterStubSettings.java @@ -35,6 +35,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -912,13 +915,17 @@ public UnaryCallSettings deleteBigQueryExpor return listBigQueryExportsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSecurityCenterStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSecurityCenterStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -951,18 +958,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) @@ -970,11 +984,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SecurityCenterStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -1370,6 +1403,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .bulkMuteFindingsSettings() diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java index 33b24430e..5c6cac1d1 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -37,7 +38,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.Timestamp; import java.io.IOException; @@ -110,6 +110,20 @@ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SecurityCenterSettings securityCenterSettings =
+ *     SecurityCenterSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -117,7 +131,8 @@ public class SecurityCenterClient implements BackgroundResource { private final SecurityCenterSettings settings; private final SecurityCenterStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of SecurityCenterClient with default settings. */ public static final SecurityCenterClient create() throws IOException { @@ -137,7 +152,6 @@ public static final SecurityCenterClient create(SecurityCenterSettings settings) * Constructs an instance of SecurityCenterClient, using the given stub for making calls. This is * for advanced usage - prefer using create(SecurityCenterSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final SecurityCenterClient create(SecurityCenterStub stub) { return new SecurityCenterClient(stub); } @@ -150,21 +164,23 @@ public static final SecurityCenterClient create(SecurityCenterStub stub) { protected SecurityCenterClient(SecurityCenterSettings settings) throws IOException { this.settings = settings; this.stub = ((SecurityCenterStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected SecurityCenterClient(SecurityCenterStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final SecurityCenterSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub getStub() { return stub; } @@ -173,10 +189,19 @@ public SecurityCenterStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a source. @@ -422,7 +447,7 @@ public final UnaryCallable createFindingCallable( * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + * ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); * Policy response = securityCenterClient.getIamPolicy(resource); * } * } @@ -475,7 +500,7 @@ public final Policy getIamPolicy(String resource) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = securityCenterClient.getIamPolicy(request); @@ -501,7 +526,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); @@ -805,7 +830,7 @@ public final GroupAssetsPagedResponse groupAssets(GroupAssetsRequest request) { * .build(); * while (true) { * GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1006,7 +1031,7 @@ public final GroupFindingsPagedResponse groupFindings(GroupFindingsRequest reque * .build(); * while (true) { * GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1115,7 +1140,7 @@ public final UnaryCallable listAsset * .build(); * while (true) { * ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); - * for (ListAssetsResponse.ListAssetsResult element : response.getResponsesList()) { + * for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1230,7 +1255,7 @@ public final ListFindingsPagedResponse listFindings(ListFindingsRequest request) * .build(); * while (true) { * ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); - * for (Finding element : response.getResponsesList()) { + * for (Finding element : response.getFindingsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1379,7 +1404,7 @@ public final ListSourcesPagedResponse listSources(ListSourcesRequest request) { * .build(); * while (true) { * ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); - * for (Source element : response.getResponsesList()) { + * for (Source element : response.getSourcesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1670,7 +1695,7 @@ public final UnaryCallable setFindingStateCalla * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + * ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); * Policy policy = Policy.newBuilder().build(); * Policy response = securityCenterClient.setIamPolicy(resource, policy); * } @@ -1733,7 +1758,7 @@ public final Policy setIamPolicy(String resource, Policy policy) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -1760,7 +1785,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -1784,7 +1809,7 @@ public final UnaryCallable setIamPolicyCallable() { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + * ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); * List permissions = new ArrayList<>(); * TestIamPermissionsResponse response = * securityCenterClient.testIamPermissions(resource, permissions); @@ -1854,7 +1879,7 @@ public final TestIamPermissionsResponse testIamPermissions( * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); @@ -1880,7 +1905,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(OrganizationName.of("[ORGANIZATION]").toString()) + * .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java index b9fff807b..f9ddee450 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterSettings.java @@ -27,6 +27,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -215,11 +216,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SecurityCenterStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SecurityCenterStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SecurityCenterStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SecurityCenterStubSettings.defaultTransportChannelProvider(); } @@ -229,11 +237,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SecurityCenterStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -271,6 +285,11 @@ private static Builder createDefault() { return new Builder(SecurityCenterStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SecurityCenterStubSettings.newHttpJsonBuilder()); + } + public SecurityCenterStubSettings.Builder getStubSettingsBuilder() { return ((SecurityCenterStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterCallableFactory.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000..7a018a9b8 --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SecurityCenter service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSecurityCenterCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000..2e5ecc29d --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/HttpJsonSecurityCenterStub.java @@ -0,0 +1,1214 @@ +/* + * Copyright 2022 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.v1beta1.stub; + +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.securitycenter.v1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1beta1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1beta1.SetFindingStateRequest; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.UpdateFindingRequest; +import com.google.cloud.securitycenter.v1beta1.UpdateOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1beta1.UpdateSecurityMarksRequest; +import com.google.cloud.securitycenter.v1beta1.UpdateSourceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SecurityCenter service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSecurityCenterStub extends SecurityCenterStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder().add(Empty.getDescriptor()).build(); + + private static final ApiMethodDescriptor + createSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/CreateSource") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/CreateFinding") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "findingId", request.getFindingId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=organizations/*/sources/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/GetOrganizationSettings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/GetSource") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/GroupAssets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*}/assets:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/GroupFindings") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*/sources/*}/findings:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/ListAssets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*}/assets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "compareDuration", request.getCompareDuration()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSourcesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/ListSources") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSourcesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runAssetDiscoveryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/RunAssetDiscovery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=organizations/*}/assets:runDiscovery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RunAssetDiscoveryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setFindingStateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/SetFindingState") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=organizations/*/sources/*/findings/*}:setState", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=organizations/*/sources/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=organizations/*/sources/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateFinding") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{finding.name=organizations/*/sources/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "finding.name", request.getFinding().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateOrganizationSettings") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{organizationSettings.name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "organizationSettings.name", + request.getOrganizationSettings().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "organizationSettings", request.getOrganizationSettings())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSource") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{source.name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "source.name", request.getSource().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSecurityMarksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1beta1.SecurityCenter/UpdateSecurityMarks") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{securityMarks.name=organizations/*/assets/*/securityMarks}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "securityMarks.name", request.getSecurityMarks().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{securityMarks.name=organizations/*/sources/*/findings/*/securityMarks}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "startTime", request.getStartTime()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("securityMarks", request.getSecurityMarks())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SecurityMarks.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createSourceCallable; + private final UnaryCallable createFindingCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + getOrganizationSettingsCallable; + private final UnaryCallable getSourceCallable; + private final UnaryCallable groupAssetsCallable; + private final UnaryCallable + groupAssetsPagedCallable; + private final UnaryCallable groupFindingsCallable; + private final UnaryCallable + groupFindingsPagedCallable; + private final UnaryCallable listAssetsCallable; + private final UnaryCallable listAssetsPagedCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable listSourcesCallable; + private final UnaryCallable + listSourcesPagedCallable; + private final UnaryCallable runAssetDiscoveryCallable; + private final OperationCallable + runAssetDiscoveryOperationCallable; + private final UnaryCallable setFindingStateCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + private final UnaryCallable updateFindingCallable; + private final UnaryCallable + updateOrganizationSettingsCallable; + private final UnaryCallable updateSourceCallable; + private final UnaryCallable + updateSecurityMarksCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSecurityCenterStub create(SecurityCenterStubSettings settings) + throws IOException { + return new HttpJsonSecurityCenterStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSecurityCenterStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSecurityCenterStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSecurityCenterCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOrganizationSettingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings groupAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + groupFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listSourcesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSourcesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runAssetDiscoveryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runAssetDiscoveryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setFindingStateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setFindingStateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOrganizationSettingsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSecurityMarksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSecurityMarksMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createSourceCallable = + callableFactory.createUnaryCallable( + createSourceTransportSettings, settings.createSourceSettings(), clientContext); + this.createFindingCallable = + callableFactory.createUnaryCallable( + createFindingTransportSettings, settings.createFindingSettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.getOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + getOrganizationSettingsTransportSettings, + settings.getOrganizationSettingsSettings(), + clientContext); + this.getSourceCallable = + callableFactory.createUnaryCallable( + getSourceTransportSettings, settings.getSourceSettings(), clientContext); + this.groupAssetsCallable = + callableFactory.createUnaryCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupAssetsPagedCallable = + callableFactory.createPagedCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupFindingsCallable = + callableFactory.createUnaryCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.groupFindingsPagedCallable = + callableFactory.createPagedCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.listAssetsCallable = + callableFactory.createUnaryCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listAssetsPagedCallable = + callableFactory.createPagedCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listSourcesCallable = + callableFactory.createUnaryCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.listSourcesPagedCallable = + callableFactory.createPagedCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.runAssetDiscoveryCallable = + callableFactory.createUnaryCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoverySettings(), + clientContext); + this.runAssetDiscoveryOperationCallable = + callableFactory.createOperationCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoveryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setFindingStateCallable = + callableFactory.createUnaryCallable( + setFindingStateTransportSettings, settings.setFindingStateSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + this.updateFindingCallable = + callableFactory.createUnaryCallable( + updateFindingTransportSettings, settings.updateFindingSettings(), clientContext); + this.updateOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + updateOrganizationSettingsTransportSettings, + settings.updateOrganizationSettingsSettings(), + clientContext); + this.updateSourceCallable = + callableFactory.createUnaryCallable( + updateSourceTransportSettings, settings.updateSourceSettings(), clientContext); + this.updateSecurityMarksCallable = + callableFactory.createUnaryCallable( + updateSecurityMarksTransportSettings, + settings.updateSecurityMarksSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createSourceMethodDescriptor); + methodDescriptors.add(createFindingMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(getOrganizationSettingsMethodDescriptor); + methodDescriptors.add(getSourceMethodDescriptor); + methodDescriptors.add(groupAssetsMethodDescriptor); + methodDescriptors.add(groupFindingsMethodDescriptor); + methodDescriptors.add(listAssetsMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listSourcesMethodDescriptor); + methodDescriptors.add(runAssetDiscoveryMethodDescriptor); + methodDescriptors.add(setFindingStateMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + methodDescriptors.add(updateFindingMethodDescriptor); + methodDescriptors.add(updateOrganizationSettingsMethodDescriptor); + methodDescriptors.add(updateSourceMethodDescriptor); + methodDescriptors.add(updateSecurityMarksMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createSourceCallable() { + return createSourceCallable; + } + + @Override + public UnaryCallable createFindingCallable() { + return createFindingCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + getOrganizationSettingsCallable() { + return getOrganizationSettingsCallable; + } + + @Override + public UnaryCallable getSourceCallable() { + return getSourceCallable; + } + + @Override + public UnaryCallable groupAssetsCallable() { + return groupAssetsCallable; + } + + @Override + public UnaryCallable groupAssetsPagedCallable() { + return groupAssetsPagedCallable; + } + + @Override + public UnaryCallable groupFindingsCallable() { + return groupFindingsCallable; + } + + @Override + public UnaryCallable + groupFindingsPagedCallable() { + return groupFindingsPagedCallable; + } + + @Override + public UnaryCallable listAssetsCallable() { + return listAssetsCallable; + } + + @Override + public UnaryCallable listAssetsPagedCallable() { + return listAssetsPagedCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable listSourcesCallable() { + return listSourcesCallable; + } + + @Override + public UnaryCallable listSourcesPagedCallable() { + return listSourcesPagedCallable; + } + + @Override + public UnaryCallable runAssetDiscoveryCallable() { + return runAssetDiscoveryCallable; + } + + @Override + public OperationCallable + runAssetDiscoveryOperationCallable() { + return runAssetDiscoveryOperationCallable; + } + + @Override + public UnaryCallable setFindingStateCallable() { + return setFindingStateCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public UnaryCallable updateFindingCallable() { + return updateFindingCallable; + } + + @Override + public UnaryCallable + updateOrganizationSettingsCallable() { + return updateOrganizationSettingsCallable; + } + + @Override + public UnaryCallable updateSourceCallable() { + return updateSourceCallable; + } + + @Override + public UnaryCallable updateSecurityMarksCallable() { + return updateSecurityMarksCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java index 4947c7f6d..1072f47bb 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStub.java @@ -71,7 +71,11 @@ public abstract class SecurityCenterStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createSourceCallable() { diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java index 6b4f82881..9a679e91c 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1beta1/stub/SecurityCenterStubSettings.java @@ -32,6 +32,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -538,13 +541,17 @@ public UnaryCallSettings updateSourceSettings() { return updateSecurityMarksSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSecurityCenterStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSecurityCenterStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -577,18 +584,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) @@ -596,11 +610,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SecurityCenterStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -853,6 +886,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createSourceSettings() diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java index 3c5a865a7..3e1c00091 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -37,7 +38,6 @@ import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; @@ -111,6 +111,20 @@ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SecurityCenterSettings securityCenterSettings =
+ *     SecurityCenterSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -118,7 +132,8 @@ public class SecurityCenterClient implements BackgroundResource { private final SecurityCenterSettings settings; private final SecurityCenterStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of SecurityCenterClient with default settings. */ public static final SecurityCenterClient create() throws IOException { @@ -138,7 +153,6 @@ public static final SecurityCenterClient create(SecurityCenterSettings settings) * Constructs an instance of SecurityCenterClient, using the given stub for making calls. This is * for advanced usage - prefer using create(SecurityCenterSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final SecurityCenterClient create(SecurityCenterStub stub) { return new SecurityCenterClient(stub); } @@ -151,21 +165,23 @@ public static final SecurityCenterClient create(SecurityCenterStub stub) { protected SecurityCenterClient(SecurityCenterSettings settings) throws IOException { this.settings = settings; this.stub = ((SecurityCenterStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected SecurityCenterClient(SecurityCenterStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final SecurityCenterSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub getStub() { return stub; } @@ -174,10 +190,19 @@ public SecurityCenterStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a source. @@ -793,7 +818,7 @@ public final void deleteNotificationConfig(DeleteNotificationConfigRequest reque * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * Policy response = securityCenterClient.getIamPolicy(resource); * } * } @@ -846,7 +871,8 @@ public final Policy getIamPolicy(String resource) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = securityCenterClient.getIamPolicy(request); @@ -872,7 +898,8 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); @@ -1282,7 +1309,7 @@ public final GroupAssetsPagedResponse groupAssets(GroupAssetsRequest request) { * .build(); * while (true) { * GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1510,7 +1537,7 @@ public final GroupFindingsPagedResponse groupFindings(GroupFindingsRequest reque * .build(); * while (true) { * GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); - * for (GroupResult element : response.getResponsesList()) { + * for (GroupResult element : response.getGroupByResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1730,7 +1757,7 @@ public final UnaryCallable listAsset * .build(); * while (true) { * ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); - * for (ListAssetsResponse.ListAssetsResult element : response.getResponsesList()) { + * for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1923,7 +1950,8 @@ public final ListFindingsPagedResponse listFindings(ListFindingsRequest request) * .build(); * while (true) { * ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); - * for (ListFindingsResponse.ListFindingsResult element : response.getResponsesList()) { + * for (ListFindingsResponse.ListFindingsResult element : + * response.getListFindingsResultsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2079,7 +2107,7 @@ public final ListNotificationConfigsPagedResponse listNotificationConfigs( * while (true) { * ListNotificationConfigsResponse response = * securityCenterClient.listNotificationConfigsCallable().call(request); - * for (NotificationConfig element : response.getResponsesList()) { + * for (NotificationConfig element : response.getNotificationConfigsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2287,7 +2315,7 @@ public final ListSourcesPagedResponse listSources(ListSourcesRequest request) { * .build(); * while (true) { * ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); - * for (Source element : response.getResponsesList()) { + * for (Source element : response.getSourcesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2592,7 +2620,7 @@ public final UnaryCallable setFindingStateCalla * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * Policy policy = Policy.newBuilder().build(); * Policy response = securityCenterClient.setIamPolicy(resource, policy); * } @@ -2655,7 +2683,8 @@ public final Policy setIamPolicy(String resource, Policy policy) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -2682,7 +2711,8 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -2706,7 +2736,7 @@ public final UnaryCallable setIamPolicyCallable() { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { - * ResourceName resource = FolderName.of("[FOLDER]"); + * ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); * List permissions = new ArrayList<>(); * TestIamPermissionsResponse response = * securityCenterClient.testIamPermissions(resource, permissions); @@ -2776,7 +2806,8 @@ public final TestIamPermissionsResponse testIamPermissions( * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); @@ -2802,7 +2833,8 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(FolderName.of("[FOLDER]").toString()) + * .setResource( + * SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java index b831cccc7..475a1c90e 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterSettings.java @@ -28,6 +28,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -249,11 +250,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SecurityCenterStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SecurityCenterStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SecurityCenterStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SecurityCenterStubSettings.defaultTransportChannelProvider(); } @@ -263,11 +271,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SecurityCenterStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -305,6 +319,11 @@ private static Builder createDefault() { return new Builder(SecurityCenterStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SecurityCenterStubSettings.newHttpJsonBuilder()); + } + public SecurityCenterStubSettings.Builder getStubSettingsBuilder() { return ((SecurityCenterStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterCallableFactory.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterCallableFactory.java new file mode 100644 index 000000000..3c34c9820 --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.v1p1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the SecurityCenter service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSecurityCenterCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterStub.java new file mode 100644 index 000000000..4e376ba4d --- /dev/null +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/HttpJsonSecurityCenterStub.java @@ -0,0 +1,1559 @@ +/* + * Copyright 2022 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.v1p1beta1.stub; + +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListNotificationConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.securitycenter.v1p1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1p1beta1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsResponse; +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1p1beta1.SetFindingStateRequest; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.UpdateFindingRequest; +import com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.UpdateOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSecurityMarksRequest; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSourceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the SecurityCenter service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonSecurityCenterStub extends SecurityCenterStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(RunAssetDiscoveryResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateSource") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateFinding") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "findingId", request.getFindingId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/CreateNotificationConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/notificationConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "configId", request.getConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("notificationConfig", request.getNotificationConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/DeleteNotificationConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{resource=organizations/*/sources/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetNotificationConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetOrganizationSettings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1p1beta1.SecurityCenter/GetSource") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupAssets") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/assets:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{parent=folders/*}/assets:group", + "/v1p1beta1/{parent=projects/*}/assets:group") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + groupFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/GroupFindings") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*/sources/*}/findings:group", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{parent=folders/*/sources/*}/findings:group", + "/v1p1beta1/{parent=projects/*/sources/*}/findings:group") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GroupFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listAssetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListAssets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/assets", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{parent=folders/*}/assets", + "/v1p1beta1/{parent=projects/*}/assets") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "compareDuration", request.getCompareDuration()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAssetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listFindingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListFindings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*/sources/*}/findings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{parent=folders/*/sources/*}/findings", + "/v1p1beta1/{parent=projects/*/sources/*}/findings") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "compareDuration", request.getCompareDuration()); + serializer.putQueryParam(fields, "fieldMask", request.getFieldMask()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFindingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListNotificationConfigsRequest, ListNotificationConfigsResponse> + listNotificationConfigsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListNotificationConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/notificationConfigs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListNotificationConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSourcesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.securitycenter.v1p1beta1.SecurityCenter/ListSources") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/sources", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{parent=folders/*}/sources", + "/v1p1beta1/{parent=projects/*}/sources") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSourcesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runAssetDiscoveryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/RunAssetDiscovery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{parent=organizations/*}/assets:runDiscovery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RunAssetDiscoveryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + setFindingStateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetFindingState") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{name=organizations/*/sources/*/findings/*}:setState", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{name=folders/*/sources/*/findings/*}:setState", + "/v1p1beta1/{name=projects/*/sources/*/findings/*}:setState") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{resource=organizations/*/sources/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{resource=organizations/*/sources/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFindingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateFinding") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{finding.name=organizations/*/sources/*/findings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "finding.name", request.getFinding().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{finding.name=folders/*/sources/*/findings/*}", + "/v1p1beta1/{finding.name=projects/*/sources/*/findings/*}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("finding", request.getFinding())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Finding.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateNotificationConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateNotificationConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{notificationConfig.name=organizations/*/notificationConfigs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "notificationConfig.name", + request.getNotificationConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("notificationConfig", request.getNotificationConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(NotificationConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateOrganizationSettingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateOrganizationSettings") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{organizationSettings.name=organizations/*/organizationSettings}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "organizationSettings.name", + request.getOrganizationSettings().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody( + "organizationSettings", request.getOrganizationSettings())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(OrganizationSettings.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSourceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSource") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{source.name=organizations/*/sources/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "source.name", request.getSource().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("source", request.getSource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Source.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSecurityMarksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.securitycenter.v1p1beta1.SecurityCenter/UpdateSecurityMarks") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/{securityMarks.name=organizations/*/assets/*/securityMarks}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "securityMarks.name", request.getSecurityMarks().getName()); + return fields; + }) + .setAdditionalPaths( + "/v1p1beta1/{securityMarks.name=folders/*/assets/*/securityMarks}", + "/v1p1beta1/{securityMarks.name=projects/*/assets/*/securityMarks}", + "/v1p1beta1/{securityMarks.name=organizations/*/sources/*/findings/*/securityMarks}", + "/v1p1beta1/{securityMarks.name=folders/*/sources/*/findings/*/securityMarks}", + "/v1p1beta1/{securityMarks.name=projects/*/sources/*/findings/*/securityMarks}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "startTime", request.getStartTime()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("securityMarks", request.getSecurityMarks())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SecurityMarks.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createSourceCallable; + private final UnaryCallable createFindingCallable; + private final UnaryCallable + createNotificationConfigCallable; + private final UnaryCallable + deleteNotificationConfigCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + getNotificationConfigCallable; + private final UnaryCallable + getOrganizationSettingsCallable; + private final UnaryCallable getSourceCallable; + private final UnaryCallable groupAssetsCallable; + private final UnaryCallable + groupAssetsPagedCallable; + private final UnaryCallable groupFindingsCallable; + private final UnaryCallable + groupFindingsPagedCallable; + private final UnaryCallable listAssetsCallable; + private final UnaryCallable listAssetsPagedCallable; + private final UnaryCallable listFindingsCallable; + private final UnaryCallable + listFindingsPagedCallable; + private final UnaryCallable + listNotificationConfigsCallable; + private final UnaryCallable + listNotificationConfigsPagedCallable; + private final UnaryCallable listSourcesCallable; + private final UnaryCallable + listSourcesPagedCallable; + private final UnaryCallable runAssetDiscoveryCallable; + private final OperationCallable + runAssetDiscoveryOperationCallable; + private final UnaryCallable setFindingStateCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + private final UnaryCallable updateFindingCallable; + private final UnaryCallable + updateNotificationConfigCallable; + private final UnaryCallable + updateOrganizationSettingsCallable; + private final UnaryCallable updateSourceCallable; + private final UnaryCallable + updateSecurityMarksCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSecurityCenterStub create(SecurityCenterStubSettings settings) + throws IOException { + return new HttpJsonSecurityCenterStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSecurityCenterStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSecurityCenterStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSecurityCenterStub( + SecurityCenterStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSecurityCenterCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSecurityCenterStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonSecurityCenterStub( + SecurityCenterStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOrganizationSettingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings groupAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + groupFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(groupFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listAssetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listAssetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listFindingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFindingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listNotificationConfigsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listNotificationConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listSourcesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSourcesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runAssetDiscoveryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runAssetDiscoveryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setFindingStateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setFindingStateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateFindingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFindingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateNotificationConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateNotificationConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOrganizationSettingsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateOrganizationSettingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateSourceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSourceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSecurityMarksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSecurityMarksMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createSourceCallable = + callableFactory.createUnaryCallable( + createSourceTransportSettings, settings.createSourceSettings(), clientContext); + this.createFindingCallable = + callableFactory.createUnaryCallable( + createFindingTransportSettings, settings.createFindingSettings(), clientContext); + this.createNotificationConfigCallable = + callableFactory.createUnaryCallable( + createNotificationConfigTransportSettings, + settings.createNotificationConfigSettings(), + clientContext); + this.deleteNotificationConfigCallable = + callableFactory.createUnaryCallable( + deleteNotificationConfigTransportSettings, + settings.deleteNotificationConfigSettings(), + clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.getNotificationConfigCallable = + callableFactory.createUnaryCallable( + getNotificationConfigTransportSettings, + settings.getNotificationConfigSettings(), + clientContext); + this.getOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + getOrganizationSettingsTransportSettings, + settings.getOrganizationSettingsSettings(), + clientContext); + this.getSourceCallable = + callableFactory.createUnaryCallable( + getSourceTransportSettings, settings.getSourceSettings(), clientContext); + this.groupAssetsCallable = + callableFactory.createUnaryCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupAssetsPagedCallable = + callableFactory.createPagedCallable( + groupAssetsTransportSettings, settings.groupAssetsSettings(), clientContext); + this.groupFindingsCallable = + callableFactory.createUnaryCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.groupFindingsPagedCallable = + callableFactory.createPagedCallable( + groupFindingsTransportSettings, settings.groupFindingsSettings(), clientContext); + this.listAssetsCallable = + callableFactory.createUnaryCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listAssetsPagedCallable = + callableFactory.createPagedCallable( + listAssetsTransportSettings, settings.listAssetsSettings(), clientContext); + this.listFindingsCallable = + callableFactory.createUnaryCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listFindingsPagedCallable = + callableFactory.createPagedCallable( + listFindingsTransportSettings, settings.listFindingsSettings(), clientContext); + this.listNotificationConfigsCallable = + callableFactory.createUnaryCallable( + listNotificationConfigsTransportSettings, + settings.listNotificationConfigsSettings(), + clientContext); + this.listNotificationConfigsPagedCallable = + callableFactory.createPagedCallable( + listNotificationConfigsTransportSettings, + settings.listNotificationConfigsSettings(), + clientContext); + this.listSourcesCallable = + callableFactory.createUnaryCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.listSourcesPagedCallable = + callableFactory.createPagedCallable( + listSourcesTransportSettings, settings.listSourcesSettings(), clientContext); + this.runAssetDiscoveryCallable = + callableFactory.createUnaryCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoverySettings(), + clientContext); + this.runAssetDiscoveryOperationCallable = + callableFactory.createOperationCallable( + runAssetDiscoveryTransportSettings, + settings.runAssetDiscoveryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.setFindingStateCallable = + callableFactory.createUnaryCallable( + setFindingStateTransportSettings, settings.setFindingStateSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + this.updateFindingCallable = + callableFactory.createUnaryCallable( + updateFindingTransportSettings, settings.updateFindingSettings(), clientContext); + this.updateNotificationConfigCallable = + callableFactory.createUnaryCallable( + updateNotificationConfigTransportSettings, + settings.updateNotificationConfigSettings(), + clientContext); + this.updateOrganizationSettingsCallable = + callableFactory.createUnaryCallable( + updateOrganizationSettingsTransportSettings, + settings.updateOrganizationSettingsSettings(), + clientContext); + this.updateSourceCallable = + callableFactory.createUnaryCallable( + updateSourceTransportSettings, settings.updateSourceSettings(), clientContext); + this.updateSecurityMarksCallable = + callableFactory.createUnaryCallable( + updateSecurityMarksTransportSettings, + settings.updateSecurityMarksSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createSourceMethodDescriptor); + methodDescriptors.add(createFindingMethodDescriptor); + methodDescriptors.add(createNotificationConfigMethodDescriptor); + methodDescriptors.add(deleteNotificationConfigMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(getNotificationConfigMethodDescriptor); + methodDescriptors.add(getOrganizationSettingsMethodDescriptor); + methodDescriptors.add(getSourceMethodDescriptor); + methodDescriptors.add(groupAssetsMethodDescriptor); + methodDescriptors.add(groupFindingsMethodDescriptor); + methodDescriptors.add(listAssetsMethodDescriptor); + methodDescriptors.add(listFindingsMethodDescriptor); + methodDescriptors.add(listNotificationConfigsMethodDescriptor); + methodDescriptors.add(listSourcesMethodDescriptor); + methodDescriptors.add(runAssetDiscoveryMethodDescriptor); + methodDescriptors.add(setFindingStateMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + methodDescriptors.add(updateFindingMethodDescriptor); + methodDescriptors.add(updateNotificationConfigMethodDescriptor); + methodDescriptors.add(updateOrganizationSettingsMethodDescriptor); + methodDescriptors.add(updateSourceMethodDescriptor); + methodDescriptors.add(updateSecurityMarksMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createSourceCallable() { + return createSourceCallable; + } + + @Override + public UnaryCallable createFindingCallable() { + return createFindingCallable; + } + + @Override + public UnaryCallable + createNotificationConfigCallable() { + return createNotificationConfigCallable; + } + + @Override + public UnaryCallable deleteNotificationConfigCallable() { + return deleteNotificationConfigCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + getNotificationConfigCallable() { + return getNotificationConfigCallable; + } + + @Override + public UnaryCallable + getOrganizationSettingsCallable() { + return getOrganizationSettingsCallable; + } + + @Override + public UnaryCallable getSourceCallable() { + return getSourceCallable; + } + + @Override + public UnaryCallable groupAssetsCallable() { + return groupAssetsCallable; + } + + @Override + public UnaryCallable groupAssetsPagedCallable() { + return groupAssetsPagedCallable; + } + + @Override + public UnaryCallable groupFindingsCallable() { + return groupFindingsCallable; + } + + @Override + public UnaryCallable + groupFindingsPagedCallable() { + return groupFindingsPagedCallable; + } + + @Override + public UnaryCallable listAssetsCallable() { + return listAssetsCallable; + } + + @Override + public UnaryCallable listAssetsPagedCallable() { + return listAssetsPagedCallable; + } + + @Override + public UnaryCallable listFindingsCallable() { + return listFindingsCallable; + } + + @Override + public UnaryCallable listFindingsPagedCallable() { + return listFindingsPagedCallable; + } + + @Override + public UnaryCallable + listNotificationConfigsCallable() { + return listNotificationConfigsCallable; + } + + @Override + public UnaryCallable + listNotificationConfigsPagedCallable() { + return listNotificationConfigsPagedCallable; + } + + @Override + public UnaryCallable listSourcesCallable() { + return listSourcesCallable; + } + + @Override + public UnaryCallable listSourcesPagedCallable() { + return listSourcesPagedCallable; + } + + @Override + public UnaryCallable runAssetDiscoveryCallable() { + return runAssetDiscoveryCallable; + } + + @Override + public OperationCallable + runAssetDiscoveryOperationCallable() { + return runAssetDiscoveryOperationCallable; + } + + @Override + public UnaryCallable setFindingStateCallable() { + return setFindingStateCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public UnaryCallable updateFindingCallable() { + return updateFindingCallable; + } + + @Override + public UnaryCallable + updateNotificationConfigCallable() { + return updateNotificationConfigCallable; + } + + @Override + public UnaryCallable + updateOrganizationSettingsCallable() { + return updateOrganizationSettingsCallable; + } + + @Override + public UnaryCallable updateSourceCallable() { + return updateSourceCallable; + } + + @Override + public UnaryCallable updateSecurityMarksCallable() { + return updateSecurityMarksCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java index d3a5bcc5f..930803f2b 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStub.java @@ -80,7 +80,11 @@ public abstract class SecurityCenterStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createSourceCallable() { diff --git a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java index 5efa3af4b..f8610c6da 100644 --- a/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java +++ b/google-cloud-securitycenter/src/main/java/com/google/cloud/securitycenter/v1p1beta1/stub/SecurityCenterStubSettings.java @@ -33,6 +33,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -674,13 +677,17 @@ public UnaryCallSettings updateSourceSettings() { return updateSecurityMarksSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SecurityCenterStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSecurityCenterStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSecurityCenterStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -713,18 +720,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) @@ -732,11 +746,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(SecurityCenterStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SecurityCenterStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -1029,6 +1062,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createSourceSettings() diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientHttpJsonTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000..3195ac5e1 --- /dev/null +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1/SecurityCenterClientHttpJsonTest.java @@ -0,0 +1,4395 @@ +/* + * Copyright 2022 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 static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListMuteConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1.stub.HttpJsonSecurityCenterStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SecurityCenterClientHttpJsonTest { + private static MockHttpService mockService; + private static SecurityCenterClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSecurityCenterStub.getMethodDescriptors(), + SecurityCenterSettings.getDefaultEndpoint()); + SecurityCenterSettings settings = + SecurityCenterSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SecurityCenterClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void bulkMuteFindingsTest() throws Exception { + BulkMuteFindingsResponse expectedResponse = BulkMuteFindingsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkMuteFindingsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ResourceName parent = FolderName.of("[FOLDER]"); + + BulkMuteFindingsResponse actualResponse = client.bulkMuteFindingsAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bulkMuteFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName parent = FolderName.of("[FOLDER]"); + client.bulkMuteFindingsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void bulkMuteFindingsTest2() throws Exception { + BulkMuteFindingsResponse expectedResponse = BulkMuteFindingsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkMuteFindingsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "organizations/organization-8287"; + + BulkMuteFindingsResponse actualResponse = client.bulkMuteFindingsAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bulkMuteFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.bulkMuteFindingsAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + client.createMuteConfig(parent, muteConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest2() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + client.createMuteConfig(parent, muteConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest3() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + client.createMuteConfig(parent, muteConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest4() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + client.createMuteConfig(parent, muteConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest5() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest5() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest6() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest6() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest7() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest7() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMuteConfigTest8() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + + MuteConfig actualResponse = client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createMuteConfigExceptionTest8() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + client.createMuteConfig(parent, muteConfig, muteConfigId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest3() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest4() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteMuteConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + + client.deleteMuteConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteMuteConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + client.deleteMuteConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteMuteConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-3180/muteConfigs/muteConfig-3180"; + + client.deleteMuteConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteMuteConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-3180/muteConfigs/muteConfig-3180"; + client.deleteMuteConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNotificationConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + + client.deleteNotificationConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + client.deleteNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNotificationConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + + client.deleteNotificationConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + client.deleteNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBigQueryExportTest() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + + BigQueryExport actualResponse = client.getBigQueryExport(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBigQueryExportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + client.getBigQueryExport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBigQueryExportTest2() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683"; + + BigQueryExport actualResponse = client.getBigQueryExport(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBigQueryExportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683"; + client.getBigQueryExport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getMuteConfigTest() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + + MuteConfig actualResponse = client.getMuteConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getMuteConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + client.getMuteConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getMuteConfigTest2() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-3180/muteConfigs/muteConfig-3180"; + + MuteConfig actualResponse = client.getMuteConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getMuteConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-3180/muteConfigs/muteConfig-3180"; + client.getMuteConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + + NotificationConfig actualResponse = client.getNotificationConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + client.getNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + + NotificationConfig actualResponse = client.getNotificationConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + client.getNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest2() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9995/organizationSettings"; + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9995/organizationSettings"; + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7292/sources/source-7292"; + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7292/sources/source-7292"; + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupAssetsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupAssetsResponse expectedResponse = + GroupAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + GroupAssetsPagedResponse pagedListResponse = client.groupAssets(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.groupAssets(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest2() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListAssetsPagedResponse pagedListResponse = client.listAssets(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listAssets(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + ListFindingsResponse.ListFindingsResult responsesElement = + ListFindingsResponse.ListFindingsResult.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllListFindingsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListFindingsPagedResponse pagedListResponse = client.listFindings(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListFindingsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listFindings(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMuteConfigsTest() throws Exception { + MuteConfig responsesElement = MuteConfig.newBuilder().build(); + ListMuteConfigsResponse expectedResponse = + ListMuteConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllMuteConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMuteConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listMuteConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMuteConfigsTest2() throws Exception { + MuteConfig responsesElement = MuteConfig.newBuilder().build(); + ListMuteConfigsResponse expectedResponse = + ListMuteConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllMuteConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMuteConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listMuteConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMuteConfigsTest3() throws Exception { + MuteConfig responsesElement = MuteConfig.newBuilder().build(); + ListMuteConfigsResponse expectedResponse = + ListMuteConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllMuteConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMuteConfigsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listMuteConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMuteConfigsTest4() throws Exception { + MuteConfig responsesElement = MuteConfig.newBuilder().build(); + ListMuteConfigsResponse expectedResponse = + ListMuteConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllMuteConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListMuteConfigsPagedResponse pagedListResponse = client.listMuteConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getMuteConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listMuteConfigsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listMuteConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationConfigsTest() throws Exception { + NotificationConfig responsesElement = NotificationConfig.newBuilder().build(); + ListNotificationConfigsResponse expectedResponse = + ListNotificationConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNotificationConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listNotificationConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationConfigsTest2() throws Exception { + NotificationConfig responsesElement = NotificationConfig.newBuilder().build(); + ListNotificationConfigsResponse expectedResponse = + ListNotificationConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNotificationConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listNotificationConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest2() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest3() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest4() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runAssetDiscoveryTest() throws Exception { + RunAssetDiscoveryResponse expectedResponse = + RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void runAssetDiscoveryTest2() throws Exception { + RunAssetDiscoveryResponse expectedResponse = + RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "organizations/organization-8287"; + + RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setFindingStateTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setFindingStateTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setMuteTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.Mute mute = Finding.Mute.forNumber(0); + + Finding actualResponse = client.setMute(name, mute); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setMuteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.Mute mute = Finding.Mute.forNumber(0); + client.setMute(name, mute); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setMuteTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.Mute mute = Finding.Mute.forNumber(0); + + Finding actualResponse = client.setMute(name, mute); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setMuteExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.Mute mute = Finding.Mute.forNumber(0); + client.setMute(name, mute); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateExternalSystemTest() throws Exception { + ExternalSystem expectedResponse = + ExternalSystem.newBuilder() + .setName("name3373707") + .addAllAssignees(new ArrayList()) + .setExternalUid("externalUid-1153085307") + .setStatus("status-892481550") + .setExternalSystemUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ExternalSystem externalSystem = + ExternalSystem.newBuilder() + .setName( + "organizations/organization-5115/sources/source-5115/findings/finding-5115/externalSystems/externalSystem-5115") + .addAllAssignees(new ArrayList()) + .setExternalUid("externalUid-1153085307") + .setStatus("status-892481550") + .setExternalSystemUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ExternalSystem actualResponse = client.updateExternalSystem(externalSystem, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateExternalSystemExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExternalSystem externalSystem = + ExternalSystem.newBuilder() + .setName( + "organizations/organization-5115/sources/source-5115/findings/finding-5115/externalSystems/externalSystem-5115") + .addAllAssignees(new ArrayList()) + .setExternalUid("externalUid-1153085307") + .setStatus("status-892481550") + .setExternalSystemUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateExternalSystem(externalSystem, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + mockService.addResponse(expectedResponse); + + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + + Finding actualResponse = client.updateFinding(finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .setIndicator(Indicator.newBuilder().build()) + .setVulnerability(Vulnerability.newBuilder().build()) + .setMuteUpdateTime(Timestamp.newBuilder().build()) + .putAllExternalSystems(new HashMap()) + .setMitreAttack(MitreAttack.newBuilder().build()) + .setAccess(Access.newBuilder().build()) + .addAllConnections(new ArrayList()) + .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) + .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) + .addAllIamBindings(new ArrayList()) + .setNextSteps("nextSteps1206138868") + .build(); + client.updateFinding(finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateMuteConfigTest() throws Exception { + MuteConfig expectedResponse = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + mockService.addResponse(expectedResponse); + + MuteConfig muteConfig = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + MuteConfig actualResponse = client.updateMuteConfig(muteConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateMuteConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + MuteConfig muteConfig = + MuteConfig.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateMuteConfig(muteConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + + NotificationConfig actualResponse = client.updateNotificationConfig(notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + client.updateNotificationConfig(notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + NotificationConfig actualResponse = + client.updateNotificationConfig(notificationConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateNotificationConfig(notificationConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + + OrganizationSettings actualResponse = client.updateOrganizationSettings(organizationSettings); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig( + OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + client.updateOrganizationSettings(organizationSettings); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + + Source actualResponse = client.updateSource(source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + client.updateSource(source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSecurityMarksTest() throws Exception { + SecurityMarks expectedResponse = + SecurityMarks.newBuilder() + .setName("name3373707") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + + SecurityMarks actualResponse = client.updateSecurityMarks(securityMarks); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSecurityMarksExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + client.updateSecurityMarks(securityMarks); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBigQueryExportTest() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + + BigQueryExport actualResponse = + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBigQueryExportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBigQueryExportTest2() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + + BigQueryExport actualResponse = + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBigQueryExportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBigQueryExportTest3() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + + BigQueryExport actualResponse = + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBigQueryExportExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBigQueryExportTest4() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + + BigQueryExport actualResponse = + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBigQueryExportExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + client.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBigQueryExportTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + + client.deleteBigQueryExport(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBigQueryExportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + client.deleteBigQueryExport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBigQueryExportTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683"; + + client.deleteBigQueryExport(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBigQueryExportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-3683/bigQueryExports/bigQueryExport-3683"; + client.deleteBigQueryExport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBigQueryExportTest() throws Exception { + BigQueryExport expectedResponse = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + mockService.addResponse(expectedResponse); + + BigQueryExport bigQueryExport = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BigQueryExport actualResponse = client.updateBigQueryExport(bigQueryExport, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateBigQueryExportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BigQueryExport bigQueryExport = + BigQueryExport.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .setDescription("description-1724546052") + .setFilter("filter-1274492040") + .setDataset("dataset1443214456") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setMostRecentEditor("mostRecentEditor-833861941") + .setPrincipal("principal-1812041682") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBigQueryExport(bigQueryExport, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBigQueryExportsTest() throws Exception { + BigQueryExport responsesElement = BigQueryExport.newBuilder().build(); + ListBigQueryExportsResponse expectedResponse = + ListBigQueryExportsResponse.newBuilder() + .setNextPageToken("") + .addAllBigQueryExports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBigQueryExportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listBigQueryExports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBigQueryExportsTest2() throws Exception { + BigQueryExport responsesElement = BigQueryExport.newBuilder().build(); + ListBigQueryExportsResponse expectedResponse = + ListBigQueryExportsResponse.newBuilder() + .setNextPageToken("") + .addAllBigQueryExports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBigQueryExportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listBigQueryExports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBigQueryExportsTest3() throws Exception { + BigQueryExport responsesElement = BigQueryExport.newBuilder().build(); + ListBigQueryExportsResponse expectedResponse = + ListBigQueryExportsResponse.newBuilder() + .setNextPageToken("") + .addAllBigQueryExports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBigQueryExportsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listBigQueryExports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBigQueryExportsTest4() throws Exception { + BigQueryExport responsesElement = BigQueryExport.newBuilder().build(); + ListBigQueryExportsResponse expectedResponse = + ListBigQueryExportsResponse.newBuilder() + .setNextPageToken("") + .addAllBigQueryExports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBigQueryExportsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listBigQueryExports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} 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 3867482fc..0e5b30f22 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 @@ -304,7 +304,10 @@ public void createFindingTest() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -371,7 +374,10 @@ public void createFindingTest2() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -1258,7 +1264,7 @@ public void getIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy actualResponse = client.getIamPolicy(resource); Assert.assertEquals(expectedResponse, actualResponse); @@ -1280,7 +1286,7 @@ public void getIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); client.getIamPolicy(resource); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { @@ -2539,7 +2545,10 @@ public void setFindingStateTest() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -2608,7 +2617,10 @@ public void setFindingStateTest2() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -2675,7 +2687,10 @@ public void setMuteTest() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -2741,7 +2756,10 @@ public void setMuteTest2() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); @@ -2791,7 +2809,7 @@ public void setIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); Policy actualResponse = client.setIamPolicy(resource, policy); @@ -2815,7 +2833,7 @@ public void setIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); client.setIamPolicy(resource, policy); Assert.fail("No exception raised"); @@ -2874,7 +2892,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); @@ -2898,7 +2916,7 @@ public void testIamPermissionsExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); client.testIamPermissions(resource, permissions); Assert.fail("No exception raised"); @@ -3017,7 +3035,10 @@ public void updateFindingTest() throws Exception { .setAccess(Access.newBuilder().build()) .addAllConnections(new ArrayList()) .setMuteInitiator("muteInitiator1395645462") + .addAllProcesses(new ArrayList()) + .addAllCompliances(new ArrayList()) .setDescription("description-1724546052") + .setExfiltration(Exfiltration.newBuilder().build()) .addAllIamBindings(new ArrayList()) .setNextSteps("nextSteps1206138868") .build(); diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientHttpJsonTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000..3577b9916 --- /dev/null +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientHttpJsonTest.java @@ -0,0 +1,1623 @@ +/* + * Copyright 2022 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.v1beta1; + +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1beta1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1beta1.stub.HttpJsonSecurityCenterStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SecurityCenterClientHttpJsonTest { + private static MockHttpService mockService; + private static SecurityCenterClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSecurityCenterStub.getMethodDescriptors(), + SecurityCenterSettings.getDefaultEndpoint()); + SecurityCenterSettings settings = + SecurityCenterSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SecurityCenterClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest2() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9995/organizationSettings"; + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9995/organizationSettings"; + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + SourceName name = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName name = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7292/sources/source-7292"; + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7292/sources/source-7292"; + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupAssetsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupAssetsResponse expectedResponse = + GroupAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + GroupAssetsPagedResponse pagedListResponse = client.groupAssets(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.groupAssets(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest2() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListAssetsPagedResponse pagedListResponse = client.listAssets(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listAssets(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + Finding responsesElement = Finding.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllFindings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + ListFindingsPagedResponse pagedListResponse = client.listFindings(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getFindingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.listFindings(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest2() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runAssetDiscoveryTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + client.runAssetDiscoveryAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void runAssetDiscoveryTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "organizations/organization-8287"; + + client.runAssetDiscoveryAsync(parent).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setFindingStateTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setFindingStateTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Finding finding = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + + Finding actualResponse = client.updateFinding(finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Finding finding = + Finding.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .build(); + client.updateFinding(finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + + OrganizationSettings actualResponse = client.updateOrganizationSettings(organizationSettings); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig( + OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + client.updateOrganizationSettings(organizationSettings); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + Source source = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + + Source actualResponse = client.updateSource(source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Source source = + Source.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .build(); + client.updateSource(source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSecurityMarksTest() throws Exception { + SecurityMarks expectedResponse = + SecurityMarks.newBuilder() + .setName("name3373707") + .putAllMarks(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .build(); + + SecurityMarks actualResponse = client.updateSecurityMarks(securityMarks); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSecurityMarksExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .build(); + client.updateSecurityMarks(securityMarks); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientTest.java index fb6006322..ac9e9515b 100644 --- a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientTest.java +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1beta1/SecurityCenterClientTest.java @@ -303,7 +303,7 @@ public void getIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); Policy actualResponse = client.getIamPolicy(resource); Assert.assertEquals(expectedResponse, actualResponse); @@ -325,7 +325,7 @@ public void getIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); client.getIamPolicy(resource); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { @@ -1126,7 +1126,7 @@ public void setIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); Policy actualResponse = client.setIamPolicy(resource, policy); @@ -1150,7 +1150,7 @@ public void setIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); client.setIamPolicy(resource, policy); Assert.fail("No exception raised"); @@ -1209,7 +1209,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); @@ -1233,7 +1233,7 @@ public void testIamPermissionsExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = OrganizationName.of("[ORGANIZATION]"); + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); client.testIamPermissions(resource, permissions); Assert.fail("No exception raised"); diff --git a/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientHttpJsonTest.java b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientHttpJsonTest.java new file mode 100644 index 000000000..dce80265b --- /dev/null +++ b/google-cloud-securitycenter/src/test/java/com/google/cloud/securitycenter/v1p1beta1/SecurityCenterClientHttpJsonTest.java @@ -0,0 +1,2880 @@ +/* + * Copyright 2022 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.v1p1beta1; + +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.GroupAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.GroupFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListAssetsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListFindingsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListNotificationConfigsPagedResponse; +import static com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListSourcesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1p1beta1.stub.HttpJsonSecurityCenterStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.Policy; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.protobuf.Value; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SecurityCenterClientHttpJsonTest { + private static MockHttpService mockService; + private static SecurityCenterClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSecurityCenterStub.getMethodDescriptors(), + SecurityCenterSettings.getDefaultEndpoint()); + SecurityCenterSettings settings = + SecurityCenterSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SecurityCenterClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + + Source actualResponse = client.createSource(parent, source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + Source source = Source.newBuilder().build(); + client.createSource(parent, source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + + Finding actualResponse = client.createFinding(parent, finding, findingId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + client.createFinding(parent, finding, findingId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest3() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + + Finding actualResponse = client.createFinding(parent, finding, findingId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + client.createFinding(parent, finding, findingId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createFindingTest4() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + + Finding actualResponse = client.createFinding(parent, findingId, finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createFindingExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + client.createFinding(parent, findingId, finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = client.createNotificationConfig(parent, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest3() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNotificationConfigTest4() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + + NotificationConfig actualResponse = + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNotificationConfigExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + client.createNotificationConfig(parent, configId, notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNotificationConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + + client.deleteNotificationConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + client.deleteNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNotificationConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + + client.deleteNotificationConfig(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + client.deleteNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + + NotificationConfig actualResponse = client.getNotificationConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + client.getNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + + NotificationConfig actualResponse = client.getNotificationConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7374/notificationConfigs/notificationConfig-7374"; + client.getNotificationConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOrganizationSettingsTest2() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9995/organizationSettings"; + + OrganizationSettings actualResponse = client.getOrganizationSettings(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getOrganizationSettingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9995/organizationSettings"; + client.getOrganizationSettings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-7292/sources/source-7292"; + + Source actualResponse = client.getSource(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-7292/sources/source-7292"; + client.getSource(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupAssetsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupAssetsResponse expectedResponse = + GroupAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + + GroupAssetsPagedResponse pagedListResponse = client.groupAssets(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.groupAssets(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void groupFindingsTest2() throws Exception { + GroupResult responsesElement = GroupResult.newBuilder().build(); + GroupFindingsResponse expectedResponse = + GroupFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllGroupByResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + + GroupFindingsPagedResponse pagedListResponse = client.groupFindings(parent, groupBy); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGroupByResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void groupFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + String groupBy = "groupBy293428022"; + client.groupFindings(parent, groupBy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListAssetsPagedResponse pagedListResponse = client.listAssets(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listAssets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest2() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListAssetsPagedResponse pagedListResponse = client.listAssets(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listAssets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest3() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListAssetsPagedResponse pagedListResponse = client.listAssets(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listAssets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAssetsTest4() throws Exception { + ListAssetsResponse.ListAssetsResult responsesElement = + ListAssetsResponse.ListAssetsResult.newBuilder().build(); + ListAssetsResponse expectedResponse = + ListAssetsResponse.newBuilder() + .setNextPageToken("") + .addAllListAssetsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListAssetsPagedResponse pagedListResponse = client.listAssets(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListAssetsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAssetsExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listAssets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest() throws Exception { + ListFindingsResponse.ListFindingsResult responsesElement = + ListFindingsResponse.ListFindingsResult.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllListFindingsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListFindingsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + client.listFindings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFindingsTest2() throws Exception { + ListFindingsResponse.ListFindingsResult responsesElement = + ListFindingsResponse.ListFindingsResult.newBuilder().build(); + ListFindingsResponse expectedResponse = + ListFindingsResponse.newBuilder() + .setNextPageToken("") + .addAllListFindingsResults(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8741/sources/source-8741"; + + ListFindingsPagedResponse pagedListResponse = client.listFindings(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getListFindingsResultsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFindingsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8741/sources/source-8741"; + client.listFindings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationConfigsTest() throws Exception { + NotificationConfig responsesElement = NotificationConfig.newBuilder().build(); + ListNotificationConfigsResponse expectedResponse = + ListNotificationConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNotificationConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listNotificationConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationConfigsTest2() throws Exception { + NotificationConfig responsesElement = NotificationConfig.newBuilder().build(); + ListNotificationConfigsResponse expectedResponse = + ListNotificationConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNotificationConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listNotificationConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest2() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest3() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSourcesTest4() throws Exception { + Source responsesElement = Source.newBuilder().build(); + ListSourcesResponse expectedResponse = + ListSourcesResponse.newBuilder() + .setNextPageToken("") + .addAllSources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "organizations/organization-8287"; + + ListSourcesPagedResponse pagedListResponse = client.listSources(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSourcesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSourcesExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.listSources(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runAssetDiscoveryTest() throws Exception { + RunAssetDiscoveryResponse expectedResponse = + RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void runAssetDiscoveryTest2() throws Exception { + RunAssetDiscoveryResponse expectedResponse = + RunAssetDiscoveryResponse.newBuilder().setDuration(Duration.newBuilder().build()).build(); + Operation resultOperation = + Operation.newBuilder() + .setName("runAssetDiscoveryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "organizations/organization-8287"; + + RunAssetDiscoveryResponse actualResponse = client.runAssetDiscoveryAsync(parent).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void runAssetDiscoveryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "organizations/organization-8287"; + client.runAssetDiscoveryAsync(parent).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void setFindingStateTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setFindingStateTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + + Finding actualResponse = client.setFindingState(name, state, startTime); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setFindingStateExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "organizations/organization-9392/sources/source-9392/findings/finding-9392"; + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + client.setFindingState(name, state, startTime); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String resource = "organizations/organization-3393/sources/source-3393"; + List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFindingTest() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + + Finding actualResponse = client.updateFinding(finding); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFindingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + client.updateFinding(finding); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFindingTest2() throws Exception { + Finding expectedResponse = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Finding actualResponse = client.updateFinding(finding, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFindingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Finding finding = + Finding.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setParent("parent-995424086") + .setResourceName("resourceName-384566343") + .setCategory("category50511102") + .setExternalUri("externalUri-1153085023") + .putAllSourceProperties(new HashMap()) + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setEventTime(Timestamp.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateFinding(finding, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNotificationConfigTest() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + + NotificationConfig actualResponse = client.updateNotificationConfig(notificationConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNotificationConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + client.updateNotificationConfig(notificationConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNotificationConfigTest2() throws Exception { + NotificationConfig expectedResponse = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + mockService.addResponse(expectedResponse); + + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + NotificationConfig actualResponse = + client.updateNotificationConfig(notificationConfig, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNotificationConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NotificationConfig notificationConfig = + NotificationConfig.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .setDescription("description-1724546052") + .setPubsubTopic("pubsubTopic255880396") + .setServiceAccount("serviceAccount1079137720") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateNotificationConfig(notificationConfig, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateOrganizationSettingsTest() throws Exception { + OrganizationSettings expectedResponse = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig(OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + + OrganizationSettings actualResponse = client.updateOrganizationSettings(organizationSettings); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateOrganizationSettingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OrganizationSettings organizationSettings = + OrganizationSettings.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .setEnableAssetDiscovery(true) + .setAssetDiscoveryConfig( + OrganizationSettings.AssetDiscoveryConfig.newBuilder().build()) + .build(); + client.updateOrganizationSettings(organizationSettings); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSourceTest() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + + Source actualResponse = client.updateSource(source); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSourceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + client.updateSource(source); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSourceTest2() throws Exception { + Source expectedResponse = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Source actualResponse = client.updateSource(source, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSourceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Source source = + Source.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateSource(source, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSecurityMarksTest() throws Exception { + SecurityMarks expectedResponse = + SecurityMarks.newBuilder() + .setName("name3373707") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + + SecurityMarks actualResponse = client.updateSecurityMarks(securityMarks); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSecurityMarksExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + client.updateSecurityMarks(securityMarks); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSecurityMarksTest2() throws Exception { + SecurityMarks expectedResponse = + SecurityMarks.newBuilder() + .setName("name3373707") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + mockService.addResponse(expectedResponse); + + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + SecurityMarks actualResponse = client.updateSecurityMarks(securityMarks, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSecurityMarksExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SecurityMarks securityMarks = + SecurityMarks.newBuilder() + .setName("organizations/organization-5924/assets/asset-5924/securityMarks") + .putAllMarks(new HashMap()) + .setCanonicalName("canonicalName2122381727") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateSecurityMarks(securityMarks, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} 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 c5cfc706c..cec69a74f 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 @@ -690,7 +690,7 @@ public void getIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy actualResponse = client.getIamPolicy(resource); Assert.assertEquals(expectedResponse, actualResponse); @@ -712,7 +712,7 @@ public void getIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); client.getIamPolicy(resource); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { @@ -1930,7 +1930,7 @@ public void setIamPolicyTest() throws Exception { .build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); Policy actualResponse = client.setIamPolicy(resource, policy); @@ -1954,7 +1954,7 @@ public void setIamPolicyExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); Policy policy = Policy.newBuilder().build(); client.setIamPolicy(resource, policy); Assert.fail("No exception raised"); @@ -2013,7 +2013,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); mockSecurityCenter.addResponse(expectedResponse); - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); @@ -2037,7 +2037,7 @@ public void testIamPermissionsExceptionTest() throws Exception { mockSecurityCenter.addException(exception); try { - ResourceName resource = FolderName.of("[FOLDER]"); + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); List permissions = new ArrayList<>(); client.testIamPermissions(resource, permissions); Assert.fail("No exception raised"); diff --git a/grpc-google-cloud-securitycenter-v1/pom.xml b/grpc-google-cloud-securitycenter-v1/pom.xml index c4ea181f3..239e3454f 100644 --- a/grpc-google-cloud-securitycenter-v1/pom.xml +++ b/grpc-google-cloud-securitycenter-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 grpc-google-cloud-securitycenter-v1 GRPC library for grpc-google-cloud-securitycenter-v1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/grpc-google-cloud-securitycenter-v1beta1/pom.xml b/grpc-google-cloud-securitycenter-v1beta1/pom.xml index b30a692d0..73374abdf 100644 --- a/grpc-google-cloud-securitycenter-v1beta1/pom.xml +++ b/grpc-google-cloud-securitycenter-v1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 grpc-google-cloud-securitycenter-v1beta1 GRPC library for grpc-google-cloud-securitycenter-v1beta1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/grpc-google-cloud-securitycenter-v1p1beta1/pom.xml b/grpc-google-cloud-securitycenter-v1p1beta1/pom.xml index 3bbb94e5e..817309d9e 100644 --- a/grpc-google-cloud-securitycenter-v1p1beta1/pom.xml +++ b/grpc-google-cloud-securitycenter-v1p1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 grpc-google-cloud-securitycenter-v1p1beta1 GRPC library for grpc-google-cloud-securitycenter-v1p1beta1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/pom.xml b/pom.xml index db762cb17..1b625aa43 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-securitycenter-parent pom - 2.6.0 + 2.7.0 Google Cloud Security Command Center Parent https://github.com/googleapis/java-securitycenter @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 @@ -61,43 +61,43 @@ com.google.api.grpc proto-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 com.google.api.grpc proto-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc proto-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 com.google.api.grpc grpc-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 com.google.cloud google-cloud-securitycenter - 2.6.0 + 2.7.0 com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import diff --git a/proto-google-cloud-securitycenter-v1/pom.xml b/proto-google-cloud-securitycenter-v1/pom.xml index 3e2af7904..2b39c0ede 100644 --- a/proto-google-cloud-securitycenter-v1/pom.xml +++ b/proto-google-cloud-securitycenter-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-securitycenter-v1 - 2.6.0 + 2.7.0 proto-google-cloud-securitycenter-v1 PROTO library for proto-google-cloud-securitycenter-v1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Compliance.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Compliance.java new file mode 100644 index 000000000..0ab2a44ae --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Compliance.java @@ -0,0 +1,1103 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/compliance.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *

+ * Contains compliance information about a security standard indicating unmet
+ * recommendations.
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Compliance} + */ +public final class Compliance extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.Compliance) + ComplianceOrBuilder { + private static final long serialVersionUID = 0L; + // Use Compliance.newBuilder() to construct. + private Compliance(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Compliance() { + standard_ = ""; + version_ = ""; + ids_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Compliance(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Compliance( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + standard_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + version_ = s; + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + ids_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + ids_.add(s); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + ids_ = ids_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ComplianceProto + .internal_static_google_cloud_securitycenter_v1_Compliance_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ComplianceProto + .internal_static_google_cloud_securitycenter_v1_Compliance_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Compliance.class, + com.google.cloud.securitycenter.v1.Compliance.Builder.class); + } + + public static final int STANDARD_FIELD_NUMBER = 1; + private volatile java.lang.Object standard_; + /** + * + * + *
+   * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+   * etc.
+   * 
+ * + * string standard = 1; + * + * @return The standard. + */ + @java.lang.Override + public java.lang.String getStandard() { + java.lang.Object ref = standard_; + 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(); + standard_ = s; + return s; + } + } + /** + * + * + *
+   * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+   * etc.
+   * 
+ * + * string standard = 1; + * + * @return The bytes for standard. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStandardBytes() { + java.lang.Object ref = standard_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + standard_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VERSION_FIELD_NUMBER = 2; + private volatile java.lang.Object version_; + /** + * + * + *
+   * Version of the standard/benchmark e.g. 1.1
+   * 
+ * + * string version = 2; + * + * @return The version. + */ + @java.lang.Override + public java.lang.String getVersion() { + java.lang.Object ref = version_; + 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(); + version_ = s; + return s; + } + } + /** + * + * + *
+   * Version of the standard/benchmark e.g. 1.1
+   * 
+ * + * string version = 2; + * + * @return The bytes for version. + */ + @java.lang.Override + public com.google.protobuf.ByteString getVersionBytes() { + java.lang.Object ref = version_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int IDS_FIELD_NUMBER = 3; + private com.google.protobuf.LazyStringList ids_; + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @return A list containing the ids. + */ + public com.google.protobuf.ProtocolStringList getIdsList() { + return ids_; + } + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @return The count of ids. + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @param index The index of the element to return. + * @return The ids at the given index. + */ + public java.lang.String getIds(int index) { + return ids_.get(index); + } + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @param index The index of the value to return. + * @return The bytes of the ids at the given index. + */ + public com.google.protobuf.ByteString getIdsBytes(int index) { + return ids_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(standard_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, standard_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(version_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, version_); + } + for (int i = 0; i < ids_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, ids_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(standard_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, standard_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(version_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, version_); + } + { + int dataSize = 0; + for (int i = 0; i < ids_.size(); i++) { + dataSize += computeStringSizeNoTag(ids_.getRaw(i)); + } + size += dataSize; + size += 1 * getIdsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.Compliance)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.Compliance other = + (com.google.cloud.securitycenter.v1.Compliance) obj; + + if (!getStandard().equals(other.getStandard())) return false; + if (!getVersion().equals(other.getVersion())) return false; + if (!getIdsList().equals(other.getIdsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STANDARD_FIELD_NUMBER; + hash = (53 * hash) + getStandard().hashCode(); + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion().hashCode(); + if (getIdsCount() > 0) { + hash = (37 * hash) + IDS_FIELD_NUMBER; + hash = (53 * hash) + getIdsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Compliance parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.cloud.securitycenter.v1.Compliance prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Contains compliance information about a security standard indicating unmet
+   * recommendations.
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Compliance} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.Compliance) + com.google.cloud.securitycenter.v1.ComplianceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ComplianceProto + .internal_static_google_cloud_securitycenter_v1_Compliance_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ComplianceProto + .internal_static_google_cloud_securitycenter_v1_Compliance_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Compliance.class, + com.google.cloud.securitycenter.v1.Compliance.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.Compliance.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + standard_ = ""; + + version_ = ""; + + ids_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.ComplianceProto + .internal_static_google_cloud_securitycenter_v1_Compliance_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Compliance getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.Compliance.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Compliance build() { + com.google.cloud.securitycenter.v1.Compliance result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Compliance buildPartial() { + com.google.cloud.securitycenter.v1.Compliance result = + new com.google.cloud.securitycenter.v1.Compliance(this); + int from_bitField0_ = bitField0_; + result.standard_ = standard_; + result.version_ = version_; + if (((bitField0_ & 0x00000001) != 0)) { + ids_ = ids_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.ids_ = ids_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.Compliance) { + return mergeFrom((com.google.cloud.securitycenter.v1.Compliance) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.Compliance other) { + if (other == com.google.cloud.securitycenter.v1.Compliance.getDefaultInstance()) return this; + if (!other.getStandard().isEmpty()) { + standard_ = other.standard_; + onChanged(); + } + if (!other.getVersion().isEmpty()) { + version_ = other.version_; + onChanged(); + } + if (!other.ids_.isEmpty()) { + if (ids_.isEmpty()) { + ids_ = other.ids_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIdsIsMutable(); + ids_.addAll(other.ids_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.Compliance parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.securitycenter.v1.Compliance) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object standard_ = ""; + /** + * + * + *
+     * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+     * etc.
+     * 
+ * + * string standard = 1; + * + * @return The standard. + */ + public java.lang.String getStandard() { + java.lang.Object ref = standard_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + standard_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+     * etc.
+     * 
+ * + * string standard = 1; + * + * @return The bytes for standard. + */ + public com.google.protobuf.ByteString getStandardBytes() { + java.lang.Object ref = standard_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + standard_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+     * etc.
+     * 
+ * + * string standard = 1; + * + * @param value The standard to set. + * @return This builder for chaining. + */ + public Builder setStandard(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + standard_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+     * etc.
+     * 
+ * + * string standard = 1; + * + * @return This builder for chaining. + */ + public Builder clearStandard() { + + standard_ = getDefaultInstance().getStandard(); + onChanged(); + return this; + } + /** + * + * + *
+     * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+     * etc.
+     * 
+ * + * string standard = 1; + * + * @param value The bytes for standard to set. + * @return This builder for chaining. + */ + public Builder setStandardBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + standard_ = value; + onChanged(); + return this; + } + + private java.lang.Object version_ = ""; + /** + * + * + *
+     * Version of the standard/benchmark e.g. 1.1
+     * 
+ * + * string version = 2; + * + * @return The version. + */ + public java.lang.String getVersion() { + java.lang.Object ref = version_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + version_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Version of the standard/benchmark e.g. 1.1
+     * 
+ * + * string version = 2; + * + * @return The bytes for version. + */ + public com.google.protobuf.ByteString getVersionBytes() { + java.lang.Object ref = version_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + version_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Version of the standard/benchmark e.g. 1.1
+     * 
+ * + * string version = 2; + * + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + version_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Version of the standard/benchmark e.g. 1.1
+     * 
+ * + * string version = 2; + * + * @return This builder for chaining. + */ + public Builder clearVersion() { + + version_ = getDefaultInstance().getVersion(); + onChanged(); + return this; + } + /** + * + * + *
+     * Version of the standard/benchmark e.g. 1.1
+     * 
+ * + * string version = 2; + * + * @param value The bytes for version to set. + * @return This builder for chaining. + */ + public Builder setVersionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + version_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList ids_ = com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureIdsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + ids_ = new com.google.protobuf.LazyStringArrayList(ids_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @return A list containing the ids. + */ + public com.google.protobuf.ProtocolStringList getIdsList() { + return ids_.getUnmodifiableView(); + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @return The count of ids. + */ + public int getIdsCount() { + return ids_.size(); + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param index The index of the element to return. + * @return The ids at the given index. + */ + public java.lang.String getIds(int index) { + return ids_.get(index); + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param index The index of the value to return. + * @return The bytes of the ids at the given index. + */ + public com.google.protobuf.ByteString getIdsBytes(int index) { + return ids_.getByteString(index); + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param index The index to set the value at. + * @param value The ids to set. + * @return This builder for chaining. + */ + public Builder setIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param value The ids to add. + * @return This builder for chaining. + */ + public Builder addIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureIdsIsMutable(); + ids_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param values The ids to add. + * @return This builder for chaining. + */ + public Builder addAllIds(java.lang.Iterable values) { + ensureIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, ids_); + onChanged(); + return this; + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @return This builder for chaining. + */ + public Builder clearIds() { + ids_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Policies within the standard/benchmark e.g. A.12.4.1
+     * 
+ * + * repeated string ids = 3; + * + * @param value The bytes of the ids to add. + * @return This builder for chaining. + */ + public Builder addIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureIdsIsMutable(); + ids_.add(value); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.Compliance) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.Compliance) + private static final com.google.cloud.securitycenter.v1.Compliance DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.Compliance(); + } + + public static com.google.cloud.securitycenter.v1.Compliance getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Compliance parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Compliance(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Compliance getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceOrBuilder.java new file mode 100644 index 000000000..5c95e93b5 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceOrBuilder.java @@ -0,0 +1,128 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/compliance.proto + +package com.google.cloud.securitycenter.v1; + +public interface ComplianceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.Compliance) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+   * etc.
+   * 
+ * + * string standard = 1; + * + * @return The standard. + */ + java.lang.String getStandard(); + /** + * + * + *
+   * Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp",
+   * etc.
+   * 
+ * + * string standard = 1; + * + * @return The bytes for standard. + */ + com.google.protobuf.ByteString getStandardBytes(); + + /** + * + * + *
+   * Version of the standard/benchmark e.g. 1.1
+   * 
+ * + * string version = 2; + * + * @return The version. + */ + java.lang.String getVersion(); + /** + * + * + *
+   * Version of the standard/benchmark e.g. 1.1
+   * 
+ * + * string version = 2; + * + * @return The bytes for version. + */ + com.google.protobuf.ByteString getVersionBytes(); + + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @return A list containing the ids. + */ + java.util.List getIdsList(); + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @return The count of ids. + */ + int getIdsCount(); + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @param index The index of the element to return. + * @return The ids at the given index. + */ + java.lang.String getIds(int index); + /** + * + * + *
+   * Policies within the standard/benchmark e.g. A.12.4.1
+   * 
+ * + * repeated string ids = 3; + * + * @param index The index of the value to return. + * @return The bytes of the ids at the given index. + */ + com.google.protobuf.ByteString getIdsBytes(int index); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceProto.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceProto.java new file mode 100644 index 000000000..f6df500c8 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ComplianceProto.java @@ -0,0 +1,68 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/compliance.proto + +package com.google.cloud.securitycenter.v1; + +public final class ComplianceProto { + private ComplianceProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_Compliance_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_Compliance_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n/google/cloud/securitycenter/v1/complia" + + "nce.proto\022\036google.cloud.securitycenter.v" + + "1\"<\n\nCompliance\022\020\n\010standard\030\001 \001(\t\022\017\n\007ver" + + "sion\030\002 \001(\t\022\013\n\003ids\030\003 \003(\tB\353\001\n\"com.google.c" + + "loud.securitycenter.v1B\017ComplianceProtoP" + + "\001ZLgoogle.golang.org/genproto/googleapis" + + "/cloud/securitycenter/v1;securitycenter\252" + + "\002\036Google.Cloud.SecurityCenter.V1\312\002\036Googl" + + "e\\Cloud\\SecurityCenter\\V1\352\002!Google::Clou" + + "d::SecurityCenter::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_cloud_securitycenter_v1_Compliance_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_securitycenter_v1_Compliance_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_Compliance_descriptor, + new java.lang.String[] { + "Standard", "Version", "Ids", + }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariable.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariable.java new file mode 100644 index 000000000..b9509f210 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariable.java @@ -0,0 +1,820 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/process.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *
+ * EnvironmentVariable is a name-value pair to store environment variables for
+ * Process.
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.EnvironmentVariable} + */ +public final class EnvironmentVariable extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.EnvironmentVariable) + EnvironmentVariableOrBuilder { + private static final long serialVersionUID = 0L; + // Use EnvironmentVariable.newBuilder() to construct. + private EnvironmentVariable(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private EnvironmentVariable() { + name_ = ""; + val_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new EnvironmentVariable(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private EnvironmentVariable( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + val_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.EnvironmentVariable.class, + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Environment variable name as a JSON encoded string.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Environment variable name as a JSON encoded string.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VAL_FIELD_NUMBER = 2; + private volatile java.lang.Object val_; + /** + * + * + *
+   * Environment variable value as a JSON encoded string.
+   * 
+ * + * string val = 2; + * + * @return The val. + */ + @java.lang.Override + public java.lang.String getVal() { + java.lang.Object ref = val_; + 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(); + val_ = s; + return s; + } + } + /** + * + * + *
+   * Environment variable value as a JSON encoded string.
+   * 
+ * + * string val = 2; + * + * @return The bytes for val. + */ + @java.lang.Override + public com.google.protobuf.ByteString getValBytes() { + java.lang.Object ref = val_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + val_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(val_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, val_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(val_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, val_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.EnvironmentVariable)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.EnvironmentVariable other = + (com.google.cloud.securitycenter.v1.EnvironmentVariable) obj; + + if (!getName().equals(other.getName())) return false; + if (!getVal().equals(other.getVal())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + VAL_FIELD_NUMBER; + hash = (53 * hash) + getVal().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.cloud.securitycenter.v1.EnvironmentVariable prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * EnvironmentVariable is a name-value pair to store environment variables for
+   * Process.
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.EnvironmentVariable} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.EnvironmentVariable) + com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.EnvironmentVariable.class, + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.EnvironmentVariable.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + val_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariable getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.EnvironmentVariable.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariable build() { + com.google.cloud.securitycenter.v1.EnvironmentVariable result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariable buildPartial() { + com.google.cloud.securitycenter.v1.EnvironmentVariable result = + new com.google.cloud.securitycenter.v1.EnvironmentVariable(this); + result.name_ = name_; + result.val_ = val_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.EnvironmentVariable) { + return mergeFrom((com.google.cloud.securitycenter.v1.EnvironmentVariable) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.EnvironmentVariable other) { + if (other == com.google.cloud.securitycenter.v1.EnvironmentVariable.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getVal().isEmpty()) { + val_ = other.val_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.EnvironmentVariable parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.securitycenter.v1.EnvironmentVariable) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Environment variable name as a JSON encoded string.
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Environment variable name as a JSON encoded string.
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Environment variable name as a JSON encoded string.
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Environment variable name as a JSON encoded string.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Environment variable name as a JSON encoded string.
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object val_ = ""; + /** + * + * + *
+     * Environment variable value as a JSON encoded string.
+     * 
+ * + * string val = 2; + * + * @return The val. + */ + public java.lang.String getVal() { + java.lang.Object ref = val_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + val_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Environment variable value as a JSON encoded string.
+     * 
+ * + * string val = 2; + * + * @return The bytes for val. + */ + public com.google.protobuf.ByteString getValBytes() { + java.lang.Object ref = val_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + val_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Environment variable value as a JSON encoded string.
+     * 
+ * + * string val = 2; + * + * @param value The val to set. + * @return This builder for chaining. + */ + public Builder setVal(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + val_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Environment variable value as a JSON encoded string.
+     * 
+ * + * string val = 2; + * + * @return This builder for chaining. + */ + public Builder clearVal() { + + val_ = getDefaultInstance().getVal(); + onChanged(); + return this; + } + /** + * + * + *
+     * Environment variable value as a JSON encoded string.
+     * 
+ * + * string val = 2; + * + * @param value The bytes for val to set. + * @return This builder for chaining. + */ + public Builder setValBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + val_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.EnvironmentVariable) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.EnvironmentVariable) + private static final com.google.cloud.securitycenter.v1.EnvironmentVariable DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.EnvironmentVariable(); + } + + public static com.google.cloud.securitycenter.v1.EnvironmentVariable getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EnvironmentVariable parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new EnvironmentVariable(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariable getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariableOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariableOrBuilder.java new file mode 100644 index 000000000..a041145cf --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/EnvironmentVariableOrBuilder.java @@ -0,0 +1,75 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/process.proto + +package com.google.cloud.securitycenter.v1; + +public interface EnvironmentVariableOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.EnvironmentVariable) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Environment variable name as a JSON encoded string.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Environment variable name as a JSON encoded string.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Environment variable value as a JSON encoded string.
+   * 
+ * + * string val = 2; + * + * @return The val. + */ + java.lang.String getVal(); + /** + * + * + *
+   * Environment variable value as a JSON encoded string.
+   * 
+ * + * string val = 2; + * + * @return The bytes for val. + */ + com.google.protobuf.ByteString getValBytes(); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResource.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResource.java new file mode 100644 index 000000000..79365402d --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResource.java @@ -0,0 +1,956 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/exfiltration.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *
+ * Resource that has been exfiltrated or exfiltrated_to.
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.ExfilResource} + */ +public final class ExfilResource extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.ExfilResource) + ExfilResourceOrBuilder { + private static final long serialVersionUID = 0L; + // Use ExfilResource.newBuilder() to construct. + private ExfilResource(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExfilResource() { + name_ = ""; + components_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExfilResource(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ExfilResource( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + components_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + components_.add(s); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + components_ = components_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_ExfilResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.ExfilResource.class, + com.google.cloud.securitycenter.v1.ExfilResource.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Resource's URI (https://google.aip.dev/122#full-resource-names)
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Resource's URI (https://google.aip.dev/122#full-resource-names)
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COMPONENTS_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList components_; + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @return A list containing the components. + */ + public com.google.protobuf.ProtocolStringList getComponentsList() { + return components_; + } + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @return The count of components. + */ + public int getComponentsCount() { + return components_.size(); + } + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @param index The index of the element to return. + * @return The components at the given index. + */ + public java.lang.String getComponents(int index) { + return components_.get(index); + } + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @param index The index of the value to return. + * @return The bytes of the components at the given index. + */ + public com.google.protobuf.ByteString getComponentsBytes(int index) { + return components_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + for (int i = 0; i < components_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, components_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < components_.size(); i++) { + dataSize += computeStringSizeNoTag(components_.getRaw(i)); + } + size += dataSize; + size += 1 * getComponentsList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.ExfilResource)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.ExfilResource other = + (com.google.cloud.securitycenter.v1.ExfilResource) obj; + + if (!getName().equals(other.getName())) return false; + if (!getComponentsList().equals(other.getComponentsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getComponentsCount() > 0) { + hash = (37 * hash) + COMPONENTS_FIELD_NUMBER; + hash = (53 * hash) + getComponentsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.cloud.securitycenter.v1.ExfilResource prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Resource that has been exfiltrated or exfiltrated_to.
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.ExfilResource} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.ExfilResource) + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_ExfilResource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.ExfilResource.class, + com.google.cloud.securitycenter.v1.ExfilResource.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.ExfilResource.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + components_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource build() { + com.google.cloud.securitycenter.v1.ExfilResource result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource buildPartial() { + com.google.cloud.securitycenter.v1.ExfilResource result = + new com.google.cloud.securitycenter.v1.ExfilResource(this); + int from_bitField0_ = bitField0_; + result.name_ = name_; + if (((bitField0_ & 0x00000001) != 0)) { + components_ = components_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.components_ = components_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.ExfilResource) { + return mergeFrom((com.google.cloud.securitycenter.v1.ExfilResource) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.ExfilResource other) { + if (other == com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.components_.isEmpty()) { + if (components_.isEmpty()) { + components_ = other.components_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureComponentsIsMutable(); + components_.addAll(other.components_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.ExfilResource parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.securitycenter.v1.ExfilResource) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Resource's URI (https://google.aip.dev/122#full-resource-names)
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Resource's URI (https://google.aip.dev/122#full-resource-names)
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Resource's URI (https://google.aip.dev/122#full-resource-names)
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Resource's URI (https://google.aip.dev/122#full-resource-names)
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Resource's URI (https://google.aip.dev/122#full-resource-names)
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList components_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureComponentsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + components_ = new com.google.protobuf.LazyStringArrayList(components_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @return A list containing the components. + */ + public com.google.protobuf.ProtocolStringList getComponentsList() { + return components_.getUnmodifiableView(); + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @return The count of components. + */ + public int getComponentsCount() { + return components_.size(); + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param index The index of the element to return. + * @return The components at the given index. + */ + public java.lang.String getComponents(int index) { + return components_.get(index); + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param index The index of the value to return. + * @return The bytes of the components at the given index. + */ + public com.google.protobuf.ByteString getComponentsBytes(int index) { + return components_.getByteString(index); + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param index The index to set the value at. + * @param value The components to set. + * @return This builder for chaining. + */ + public Builder setComponents(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureComponentsIsMutable(); + components_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param value The components to add. + * @return This builder for chaining. + */ + public Builder addComponents(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureComponentsIsMutable(); + components_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param values The components to add. + * @return This builder for chaining. + */ + public Builder addAllComponents(java.lang.Iterable values) { + ensureComponentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, components_); + onChanged(); + return this; + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @return This builder for chaining. + */ + public Builder clearComponents() { + components_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Subcomponents of the asset that is exfiltrated - these could be
+     * URIs used during exfiltration, table names, databases, filenames, etc.
+     * For example, multiple tables may be exfiltrated from the same CloudSQL
+     * instance, or multiple files from the same Cloud Storage bucket.
+     * 
+ * + * repeated string components = 2; + * + * @param value The bytes of the components to add. + * @return This builder for chaining. + */ + public Builder addComponentsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureComponentsIsMutable(); + components_.add(value); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.ExfilResource) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.ExfilResource) + private static final com.google.cloud.securitycenter.v1.ExfilResource DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.ExfilResource(); + } + + public static com.google.cloud.securitycenter.v1.ExfilResource getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExfilResource parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ExfilResource(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResourceOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResourceOrBuilder.java new file mode 100644 index 000000000..40756efb7 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfilResourceOrBuilder.java @@ -0,0 +1,113 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/exfiltration.proto + +package com.google.cloud.securitycenter.v1; + +public interface ExfilResourceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.ExfilResource) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Resource's URI (https://google.aip.dev/122#full-resource-names)
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Resource's URI (https://google.aip.dev/122#full-resource-names)
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @return A list containing the components. + */ + java.util.List getComponentsList(); + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @return The count of components. + */ + int getComponentsCount(); + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @param index The index of the element to return. + * @return The components at the given index. + */ + java.lang.String getComponents(int index); + /** + * + * + *
+   * Subcomponents of the asset that is exfiltrated - these could be
+   * URIs used during exfiltration, table names, databases, filenames, etc.
+   * For example, multiple tables may be exfiltrated from the same CloudSQL
+   * instance, or multiple files from the same Cloud Storage bucket.
+   * 
+ * + * repeated string components = 2; + * + * @param index The index of the value to return. + * @return The bytes of the components at the given index. + */ + com.google.protobuf.ByteString getComponentsBytes(int index); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Exfiltration.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Exfiltration.java new file mode 100644 index 000000000..7d864369b --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Exfiltration.java @@ -0,0 +1,1522 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/exfiltration.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *
+ * Exfiltration represents a data exfiltration attempt of one or more
+ * sources to one or more targets.  Sources represent the source
+ * of data that is exfiltrated, and Targets represents the destination the
+ * data was copied to.
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Exfiltration} + */ +public final class Exfiltration extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.Exfiltration) + ExfiltrationOrBuilder { + private static final long serialVersionUID = 0L; + // Use Exfiltration.newBuilder() to construct. + private Exfiltration(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Exfiltration() { + sources_ = java.util.Collections.emptyList(); + targets_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Exfiltration(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Exfiltration( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + sources_ = + new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + sources_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.ExfilResource.parser(), + extensionRegistry)); + break; + } + case 18: + { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + targets_ = + new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + targets_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.ExfilResource.parser(), + extensionRegistry)); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + sources_ = java.util.Collections.unmodifiableList(sources_); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + targets_ = java.util.Collections.unmodifiableList(targets_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_Exfiltration_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Exfiltration.class, + com.google.cloud.securitycenter.v1.Exfiltration.Builder.class); + } + + public static final int SOURCES_FIELD_NUMBER = 1; + private java.util.List sources_; + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + @java.lang.Override + public java.util.List getSourcesList() { + return sources_; + } + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + @java.lang.Override + public java.util.List + getSourcesOrBuilderList() { + return sources_; + } + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + @java.lang.Override + public int getSourcesCount() { + return sources_.size(); + } + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource getSources(int index) { + return sources_.get(index); + } + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getSourcesOrBuilder(int index) { + return sources_.get(index); + } + + public static final int TARGETS_FIELD_NUMBER = 2; + private java.util.List targets_; + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + @java.lang.Override + public java.util.List getTargetsList() { + return targets_; + } + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + @java.lang.Override + public java.util.List + getTargetsOrBuilderList() { + return targets_; + } + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + @java.lang.Override + public int getTargetsCount() { + return targets_.size(); + } + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResource getTargets(int index) { + return targets_.get(index); + } + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getTargetsOrBuilder(int index) { + return targets_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < sources_.size(); i++) { + output.writeMessage(1, sources_.get(i)); + } + for (int i = 0; i < targets_.size(); i++) { + output.writeMessage(2, targets_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < sources_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, sources_.get(i)); + } + for (int i = 0; i < targets_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, targets_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.Exfiltration)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.Exfiltration other = + (com.google.cloud.securitycenter.v1.Exfiltration) obj; + + if (!getSourcesList().equals(other.getSourcesList())) return false; + if (!getTargetsList().equals(other.getTargetsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getSourcesCount() > 0) { + hash = (37 * hash) + SOURCES_FIELD_NUMBER; + hash = (53 * hash) + getSourcesList().hashCode(); + } + if (getTargetsCount() > 0) { + hash = (37 * hash) + TARGETS_FIELD_NUMBER; + hash = (53 * hash) + getTargetsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.cloud.securitycenter.v1.Exfiltration prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Exfiltration represents a data exfiltration attempt of one or more
+   * sources to one or more targets.  Sources represent the source
+   * of data that is exfiltrated, and Targets represents the destination the
+   * data was copied to.
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Exfiltration} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.Exfiltration) + com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_Exfiltration_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Exfiltration.class, + com.google.cloud.securitycenter.v1.Exfiltration.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.Exfiltration.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getSourcesFieldBuilder(); + getTargetsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (sourcesBuilder_ == null) { + sources_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + sourcesBuilder_.clear(); + } + if (targetsBuilder_ == null) { + targets_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + targetsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.ExfiltrationProto + .internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Exfiltration getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.Exfiltration.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Exfiltration build() { + com.google.cloud.securitycenter.v1.Exfiltration result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Exfiltration buildPartial() { + com.google.cloud.securitycenter.v1.Exfiltration result = + new com.google.cloud.securitycenter.v1.Exfiltration(this); + int from_bitField0_ = bitField0_; + if (sourcesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + sources_ = java.util.Collections.unmodifiableList(sources_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.sources_ = sources_; + } else { + result.sources_ = sourcesBuilder_.build(); + } + if (targetsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + targets_ = java.util.Collections.unmodifiableList(targets_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.targets_ = targets_; + } else { + result.targets_ = targetsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.Exfiltration) { + return mergeFrom((com.google.cloud.securitycenter.v1.Exfiltration) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.Exfiltration other) { + if (other == com.google.cloud.securitycenter.v1.Exfiltration.getDefaultInstance()) + return this; + if (sourcesBuilder_ == null) { + if (!other.sources_.isEmpty()) { + if (sources_.isEmpty()) { + sources_ = other.sources_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureSourcesIsMutable(); + sources_.addAll(other.sources_); + } + onChanged(); + } + } else { + if (!other.sources_.isEmpty()) { + if (sourcesBuilder_.isEmpty()) { + sourcesBuilder_.dispose(); + sourcesBuilder_ = null; + sources_ = other.sources_; + bitField0_ = (bitField0_ & ~0x00000001); + sourcesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getSourcesFieldBuilder() + : null; + } else { + sourcesBuilder_.addAllMessages(other.sources_); + } + } + } + if (targetsBuilder_ == null) { + if (!other.targets_.isEmpty()) { + if (targets_.isEmpty()) { + targets_ = other.targets_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureTargetsIsMutable(); + targets_.addAll(other.targets_); + } + onChanged(); + } + } else { + if (!other.targets_.isEmpty()) { + if (targetsBuilder_.isEmpty()) { + targetsBuilder_.dispose(); + targetsBuilder_ = null; + targets_ = other.targets_; + bitField0_ = (bitField0_ & ~0x00000002); + targetsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getTargetsFieldBuilder() + : null; + } else { + targetsBuilder_.addAllMessages(other.targets_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.Exfiltration parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.securitycenter.v1.Exfiltration) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.util.List sources_ = + java.util.Collections.emptyList(); + + private void ensureSourcesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + sources_ = + new java.util.ArrayList(sources_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder> + sourcesBuilder_; + + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public java.util.List getSourcesList() { + if (sourcesBuilder_ == null) { + return java.util.Collections.unmodifiableList(sources_); + } else { + return sourcesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public int getSourcesCount() { + if (sourcesBuilder_ == null) { + return sources_.size(); + } else { + return sourcesBuilder_.getCount(); + } + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public com.google.cloud.securitycenter.v1.ExfilResource getSources(int index) { + if (sourcesBuilder_ == null) { + return sources_.get(index); + } else { + return sourcesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder setSources(int index, com.google.cloud.securitycenter.v1.ExfilResource value) { + if (sourcesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSourcesIsMutable(); + sources_.set(index, value); + onChanged(); + } else { + sourcesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder setSources( + int index, com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (sourcesBuilder_ == null) { + ensureSourcesIsMutable(); + sources_.set(index, builderForValue.build()); + onChanged(); + } else { + sourcesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder addSources(com.google.cloud.securitycenter.v1.ExfilResource value) { + if (sourcesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSourcesIsMutable(); + sources_.add(value); + onChanged(); + } else { + sourcesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder addSources(int index, com.google.cloud.securitycenter.v1.ExfilResource value) { + if (sourcesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureSourcesIsMutable(); + sources_.add(index, value); + onChanged(); + } else { + sourcesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder addSources( + com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (sourcesBuilder_ == null) { + ensureSourcesIsMutable(); + sources_.add(builderForValue.build()); + onChanged(); + } else { + sourcesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder addSources( + int index, com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (sourcesBuilder_ == null) { + ensureSourcesIsMutable(); + sources_.add(index, builderForValue.build()); + onChanged(); + } else { + sourcesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder addAllSources( + java.lang.Iterable values) { + if (sourcesBuilder_ == null) { + ensureSourcesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, sources_); + onChanged(); + } else { + sourcesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder clearSources() { + if (sourcesBuilder_ == null) { + sources_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + sourcesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public Builder removeSources(int index) { + if (sourcesBuilder_ == null) { + ensureSourcesIsMutable(); + sources_.remove(index); + onChanged(); + } else { + sourcesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder getSourcesBuilder(int index) { + return getSourcesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getSourcesOrBuilder( + int index) { + if (sourcesBuilder_ == null) { + return sources_.get(index); + } else { + return sourcesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public java.util.List + getSourcesOrBuilderList() { + if (sourcesBuilder_ != null) { + return sourcesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(sources_); + } + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder addSourcesBuilder() { + return getSourcesFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance()); + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder addSourcesBuilder(int index) { + return getSourcesFieldBuilder() + .addBuilder(index, com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance()); + } + /** + * + * + *
+     * If there are multiple sources, then the data is considered "joined" between
+     * them. For instance, BigQuery can join multiple tables, and each
+     * table would be considered a source.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + public java.util.List + getSourcesBuilderList() { + return getSourcesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder> + getSourcesFieldBuilder() { + if (sourcesBuilder_ == null) { + sourcesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder>( + sources_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + sources_ = null; + } + return sourcesBuilder_; + } + + private java.util.List targets_ = + java.util.Collections.emptyList(); + + private void ensureTargetsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + targets_ = + new java.util.ArrayList(targets_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder> + targetsBuilder_; + + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public java.util.List getTargetsList() { + if (targetsBuilder_ == null) { + return java.util.Collections.unmodifiableList(targets_); + } else { + return targetsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public int getTargetsCount() { + if (targetsBuilder_ == null) { + return targets_.size(); + } else { + return targetsBuilder_.getCount(); + } + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public com.google.cloud.securitycenter.v1.ExfilResource getTargets(int index) { + if (targetsBuilder_ == null) { + return targets_.get(index); + } else { + return targetsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder setTargets(int index, com.google.cloud.securitycenter.v1.ExfilResource value) { + if (targetsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTargetsIsMutable(); + targets_.set(index, value); + onChanged(); + } else { + targetsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder setTargets( + int index, com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (targetsBuilder_ == null) { + ensureTargetsIsMutable(); + targets_.set(index, builderForValue.build()); + onChanged(); + } else { + targetsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder addTargets(com.google.cloud.securitycenter.v1.ExfilResource value) { + if (targetsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTargetsIsMutable(); + targets_.add(value); + onChanged(); + } else { + targetsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder addTargets(int index, com.google.cloud.securitycenter.v1.ExfilResource value) { + if (targetsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTargetsIsMutable(); + targets_.add(index, value); + onChanged(); + } else { + targetsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder addTargets( + com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (targetsBuilder_ == null) { + ensureTargetsIsMutable(); + targets_.add(builderForValue.build()); + onChanged(); + } else { + targetsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder addTargets( + int index, com.google.cloud.securitycenter.v1.ExfilResource.Builder builderForValue) { + if (targetsBuilder_ == null) { + ensureTargetsIsMutable(); + targets_.add(index, builderForValue.build()); + onChanged(); + } else { + targetsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder addAllTargets( + java.lang.Iterable values) { + if (targetsBuilder_ == null) { + ensureTargetsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, targets_); + onChanged(); + } else { + targetsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder clearTargets() { + if (targetsBuilder_ == null) { + targets_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + targetsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public Builder removeTargets(int index) { + if (targetsBuilder_ == null) { + ensureTargetsIsMutable(); + targets_.remove(index); + onChanged(); + } else { + targetsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder getTargetsBuilder(int index) { + return getTargetsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getTargetsOrBuilder( + int index) { + if (targetsBuilder_ == null) { + return targets_.get(index); + } else { + return targetsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public java.util.List + getTargetsOrBuilderList() { + if (targetsBuilder_ != null) { + return targetsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(targets_); + } + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder addTargetsBuilder() { + return getTargetsFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance()); + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public com.google.cloud.securitycenter.v1.ExfilResource.Builder addTargetsBuilder(int index) { + return getTargetsFieldBuilder() + .addBuilder(index, com.google.cloud.securitycenter.v1.ExfilResource.getDefaultInstance()); + } + /** + * + * + *
+     * If there are multiple targets, each target would get a complete copy of the
+     * "joined" source data.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + public java.util.List + getTargetsBuilderList() { + return getTargetsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder> + getTargetsFieldBuilder() { + if (targetsBuilder_ == null) { + targetsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.ExfilResource, + com.google.cloud.securitycenter.v1.ExfilResource.Builder, + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder>( + targets_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + targets_ = null; + } + return targetsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.Exfiltration) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.Exfiltration) + private static final com.google.cloud.securitycenter.v1.Exfiltration DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.Exfiltration(); + } + + public static com.google.cloud.securitycenter.v1.Exfiltration getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Exfiltration parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Exfiltration(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Exfiltration getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationOrBuilder.java new file mode 100644 index 000000000..f84ebb366 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationOrBuilder.java @@ -0,0 +1,144 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/exfiltration.proto + +package com.google.cloud.securitycenter.v1; + +public interface ExfiltrationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.Exfiltration) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + java.util.List getSourcesList(); + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + com.google.cloud.securitycenter.v1.ExfilResource getSources(int index); + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + int getSourcesCount(); + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + java.util.List + getSourcesOrBuilderList(); + /** + * + * + *
+   * If there are multiple sources, then the data is considered "joined" between
+   * them. For instance, BigQuery can join multiple tables, and each
+   * table would be considered a source.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource sources = 1; + */ + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getSourcesOrBuilder(int index); + + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + java.util.List getTargetsList(); + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + com.google.cloud.securitycenter.v1.ExfilResource getTargets(int index); + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + int getTargetsCount(); + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + java.util.List + getTargetsOrBuilderList(); + /** + * + * + *
+   * If there are multiple targets, each target would get a complete copy of the
+   * "joined" source data.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.ExfilResource targets = 2; + */ + com.google.cloud.securitycenter.v1.ExfilResourceOrBuilder getTargetsOrBuilder(int index); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationProto.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationProto.java new file mode 100644 index 000000000..40827fa73 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ExfiltrationProto.java @@ -0,0 +1,84 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/exfiltration.proto + +package com.google.cloud.securitycenter.v1; + +public final class ExfiltrationProto { + private ExfiltrationProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_Exfiltration_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_ExfilResource_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n1google/cloud/securitycenter/v1/exfiltr" + + "ation.proto\022\036google.cloud.securitycenter" + + ".v1\"\216\001\n\014Exfiltration\022>\n\007sources\030\001 \003(\0132-." + + "google.cloud.securitycenter.v1.ExfilReso" + + "urce\022>\n\007targets\030\002 \003(\0132-.google.cloud.sec" + + "uritycenter.v1.ExfilResource\"1\n\rExfilRes" + + "ource\022\014\n\004name\030\001 \001(\t\022\022\n\ncomponents\030\002 \003(\tB" + + "\355\001\n\"com.google.cloud.securitycenter.v1B\021" + + "ExfiltrationProtoP\001ZLgoogle.golang.org/g" + + "enproto/googleapis/cloud/securitycenter/" + + "v1;securitycenter\252\002\036Google.Cloud.Securit" + + "yCenter.V1\312\002\036Google\\Cloud\\SecurityCenter" + + "\\V1\352\002!Google::Cloud::SecurityCenter::V1b" + + "\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_securitycenter_v1_Exfiltration_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_Exfiltration_descriptor, + new java.lang.String[] { + "Sources", "Targets", + }); + internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_securitycenter_v1_ExfilResource_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_ExfilResource_descriptor, + new java.lang.String[] { + "Name", "Components", + }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/File.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/File.java new file mode 100644 index 000000000..693bf5ff4 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/File.java @@ -0,0 +1,1294 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/file.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *
+ * File information about the related binary/library used by an executable, or
+ * the script used by a script interpreter
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.File} + */ +public final class File extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.File) + FileOrBuilder { + private static final long serialVersionUID = 0L; + // Use File.newBuilder() to construct. + private File(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private File() { + path_ = ""; + sha256_ = ""; + contents_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new File(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private File( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + path_ = s; + break; + } + case 16: + { + size_ = input.readInt64(); + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + sha256_ = s; + break; + } + case 32: + { + hashedSize_ = input.readInt64(); + break; + } + case 40: + { + partiallyHashed_ = input.readBool(); + break; + } + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + + contents_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.FileProto + .internal_static_google_cloud_securitycenter_v1_File_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.FileProto + .internal_static_google_cloud_securitycenter_v1_File_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.File.class, + com.google.cloud.securitycenter.v1.File.Builder.class); + } + + public static final int PATH_FIELD_NUMBER = 1; + private volatile java.lang.Object path_; + /** + * + * + *
+   * Absolute path of the file as a JSON encoded string.
+   * 
+ * + * string path = 1; + * + * @return The path. + */ + @java.lang.Override + public java.lang.String getPath() { + java.lang.Object ref = path_; + 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(); + path_ = s; + return s; + } + } + /** + * + * + *
+   * Absolute path of the file as a JSON encoded string.
+   * 
+ * + * string path = 1; + * + * @return The bytes for path. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SIZE_FIELD_NUMBER = 2; + private long size_; + /** + * + * + *
+   * Size of the file in bytes.
+   * 
+ * + * int64 size = 2; + * + * @return The size. + */ + @java.lang.Override + public long getSize() { + return size_; + } + + public static final int SHA256_FIELD_NUMBER = 3; + private volatile java.lang.Object sha256_; + /** + * + * + *
+   * SHA256 hash of the first hashed_size bytes of the file encoded as a
+   * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+   * of the entire file.
+   * 
+ * + * string sha256 = 3; + * + * @return The sha256. + */ + @java.lang.Override + public java.lang.String getSha256() { + java.lang.Object ref = sha256_; + 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(); + sha256_ = s; + return s; + } + } + /** + * + * + *
+   * SHA256 hash of the first hashed_size bytes of the file encoded as a
+   * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+   * of the entire file.
+   * 
+ * + * string sha256 = 3; + * + * @return The bytes for sha256. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSha256Bytes() { + java.lang.Object ref = sha256_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sha256_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int HASHED_SIZE_FIELD_NUMBER = 4; + private long hashedSize_; + /** + * + * + *
+   * The length in bytes of the file prefix that was hashed.  If
+   * hashed_size == size, any hashes reported represent the entire
+   * file.
+   * 
+ * + * int64 hashed_size = 4; + * + * @return The hashedSize. + */ + @java.lang.Override + public long getHashedSize() { + return hashedSize_; + } + + public static final int PARTIALLY_HASHED_FIELD_NUMBER = 5; + private boolean partiallyHashed_; + /** + * + * + *
+   * True when the hash covers only a prefix of the file.
+   * 
+ * + * bool partially_hashed = 5; + * + * @return The partiallyHashed. + */ + @java.lang.Override + public boolean getPartiallyHashed() { + return partiallyHashed_; + } + + public static final int CONTENTS_FIELD_NUMBER = 6; + private volatile java.lang.Object contents_; + /** + * + * + *
+   * Prefix of the file contents as a JSON encoded string.
+   * (Currently only populated for Malicious Script Executed findings.)
+   * 
+ * + * string contents = 6; + * + * @return The contents. + */ + @java.lang.Override + public java.lang.String getContents() { + java.lang.Object ref = contents_; + 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(); + contents_ = s; + return s; + } + } + /** + * + * + *
+   * Prefix of the file contents as a JSON encoded string.
+   * (Currently only populated for Malicious Script Executed findings.)
+   * 
+ * + * string contents = 6; + * + * @return The bytes for contents. + */ + @java.lang.Override + public com.google.protobuf.ByteString getContentsBytes() { + java.lang.Object ref = contents_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + contents_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(path_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, path_); + } + if (size_ != 0L) { + output.writeInt64(2, size_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sha256_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, sha256_); + } + if (hashedSize_ != 0L) { + output.writeInt64(4, hashedSize_); + } + if (partiallyHashed_ != false) { + output.writeBool(5, partiallyHashed_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(contents_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, contents_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(path_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, path_); + } + if (size_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, size_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(sha256_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, sha256_); + } + if (hashedSize_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, hashedSize_); + } + if (partiallyHashed_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(5, partiallyHashed_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(contents_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, contents_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.File)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.File other = (com.google.cloud.securitycenter.v1.File) obj; + + if (!getPath().equals(other.getPath())) return false; + if (getSize() != other.getSize()) return false; + if (!getSha256().equals(other.getSha256())) return false; + if (getHashedSize() != other.getHashedSize()) return false; + if (getPartiallyHashed() != other.getPartiallyHashed()) return false; + if (!getContents().equals(other.getContents())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PATH_FIELD_NUMBER; + hash = (53 * hash) + getPath().hashCode(); + hash = (37 * hash) + SIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSize()); + hash = (37 * hash) + SHA256_FIELD_NUMBER; + hash = (53 * hash) + getSha256().hashCode(); + hash = (37 * hash) + HASHED_SIZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getHashedSize()); + hash = (37 * hash) + PARTIALLY_HASHED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getPartiallyHashed()); + hash = (37 * hash) + CONTENTS_FIELD_NUMBER; + hash = (53 * hash) + getContents().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.File parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.File parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.File parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.File parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.cloud.securitycenter.v1.File prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * File information about the related binary/library used by an executable, or
+   * the script used by a script interpreter
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.File} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.File) + com.google.cloud.securitycenter.v1.FileOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.FileProto + .internal_static_google_cloud_securitycenter_v1_File_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.FileProto + .internal_static_google_cloud_securitycenter_v1_File_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.File.class, + com.google.cloud.securitycenter.v1.File.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.File.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + path_ = ""; + + size_ = 0L; + + sha256_ = ""; + + hashedSize_ = 0L; + + partiallyHashed_ = false; + + contents_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.FileProto + .internal_static_google_cloud_securitycenter_v1_File_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.File getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.File.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.File build() { + com.google.cloud.securitycenter.v1.File result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.File buildPartial() { + com.google.cloud.securitycenter.v1.File result = + new com.google.cloud.securitycenter.v1.File(this); + result.path_ = path_; + result.size_ = size_; + result.sha256_ = sha256_; + result.hashedSize_ = hashedSize_; + result.partiallyHashed_ = partiallyHashed_; + result.contents_ = contents_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.File) { + return mergeFrom((com.google.cloud.securitycenter.v1.File) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.File other) { + if (other == com.google.cloud.securitycenter.v1.File.getDefaultInstance()) return this; + if (!other.getPath().isEmpty()) { + path_ = other.path_; + onChanged(); + } + if (other.getSize() != 0L) { + setSize(other.getSize()); + } + if (!other.getSha256().isEmpty()) { + sha256_ = other.sha256_; + onChanged(); + } + if (other.getHashedSize() != 0L) { + setHashedSize(other.getHashedSize()); + } + if (other.getPartiallyHashed() != false) { + setPartiallyHashed(other.getPartiallyHashed()); + } + if (!other.getContents().isEmpty()) { + contents_ = other.contents_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.File parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.securitycenter.v1.File) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object path_ = ""; + /** + * + * + *
+     * Absolute path of the file as a JSON encoded string.
+     * 
+ * + * string path = 1; + * + * @return The path. + */ + public java.lang.String getPath() { + java.lang.Object ref = path_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + path_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Absolute path of the file as a JSON encoded string.
+     * 
+ * + * string path = 1; + * + * @return The bytes for path. + */ + public com.google.protobuf.ByteString getPathBytes() { + java.lang.Object ref = path_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + path_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Absolute path of the file as a JSON encoded string.
+     * 
+ * + * string path = 1; + * + * @param value The path to set. + * @return This builder for chaining. + */ + public Builder setPath(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + path_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Absolute path of the file as a JSON encoded string.
+     * 
+ * + * string path = 1; + * + * @return This builder for chaining. + */ + public Builder clearPath() { + + path_ = getDefaultInstance().getPath(); + onChanged(); + return this; + } + /** + * + * + *
+     * Absolute path of the file as a JSON encoded string.
+     * 
+ * + * string path = 1; + * + * @param value The bytes for path to set. + * @return This builder for chaining. + */ + public Builder setPathBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + path_ = value; + onChanged(); + return this; + } + + private long size_; + /** + * + * + *
+     * Size of the file in bytes.
+     * 
+ * + * int64 size = 2; + * + * @return The size. + */ + @java.lang.Override + public long getSize() { + return size_; + } + /** + * + * + *
+     * Size of the file in bytes.
+     * 
+ * + * int64 size = 2; + * + * @param value The size to set. + * @return This builder for chaining. + */ + public Builder setSize(long value) { + + size_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Size of the file in bytes.
+     * 
+ * + * int64 size = 2; + * + * @return This builder for chaining. + */ + public Builder clearSize() { + + size_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object sha256_ = ""; + /** + * + * + *
+     * SHA256 hash of the first hashed_size bytes of the file encoded as a
+     * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+     * of the entire file.
+     * 
+ * + * string sha256 = 3; + * + * @return The sha256. + */ + public java.lang.String getSha256() { + java.lang.Object ref = sha256_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + sha256_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * SHA256 hash of the first hashed_size bytes of the file encoded as a
+     * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+     * of the entire file.
+     * 
+ * + * string sha256 = 3; + * + * @return The bytes for sha256. + */ + public com.google.protobuf.ByteString getSha256Bytes() { + java.lang.Object ref = sha256_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + sha256_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * SHA256 hash of the first hashed_size bytes of the file encoded as a
+     * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+     * of the entire file.
+     * 
+ * + * string sha256 = 3; + * + * @param value The sha256 to set. + * @return This builder for chaining. + */ + public Builder setSha256(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + sha256_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * SHA256 hash of the first hashed_size bytes of the file encoded as a
+     * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+     * of the entire file.
+     * 
+ * + * string sha256 = 3; + * + * @return This builder for chaining. + */ + public Builder clearSha256() { + + sha256_ = getDefaultInstance().getSha256(); + onChanged(); + return this; + } + /** + * + * + *
+     * SHA256 hash of the first hashed_size bytes of the file encoded as a
+     * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+     * of the entire file.
+     * 
+ * + * string sha256 = 3; + * + * @param value The bytes for sha256 to set. + * @return This builder for chaining. + */ + public Builder setSha256Bytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + sha256_ = value; + onChanged(); + return this; + } + + private long hashedSize_; + /** + * + * + *
+     * The length in bytes of the file prefix that was hashed.  If
+     * hashed_size == size, any hashes reported represent the entire
+     * file.
+     * 
+ * + * int64 hashed_size = 4; + * + * @return The hashedSize. + */ + @java.lang.Override + public long getHashedSize() { + return hashedSize_; + } + /** + * + * + *
+     * The length in bytes of the file prefix that was hashed.  If
+     * hashed_size == size, any hashes reported represent the entire
+     * file.
+     * 
+ * + * int64 hashed_size = 4; + * + * @param value The hashedSize to set. + * @return This builder for chaining. + */ + public Builder setHashedSize(long value) { + + hashedSize_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The length in bytes of the file prefix that was hashed.  If
+     * hashed_size == size, any hashes reported represent the entire
+     * file.
+     * 
+ * + * int64 hashed_size = 4; + * + * @return This builder for chaining. + */ + public Builder clearHashedSize() { + + hashedSize_ = 0L; + onChanged(); + return this; + } + + private boolean partiallyHashed_; + /** + * + * + *
+     * True when the hash covers only a prefix of the file.
+     * 
+ * + * bool partially_hashed = 5; + * + * @return The partiallyHashed. + */ + @java.lang.Override + public boolean getPartiallyHashed() { + return partiallyHashed_; + } + /** + * + * + *
+     * True when the hash covers only a prefix of the file.
+     * 
+ * + * bool partially_hashed = 5; + * + * @param value The partiallyHashed to set. + * @return This builder for chaining. + */ + public Builder setPartiallyHashed(boolean value) { + + partiallyHashed_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * True when the hash covers only a prefix of the file.
+     * 
+ * + * bool partially_hashed = 5; + * + * @return This builder for chaining. + */ + public Builder clearPartiallyHashed() { + + partiallyHashed_ = false; + onChanged(); + return this; + } + + private java.lang.Object contents_ = ""; + /** + * + * + *
+     * Prefix of the file contents as a JSON encoded string.
+     * (Currently only populated for Malicious Script Executed findings.)
+     * 
+ * + * string contents = 6; + * + * @return The contents. + */ + public java.lang.String getContents() { + java.lang.Object ref = contents_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + contents_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Prefix of the file contents as a JSON encoded string.
+     * (Currently only populated for Malicious Script Executed findings.)
+     * 
+ * + * string contents = 6; + * + * @return The bytes for contents. + */ + public com.google.protobuf.ByteString getContentsBytes() { + java.lang.Object ref = contents_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + contents_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Prefix of the file contents as a JSON encoded string.
+     * (Currently only populated for Malicious Script Executed findings.)
+     * 
+ * + * string contents = 6; + * + * @param value The contents to set. + * @return This builder for chaining. + */ + public Builder setContents(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + contents_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Prefix of the file contents as a JSON encoded string.
+     * (Currently only populated for Malicious Script Executed findings.)
+     * 
+ * + * string contents = 6; + * + * @return This builder for chaining. + */ + public Builder clearContents() { + + contents_ = getDefaultInstance().getContents(); + onChanged(); + return this; + } + /** + * + * + *
+     * Prefix of the file contents as a JSON encoded string.
+     * (Currently only populated for Malicious Script Executed findings.)
+     * 
+ * + * string contents = 6; + * + * @param value The bytes for contents to set. + * @return This builder for chaining. + */ + public Builder setContentsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + contents_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.File) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.File) + private static final com.google.cloud.securitycenter.v1.File DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.File(); + } + + public static com.google.cloud.securitycenter.v1.File getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public File parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new File(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.File getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileOrBuilder.java new file mode 100644 index 000000000..b48ec9954 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileOrBuilder.java @@ -0,0 +1,147 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/file.proto + +package com.google.cloud.securitycenter.v1; + +public interface FileOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.File) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Absolute path of the file as a JSON encoded string.
+   * 
+ * + * string path = 1; + * + * @return The path. + */ + java.lang.String getPath(); + /** + * + * + *
+   * Absolute path of the file as a JSON encoded string.
+   * 
+ * + * string path = 1; + * + * @return The bytes for path. + */ + com.google.protobuf.ByteString getPathBytes(); + + /** + * + * + *
+   * Size of the file in bytes.
+   * 
+ * + * int64 size = 2; + * + * @return The size. + */ + long getSize(); + + /** + * + * + *
+   * SHA256 hash of the first hashed_size bytes of the file encoded as a
+   * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+   * of the entire file.
+   * 
+ * + * string sha256 = 3; + * + * @return The sha256. + */ + java.lang.String getSha256(); + /** + * + * + *
+   * SHA256 hash of the first hashed_size bytes of the file encoded as a
+   * hex string.  If hashed_size == size, hash_sha256 represents the SHA256 hash
+   * of the entire file.
+   * 
+ * + * string sha256 = 3; + * + * @return The bytes for sha256. + */ + com.google.protobuf.ByteString getSha256Bytes(); + + /** + * + * + *
+   * The length in bytes of the file prefix that was hashed.  If
+   * hashed_size == size, any hashes reported represent the entire
+   * file.
+   * 
+ * + * int64 hashed_size = 4; + * + * @return The hashedSize. + */ + long getHashedSize(); + + /** + * + * + *
+   * True when the hash covers only a prefix of the file.
+   * 
+ * + * bool partially_hashed = 5; + * + * @return The partiallyHashed. + */ + boolean getPartiallyHashed(); + + /** + * + * + *
+   * Prefix of the file contents as a JSON encoded string.
+   * (Currently only populated for Malicious Script Executed findings.)
+   * 
+ * + * string contents = 6; + * + * @return The contents. + */ + java.lang.String getContents(); + /** + * + * + *
+   * Prefix of the file contents as a JSON encoded string.
+   * (Currently only populated for Malicious Script Executed findings.)
+   * 
+ * + * string contents = 6; + * + * @return The bytes for contents. + */ + com.google.protobuf.ByteString getContentsBytes(); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileProto.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileProto.java new file mode 100644 index 000000000..2f6f2c0f9 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FileProto.java @@ -0,0 +1,69 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/file.proto + +package com.google.cloud.securitycenter.v1; + +public final class FileProto { + private FileProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_File_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_File_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n)google/cloud/securitycenter/v1/file.pr" + + "oto\022\036google.cloud.securitycenter.v1\"s\n\004F" + + "ile\022\014\n\004path\030\001 \001(\t\022\014\n\004size\030\002 \001(\003\022\016\n\006sha25" + + "6\030\003 \001(\t\022\023\n\013hashed_size\030\004 \001(\003\022\030\n\020partiall" + + "y_hashed\030\005 \001(\010\022\020\n\010contents\030\006 \001(\tB\345\001\n\"com" + + ".google.cloud.securitycenter.v1B\tFilePro" + + "toP\001ZLgoogle.golang.org/genproto/googlea" + + "pis/cloud/securitycenter/v1;securitycent" + + "er\252\002\036Google.Cloud.SecurityCenter.V1\312\002\036Go" + + "ogle\\Cloud\\SecurityCenter\\V1\352\002!Google::C" + + "loud::SecurityCenter::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_cloud_securitycenter_v1_File_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_securitycenter_v1_File_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_File_descriptor, + new java.lang.String[] { + "Path", "Size", "Sha256", "HashedSize", "PartiallyHashed", "Contents", + }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Finding.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Finding.java index 44fd97072..e1c0d0890 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Finding.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Finding.java @@ -55,6 +55,8 @@ private Finding() { findingClass_ = 0; connections_ = java.util.Collections.emptyList(); muteInitiator_ = ""; + processes_ = java.util.Collections.emptyList(); + compliances_ = java.util.Collections.emptyList(); description_ = ""; iamBindings_ = java.util.Collections.emptyList(); nextSteps_ = ""; @@ -329,6 +331,17 @@ private Finding( muteInitiator_ = s; break; } + case 242: + { + if (!((mutable_bitField0_ & 0x00000008) != 0)) { + processes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000008; + } + processes_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.Process.parser(), extensionRegistry)); + break; + } case 250: { if (!((mutable_bitField0_ & 0x00000004) != 0)) { @@ -341,19 +354,47 @@ private Finding( com.google.cloud.securitycenter.v1.Connection.parser(), extensionRegistry)); break; } + case 274: + { + if (!((mutable_bitField0_ & 0x00000010) != 0)) { + compliances_ = + new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + compliances_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.Compliance.parser(), extensionRegistry)); + break; + } case 298: { java.lang.String s = input.readStringRequireUtf8(); description_ = s; + break; + } + case 306: + { + com.google.cloud.securitycenter.v1.Exfiltration.Builder subBuilder = null; + if (exfiltration_ != null) { + subBuilder = exfiltration_.toBuilder(); + } + exfiltration_ = + input.readMessage( + com.google.cloud.securitycenter.v1.Exfiltration.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(exfiltration_); + exfiltration_ = subBuilder.buildPartial(); + } + break; } case 314: { - if (!((mutable_bitField0_ & 0x00000008) != 0)) { + if (!((mutable_bitField0_ & 0x00000020) != 0)) { iamBindings_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000008; + mutable_bitField0_ |= 0x00000020; } iamBindings_.add( input.readMessage( @@ -383,10 +424,16 @@ private Finding( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { + if (((mutable_bitField0_ & 0x00000008) != 0)) { + processes_ = java.util.Collections.unmodifiableList(processes_); + } if (((mutable_bitField0_ & 0x00000004) != 0)) { connections_ = java.util.Collections.unmodifiableList(connections_); } - if (((mutable_bitField0_ & 0x00000008) != 0)) { + if (((mutable_bitField0_ & 0x00000010) != 0)) { + compliances_ = java.util.Collections.unmodifiableList(compliances_); + } + if (((mutable_bitField0_ & 0x00000020) != 0)) { iamBindings_ = java.util.Collections.unmodifiableList(iamBindings_); } this.unknownFields = unknownFields.build(); @@ -2246,8 +2293,8 @@ public int getExternalSystemsCount() { * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -2272,8 +2319,8 @@ public boolean containsExternalSystems(java.lang.String key) { * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -2289,8 +2336,8 @@ public boolean containsExternalSystems(java.lang.String key) { * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -2311,8 +2358,8 @@ public com.google.cloud.securitycenter.v1.ExternalSystem getExternalSystemsOrDef * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -2559,6 +2606,149 @@ public com.google.protobuf.ByteString getMuteInitiatorBytes() { } } + public static final int PROCESSES_FIELD_NUMBER = 30; + private java.util.List processes_; + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + @java.lang.Override + public java.util.List getProcessesList() { + return processes_; + } + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + @java.lang.Override + public java.util.List + getProcessesOrBuilderList() { + return processes_; + } + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + @java.lang.Override + public int getProcessesCount() { + return processes_.size(); + } + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.Process getProcesses(int index) { + return processes_.get(index); + } + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ProcessOrBuilder getProcessesOrBuilder(int index) { + return processes_.get(index); + } + + public static final int COMPLIANCES_FIELD_NUMBER = 34; + private java.util.List compliances_; + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + @java.lang.Override + public java.util.List getCompliancesList() { + return compliances_; + } + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + @java.lang.Override + public java.util.List + getCompliancesOrBuilderList() { + return compliances_; + } + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + @java.lang.Override + public int getCompliancesCount() { + return compliances_.size(); + } + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.Compliance getCompliances(int index) { + return compliances_.get(index); + } + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ComplianceOrBuilder getCompliancesOrBuilder(int index) { + return compliances_.get(index); + } + public static final int DESCRIPTION_FIELD_NUMBER = 37; private volatile java.lang.Object description_; /** @@ -2608,6 +2798,54 @@ public com.google.protobuf.ByteString getDescriptionBytes() { } } + public static final int EXFILTRATION_FIELD_NUMBER = 38; + private com.google.cloud.securitycenter.v1.Exfiltration exfiltration_; + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return Whether the exfiltration field is set. + */ + @java.lang.Override + public boolean hasExfiltration() { + return exfiltration_ != null; + } + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return The exfiltration. + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.Exfiltration getExfiltration() { + return exfiltration_ == null + ? com.google.cloud.securitycenter.v1.Exfiltration.getDefaultInstance() + : exfiltration_; + } + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder getExfiltrationOrBuilder() { + return getExfiltration(); + } + public static final int IAM_BINDINGS_FIELD_NUMBER = 39; private java.util.List iamBindings_; /** @@ -2804,12 +3042,21 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(muteInitiator_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 28, muteInitiator_); } + for (int i = 0; i < processes_.size(); i++) { + output.writeMessage(30, processes_.get(i)); + } for (int i = 0; i < connections_.size(); i++) { output.writeMessage(31, connections_.get(i)); } + for (int i = 0; i < compliances_.size(); i++) { + output.writeMessage(34, compliances_.get(i)); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 37, description_); } + if (exfiltration_ != null) { + output.writeMessage(38, getExfiltration()); + } for (int i = 0; i < iamBindings_.size(); i++) { output.writeMessage(39, iamBindings_.get(i)); } @@ -2907,12 +3154,21 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(muteInitiator_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(28, muteInitiator_); } + for (int i = 0; i < processes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(30, processes_.get(i)); + } for (int i = 0; i < connections_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(31, connections_.get(i)); } + for (int i = 0; i < compliances_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(34, compliances_.get(i)); + } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(description_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(37, description_); } + if (exfiltration_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(38, getExfiltration()); + } for (int i = 0; i < iamBindings_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(39, iamBindings_.get(i)); } @@ -2981,7 +3237,13 @@ public boolean equals(final java.lang.Object obj) { } if (!getConnectionsList().equals(other.getConnectionsList())) return false; if (!getMuteInitiator().equals(other.getMuteInitiator())) return false; + if (!getProcessesList().equals(other.getProcessesList())) return false; + if (!getCompliancesList().equals(other.getCompliancesList())) return false; if (!getDescription().equals(other.getDescription())) return false; + if (hasExfiltration() != other.hasExfiltration()) return false; + if (hasExfiltration()) { + if (!getExfiltration().equals(other.getExfiltration())) return false; + } if (!getIamBindingsList().equals(other.getIamBindingsList())) return false; if (!getNextSteps().equals(other.getNextSteps())) return false; if (!unknownFields.equals(other.unknownFields)) return false; @@ -3061,8 +3323,20 @@ public int hashCode() { } hash = (37 * hash) + MUTE_INITIATOR_FIELD_NUMBER; hash = (53 * hash) + getMuteInitiator().hashCode(); + if (getProcessesCount() > 0) { + hash = (37 * hash) + PROCESSES_FIELD_NUMBER; + hash = (53 * hash) + getProcessesList().hashCode(); + } + if (getCompliancesCount() > 0) { + hash = (37 * hash) + COMPLIANCES_FIELD_NUMBER; + hash = (53 * hash) + getCompliancesList().hashCode(); + } hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; hash = (53 * hash) + getDescription().hashCode(); + if (hasExfiltration()) { + hash = (37 * hash) + EXFILTRATION_FIELD_NUMBER; + hash = (53 * hash) + getExfiltration().hashCode(); + } if (getIamBindingsCount() > 0) { hash = (37 * hash) + IAM_BINDINGS_FIELD_NUMBER; hash = (53 * hash) + getIamBindingsList().hashCode(); @@ -3239,6 +3513,8 @@ private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { getConnectionsFieldBuilder(); + getProcessesFieldBuilder(); + getCompliancesFieldBuilder(); getIamBindingsFieldBuilder(); } } @@ -3324,11 +3600,29 @@ public Builder clear() { } muteInitiator_ = ""; + if (processesBuilder_ == null) { + processes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + } else { + processesBuilder_.clear(); + } + if (compliancesBuilder_ == null) { + compliances_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + compliancesBuilder_.clear(); + } description_ = ""; + if (exfiltrationBuilder_ == null) { + exfiltration_ = null; + } else { + exfiltration_ = null; + exfiltrationBuilder_ = null; + } if (iamBindingsBuilder_ == null) { iamBindings_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000020); } else { iamBindingsBuilder_.clear(); } @@ -3426,11 +3720,34 @@ public com.google.cloud.securitycenter.v1.Finding buildPartial() { result.connections_ = connectionsBuilder_.build(); } result.muteInitiator_ = muteInitiator_; + if (processesBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + processes_ = java.util.Collections.unmodifiableList(processes_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.processes_ = processes_; + } else { + result.processes_ = processesBuilder_.build(); + } + if (compliancesBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0)) { + compliances_ = java.util.Collections.unmodifiableList(compliances_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.compliances_ = compliances_; + } else { + result.compliances_ = compliancesBuilder_.build(); + } result.description_ = description_; + if (exfiltrationBuilder_ == null) { + result.exfiltration_ = exfiltration_; + } else { + result.exfiltration_ = exfiltrationBuilder_.build(); + } if (iamBindingsBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0)) { + if (((bitField0_ & 0x00000020) != 0)) { iamBindings_ = java.util.Collections.unmodifiableList(iamBindings_); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000020); } result.iamBindings_ = iamBindings_; } else { @@ -3579,15 +3896,72 @@ public Builder mergeFrom(com.google.cloud.securitycenter.v1.Finding other) { muteInitiator_ = other.muteInitiator_; onChanged(); } + if (processesBuilder_ == null) { + if (!other.processes_.isEmpty()) { + if (processes_.isEmpty()) { + processes_ = other.processes_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureProcessesIsMutable(); + processes_.addAll(other.processes_); + } + onChanged(); + } + } else { + if (!other.processes_.isEmpty()) { + if (processesBuilder_.isEmpty()) { + processesBuilder_.dispose(); + processesBuilder_ = null; + processes_ = other.processes_; + bitField0_ = (bitField0_ & ~0x00000008); + processesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getProcessesFieldBuilder() + : null; + } else { + processesBuilder_.addAllMessages(other.processes_); + } + } + } + if (compliancesBuilder_ == null) { + if (!other.compliances_.isEmpty()) { + if (compliances_.isEmpty()) { + compliances_ = other.compliances_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureCompliancesIsMutable(); + compliances_.addAll(other.compliances_); + } + onChanged(); + } + } else { + if (!other.compliances_.isEmpty()) { + if (compliancesBuilder_.isEmpty()) { + compliancesBuilder_.dispose(); + compliancesBuilder_ = null; + compliances_ = other.compliances_; + bitField0_ = (bitField0_ & ~0x00000010); + compliancesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getCompliancesFieldBuilder() + : null; + } else { + compliancesBuilder_.addAllMessages(other.compliances_); + } + } + } if (!other.getDescription().isEmpty()) { description_ = other.description_; onChanged(); } + if (other.hasExfiltration()) { + mergeExfiltration(other.getExfiltration()); + } if (iamBindingsBuilder_ == null) { if (!other.iamBindings_.isEmpty()) { if (iamBindings_.isEmpty()) { iamBindings_ = other.iamBindings_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000020); } else { ensureIamBindingsIsMutable(); iamBindings_.addAll(other.iamBindings_); @@ -3600,7 +3974,7 @@ public Builder mergeFrom(com.google.cloud.securitycenter.v1.Finding other) { iamBindingsBuilder_.dispose(); iamBindingsBuilder_ = null; iamBindings_ = other.iamBindings_; - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000020); iamBindingsBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getIamBindingsFieldBuilder() @@ -6262,8 +6636,8 @@ public int getExternalSystemsCount() { * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6288,8 +6662,8 @@ public boolean containsExternalSystems(java.lang.String key) { * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6305,8 +6679,8 @@ public boolean containsExternalSystems(java.lang.String key) { * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6327,8 +6701,8 @@ public com.google.cloud.securitycenter.v1.ExternalSystem getExternalSystemsOrDef * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6357,8 +6731,8 @@ public Builder clearExternalSystems() { * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6382,8 +6756,8 @@ public Builder removeExternalSystems(java.lang.String key) { * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -6406,8 +6780,8 @@ public Builder putExternalSystems( * * *
-     * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-     * information and external system finding fields.
+     * Output only. Third party SIEM/SOAR fields within SCC, contains external
+     * system information and external system finding fields.
      * 
* * @@ -7282,70 +7656,791 @@ public Builder setMuteInitiatorBytes(com.google.protobuf.ByteString value) { return this; } - private java.lang.Object description_ = ""; + private java.util.List processes_ = + java.util.Collections.emptyList(); + + private void ensureProcessesIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + processes_ = + new java.util.ArrayList(processes_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Process, + com.google.cloud.securitycenter.v1.Process.Builder, + com.google.cloud.securitycenter.v1.ProcessOrBuilder> + processesBuilder_; + /** * * *
-     * Contains more detail about the finding.
+     * Represents operating system processes associated with the Finding.
      * 
* - * string description = 37; - * - * @return The description. + * repeated .google.cloud.securitycenter.v1.Process processes = 30; */ - public java.lang.String getDescription() { - java.lang.Object ref = description_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - description_ = s; - return s; + public java.util.List getProcessesList() { + if (processesBuilder_ == null) { + return java.util.Collections.unmodifiableList(processes_); } else { - return (java.lang.String) ref; + return processesBuilder_.getMessageList(); } } /** * * *
-     * Contains more detail about the finding.
+     * Represents operating system processes associated with the Finding.
      * 
* - * string description = 37; - * - * @return The bytes for description. + * repeated .google.cloud.securitycenter.v1.Process processes = 30; */ - public com.google.protobuf.ByteString getDescriptionBytes() { - java.lang.Object ref = description_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - description_ = b; - return b; + public int getProcessesCount() { + if (processesBuilder_ == null) { + return processes_.size(); } else { - return (com.google.protobuf.ByteString) ref; + return processesBuilder_.getCount(); } } /** * * *
-     * Contains more detail about the finding.
+     * Represents operating system processes associated with the Finding.
      * 
* - * string description = 37; - * - * @param value The description to set. - * @return This builder for chaining. + * repeated .google.cloud.securitycenter.v1.Process processes = 30; */ - public Builder setDescription(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); + public com.google.cloud.securitycenter.v1.Process getProcesses(int index) { + if (processesBuilder_ == null) { + return processes_.get(index); + } else { + return processesBuilder_.getMessage(index); } - - description_ = value; - onChanged(); + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder setProcesses(int index, com.google.cloud.securitycenter.v1.Process value) { + if (processesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProcessesIsMutable(); + processes_.set(index, value); + onChanged(); + } else { + processesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder setProcesses( + int index, com.google.cloud.securitycenter.v1.Process.Builder builderForValue) { + if (processesBuilder_ == null) { + ensureProcessesIsMutable(); + processes_.set(index, builderForValue.build()); + onChanged(); + } else { + processesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder addProcesses(com.google.cloud.securitycenter.v1.Process value) { + if (processesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProcessesIsMutable(); + processes_.add(value); + onChanged(); + } else { + processesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder addProcesses(int index, com.google.cloud.securitycenter.v1.Process value) { + if (processesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProcessesIsMutable(); + processes_.add(index, value); + onChanged(); + } else { + processesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder addProcesses( + com.google.cloud.securitycenter.v1.Process.Builder builderForValue) { + if (processesBuilder_ == null) { + ensureProcessesIsMutable(); + processes_.add(builderForValue.build()); + onChanged(); + } else { + processesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder addProcesses( + int index, com.google.cloud.securitycenter.v1.Process.Builder builderForValue) { + if (processesBuilder_ == null) { + ensureProcessesIsMutable(); + processes_.add(index, builderForValue.build()); + onChanged(); + } else { + processesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder addAllProcesses( + java.lang.Iterable values) { + if (processesBuilder_ == null) { + ensureProcessesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, processes_); + onChanged(); + } else { + processesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder clearProcesses() { + if (processesBuilder_ == null) { + processes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + processesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public Builder removeProcesses(int index) { + if (processesBuilder_ == null) { + ensureProcessesIsMutable(); + processes_.remove(index); + onChanged(); + } else { + processesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public com.google.cloud.securitycenter.v1.Process.Builder getProcessesBuilder(int index) { + return getProcessesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public com.google.cloud.securitycenter.v1.ProcessOrBuilder getProcessesOrBuilder(int index) { + if (processesBuilder_ == null) { + return processes_.get(index); + } else { + return processesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public java.util.List + getProcessesOrBuilderList() { + if (processesBuilder_ != null) { + return processesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(processes_); + } + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public com.google.cloud.securitycenter.v1.Process.Builder addProcessesBuilder() { + return getProcessesFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.Process.getDefaultInstance()); + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public com.google.cloud.securitycenter.v1.Process.Builder addProcessesBuilder(int index) { + return getProcessesFieldBuilder() + .addBuilder(index, com.google.cloud.securitycenter.v1.Process.getDefaultInstance()); + } + /** + * + * + *
+     * Represents operating system processes associated with the Finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + public java.util.List + getProcessesBuilderList() { + return getProcessesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Process, + com.google.cloud.securitycenter.v1.Process.Builder, + com.google.cloud.securitycenter.v1.ProcessOrBuilder> + getProcessesFieldBuilder() { + if (processesBuilder_ == null) { + processesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Process, + com.google.cloud.securitycenter.v1.Process.Builder, + com.google.cloud.securitycenter.v1.ProcessOrBuilder>( + processes_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + processes_ = null; + } + return processesBuilder_; + } + + private java.util.List compliances_ = + java.util.Collections.emptyList(); + + private void ensureCompliancesIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + compliances_ = + new java.util.ArrayList(compliances_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Compliance, + com.google.cloud.securitycenter.v1.Compliance.Builder, + com.google.cloud.securitycenter.v1.ComplianceOrBuilder> + compliancesBuilder_; + + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public java.util.List getCompliancesList() { + if (compliancesBuilder_ == null) { + return java.util.Collections.unmodifiableList(compliances_); + } else { + return compliancesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public int getCompliancesCount() { + if (compliancesBuilder_ == null) { + return compliances_.size(); + } else { + return compliancesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public com.google.cloud.securitycenter.v1.Compliance getCompliances(int index) { + if (compliancesBuilder_ == null) { + return compliances_.get(index); + } else { + return compliancesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder setCompliances(int index, com.google.cloud.securitycenter.v1.Compliance value) { + if (compliancesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompliancesIsMutable(); + compliances_.set(index, value); + onChanged(); + } else { + compliancesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder setCompliances( + int index, com.google.cloud.securitycenter.v1.Compliance.Builder builderForValue) { + if (compliancesBuilder_ == null) { + ensureCompliancesIsMutable(); + compliances_.set(index, builderForValue.build()); + onChanged(); + } else { + compliancesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder addCompliances(com.google.cloud.securitycenter.v1.Compliance value) { + if (compliancesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompliancesIsMutable(); + compliances_.add(value); + onChanged(); + } else { + compliancesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder addCompliances(int index, com.google.cloud.securitycenter.v1.Compliance value) { + if (compliancesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureCompliancesIsMutable(); + compliances_.add(index, value); + onChanged(); + } else { + compliancesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder addCompliances( + com.google.cloud.securitycenter.v1.Compliance.Builder builderForValue) { + if (compliancesBuilder_ == null) { + ensureCompliancesIsMutable(); + compliances_.add(builderForValue.build()); + onChanged(); + } else { + compliancesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder addCompliances( + int index, com.google.cloud.securitycenter.v1.Compliance.Builder builderForValue) { + if (compliancesBuilder_ == null) { + ensureCompliancesIsMutable(); + compliances_.add(index, builderForValue.build()); + onChanged(); + } else { + compliancesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder addAllCompliances( + java.lang.Iterable values) { + if (compliancesBuilder_ == null) { + ensureCompliancesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, compliances_); + onChanged(); + } else { + compliancesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder clearCompliances() { + if (compliancesBuilder_ == null) { + compliances_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + compliancesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public Builder removeCompliances(int index) { + if (compliancesBuilder_ == null) { + ensureCompliancesIsMutable(); + compliances_.remove(index); + onChanged(); + } else { + compliancesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public com.google.cloud.securitycenter.v1.Compliance.Builder getCompliancesBuilder(int index) { + return getCompliancesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public com.google.cloud.securitycenter.v1.ComplianceOrBuilder getCompliancesOrBuilder( + int index) { + if (compliancesBuilder_ == null) { + return compliances_.get(index); + } else { + return compliancesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public java.util.List + getCompliancesOrBuilderList() { + if (compliancesBuilder_ != null) { + return compliancesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(compliances_); + } + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public com.google.cloud.securitycenter.v1.Compliance.Builder addCompliancesBuilder() { + return getCompliancesFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.Compliance.getDefaultInstance()); + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public com.google.cloud.securitycenter.v1.Compliance.Builder addCompliancesBuilder(int index) { + return getCompliancesFieldBuilder() + .addBuilder(index, com.google.cloud.securitycenter.v1.Compliance.getDefaultInstance()); + } + /** + * + * + *
+     * Contains compliance information for security standards associated to the
+     * finding.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + public java.util.List + getCompliancesBuilderList() { + return getCompliancesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Compliance, + com.google.cloud.securitycenter.v1.Compliance.Builder, + com.google.cloud.securitycenter.v1.ComplianceOrBuilder> + getCompliancesFieldBuilder() { + if (compliancesBuilder_ == null) { + compliancesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.Compliance, + com.google.cloud.securitycenter.v1.Compliance.Builder, + com.google.cloud.securitycenter.v1.ComplianceOrBuilder>( + compliances_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); + compliances_ = null; + } + return compliancesBuilder_; + } + + private java.lang.Object description_ = ""; + /** + * + * + *
+     * Contains more detail about the finding.
+     * 
+ * + * string description = 37; + * + * @return The description. + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Contains more detail about the finding.
+     * 
+ * + * string description = 37; + * + * @return The bytes for description. + */ + public com.google.protobuf.ByteString getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Contains more detail about the finding.
+     * 
+ * + * string description = 37; + * + * @param value The description to set. + * @return This builder for chaining. + */ + public Builder setDescription(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); return this; } /** @@ -7388,14 +8483,200 @@ public Builder setDescriptionBytes(com.google.protobuf.ByteString value) { return this; } + private com.google.cloud.securitycenter.v1.Exfiltration exfiltration_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.Exfiltration, + com.google.cloud.securitycenter.v1.Exfiltration.Builder, + com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder> + exfiltrationBuilder_; + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return Whether the exfiltration field is set. + */ + public boolean hasExfiltration() { + return exfiltrationBuilder_ != null || exfiltration_ != null; + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return The exfiltration. + */ + public com.google.cloud.securitycenter.v1.Exfiltration getExfiltration() { + if (exfiltrationBuilder_ == null) { + return exfiltration_ == null + ? com.google.cloud.securitycenter.v1.Exfiltration.getDefaultInstance() + : exfiltration_; + } else { + return exfiltrationBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public Builder setExfiltration(com.google.cloud.securitycenter.v1.Exfiltration value) { + if (exfiltrationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + exfiltration_ = value; + onChanged(); + } else { + exfiltrationBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public Builder setExfiltration( + com.google.cloud.securitycenter.v1.Exfiltration.Builder builderForValue) { + if (exfiltrationBuilder_ == null) { + exfiltration_ = builderForValue.build(); + onChanged(); + } else { + exfiltrationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public Builder mergeExfiltration(com.google.cloud.securitycenter.v1.Exfiltration value) { + if (exfiltrationBuilder_ == null) { + if (exfiltration_ != null) { + exfiltration_ = + com.google.cloud.securitycenter.v1.Exfiltration.newBuilder(exfiltration_) + .mergeFrom(value) + .buildPartial(); + } else { + exfiltration_ = value; + } + onChanged(); + } else { + exfiltrationBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public Builder clearExfiltration() { + if (exfiltrationBuilder_ == null) { + exfiltration_ = null; + onChanged(); + } else { + exfiltration_ = null; + exfiltrationBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public com.google.cloud.securitycenter.v1.Exfiltration.Builder getExfiltrationBuilder() { + + onChanged(); + return getExfiltrationFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + public com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder getExfiltrationOrBuilder() { + if (exfiltrationBuilder_ != null) { + return exfiltrationBuilder_.getMessageOrBuilder(); + } else { + return exfiltration_ == null + ? com.google.cloud.securitycenter.v1.Exfiltration.getDefaultInstance() + : exfiltration_; + } + } + /** + * + * + *
+     * Represents exfiltration associated with the Finding.
+     * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.Exfiltration, + com.google.cloud.securitycenter.v1.Exfiltration.Builder, + com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder> + getExfiltrationFieldBuilder() { + if (exfiltrationBuilder_ == null) { + exfiltrationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.Exfiltration, + com.google.cloud.securitycenter.v1.Exfiltration.Builder, + com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder>( + getExfiltration(), getParentForChildren(), isClean()); + exfiltration_ = null; + } + return exfiltrationBuilder_; + } + private java.util.List iamBindings_ = java.util.Collections.emptyList(); private void ensureIamBindingsIsMutable() { - if (!((bitField0_ & 0x00000008) != 0)) { + if (!((bitField0_ & 0x00000020) != 0)) { iamBindings_ = new java.util.ArrayList(iamBindings_); - bitField0_ |= 0x00000008; + bitField0_ |= 0x00000020; } } @@ -7611,7 +8892,7 @@ public Builder addAllIamBindings( public Builder clearIamBindings() { if (iamBindingsBuilder_ == null) { iamBindings_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000008); + bitField0_ = (bitField0_ & ~0x00000020); onChanged(); } else { iamBindingsBuilder_.clear(); @@ -7734,7 +9015,7 @@ public com.google.cloud.securitycenter.v1.IamBinding.Builder addIamBindingsBuild com.google.cloud.securitycenter.v1.IamBinding, com.google.cloud.securitycenter.v1.IamBinding.Builder, com.google.cloud.securitycenter.v1.IamBindingOrBuilder>( - iamBindings_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + iamBindings_, ((bitField0_ & 0x00000020) != 0), getParentForChildren(), isClean()); iamBindings_ = null; } return iamBindingsBuilder_; diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOrBuilder.java index ddcc4964e..0bc5d05ae 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOrBuilder.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOrBuilder.java @@ -663,8 +663,8 @@ com.google.protobuf.Value getSourcePropertiesOrDefault( * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -676,8 +676,8 @@ com.google.protobuf.Value getSourcePropertiesOrDefault( * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -693,8 +693,8 @@ com.google.protobuf.Value getSourcePropertiesOrDefault( * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -707,8 +707,8 @@ com.google.protobuf.Value getSourcePropertiesOrDefault( * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -725,8 +725,8 @@ com.google.cloud.securitycenter.v1.ExternalSystem getExternalSystemsOrDefault( * * *
-   * Output only. Third party SIEM/SOAR fields within SCC, contains external system
-   * information and external system finding fields.
+   * Output only. Third party SIEM/SOAR fields within SCC, contains external
+   * system information and external system finding fields.
    * 
* * @@ -894,6 +894,115 @@ com.google.cloud.securitycenter.v1.ExternalSystem getExternalSystemsOrDefault( */ com.google.protobuf.ByteString getMuteInitiatorBytes(); + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + java.util.List getProcessesList(); + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + com.google.cloud.securitycenter.v1.Process getProcesses(int index); + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + int getProcessesCount(); + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + java.util.List + getProcessesOrBuilderList(); + /** + * + * + *
+   * Represents operating system processes associated with the Finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Process processes = 30; + */ + com.google.cloud.securitycenter.v1.ProcessOrBuilder getProcessesOrBuilder(int index); + + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + java.util.List getCompliancesList(); + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + com.google.cloud.securitycenter.v1.Compliance getCompliances(int index); + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + int getCompliancesCount(); + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + java.util.List + getCompliancesOrBuilderList(); + /** + * + * + *
+   * Contains compliance information for security standards associated to the
+   * finding.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.Compliance compliances = 34; + */ + com.google.cloud.securitycenter.v1.ComplianceOrBuilder getCompliancesOrBuilder(int index); + /** * * @@ -919,6 +1028,41 @@ com.google.cloud.securitycenter.v1.ExternalSystem getExternalSystemsOrDefault( */ com.google.protobuf.ByteString getDescriptionBytes(); + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return Whether the exfiltration field is set. + */ + boolean hasExfiltration(); + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + * + * @return The exfiltration. + */ + com.google.cloud.securitycenter.v1.Exfiltration getExfiltration(); + /** + * + * + *
+   * Represents exfiltration associated with the Finding.
+   * 
+ * + * .google.cloud.securitycenter.v1.Exfiltration exfiltration = 38; + */ + com.google.cloud.securitycenter.v1.ExfiltrationOrBuilder getExfiltrationOrBuilder(); + /** * * diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOuterClass.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOuterClass.java index f651ba8a3..a25500939 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOuterClass.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/FindingOuterClass.java @@ -53,73 +53,81 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "google/api/field_behavior.proto\032\031google/" + "api/resource.proto\032+google/cloud/securit" + "ycenter/v1/access.proto\032/google/cloud/se" - + "curitycenter/v1/connection.proto\0324google" - + "/cloud/securitycenter/v1/external_system" - + ".proto\0320google/cloud/securitycenter/v1/i" - + "am_binding.proto\032.google/cloud/securityc" - + "enter/v1/indicator.proto\0321google/cloud/s" - + "ecuritycenter/v1/mitre_attack.proto\0323goo" - + "gle/cloud/securitycenter/v1/security_mar" - + "ks.proto\0322google/cloud/securitycenter/v1" - + "/vulnerability.proto\032\034google/protobuf/st" - + "ruct.proto\032\037google/protobuf/timestamp.pr" - + "oto\"\331\017\n\007Finding\022\014\n\004name\030\001 \001(\t\022\016\n\006parent\030" - + "\002 \001(\t\022\025\n\rresource_name\030\003 \001(\t\022<\n\005state\030\004 " - + "\001(\0162-.google.cloud.securitycenter.v1.Fin" - + "ding.State\022\020\n\010category\030\005 \001(\t\022\024\n\014external" - + "_uri\030\006 \001(\t\022X\n\021source_properties\030\007 \003(\0132=." + + "curitycenter/v1/compliance.proto\032/google" + + "/cloud/securitycenter/v1/connection.prot" + + "o\0321google/cloud/securitycenter/v1/exfilt" + + "ration.proto\0324google/cloud/securitycente" + + "r/v1/external_system.proto\0320google/cloud" + + "/securitycenter/v1/iam_binding.proto\032.go" + + "ogle/cloud/securitycenter/v1/indicator.p" + + "roto\0321google/cloud/securitycenter/v1/mit" + + "re_attack.proto\032,google/cloud/securityce" + + "nter/v1/process.proto\0323google/cloud/secu" + + "ritycenter/v1/security_marks.proto\0322goog" + + "le/cloud/securitycenter/v1/vulnerability" + + ".proto\032\034google/protobuf/struct.proto\032\037go" + + "ogle/protobuf/timestamp.proto\"\232\021\n\007Findin" + + "g\022\014\n\004name\030\001 \001(\t\022\016\n\006parent\030\002 \001(\t\022\025\n\rresou" + + "rce_name\030\003 \001(\t\022<\n\005state\030\004 \001(\0162-.google.c" + + "loud.securitycenter.v1.Finding.State\022\020\n\010" + + "category\030\005 \001(\t\022\024\n\014external_uri\030\006 \001(\t\022X\n\021" + + "source_properties\030\007 \003(\0132=.google.cloud.s" + + "ecuritycenter.v1.Finding.SourcePropertie" + + "sEntry\022J\n\016security_marks\030\010 \001(\0132-.google." + + "cloud.securitycenter.v1.SecurityMarksB\003\340" + + "A\003\022.\n\nevent_time\030\t \001(\0132\032.google.protobuf" + + ".Timestamp\022/\n\013create_time\030\n \001(\0132\032.google" + + ".protobuf.Timestamp\022B\n\010severity\030\014 \001(\01620." + "google.cloud.securitycenter.v1.Finding.S" - + "ourcePropertiesEntry\022J\n\016security_marks\030\010" - + " \001(\0132-.google.cloud.securitycenter.v1.Se" - + "curityMarksB\003\340A\003\022.\n\nevent_time\030\t \001(\0132\032.g" - + "oogle.protobuf.Timestamp\022/\n\013create_time\030" - + "\n \001(\0132\032.google.protobuf.Timestamp\022B\n\010sev" - + "erity\030\014 \001(\01620.google.cloud.securitycente" - + "r.v1.Finding.Severity\022\026\n\016canonical_name\030" - + "\016 \001(\t\022:\n\004mute\030\017 \001(\0162,.google.cloud.secur" - + "itycenter.v1.Finding.Mute\022K\n\rfinding_cla" - + "ss\030\021 \001(\01624.google.cloud.securitycenter.v" - + "1.Finding.FindingClass\022<\n\tindicator\030\022 \001(" - + "\0132).google.cloud.securitycenter.v1.Indic" - + "ator\022D\n\rvulnerability\030\024 \001(\0132-.google.clo" - + "ud.securitycenter.v1.Vulnerability\0229\n\020mu" - + "te_update_time\030\025 \001(\0132\032.google.protobuf.T" - + "imestampB\003\340A\003\022[\n\020external_systems\030\026 \003(\0132" - + "<.google.cloud.securitycenter.v1.Finding" - + ".ExternalSystemsEntryB\003\340A\003\022A\n\014mitre_atta" - + "ck\030\031 \001(\0132+.google.cloud.securitycenter.v" - + "1.MitreAttack\0226\n\006access\030\032 \001(\0132&.google.c" - + "loud.securitycenter.v1.Access\022?\n\013connect" - + "ions\030\037 \003(\0132*.google.cloud.securitycenter" - + ".v1.Connection\022\026\n\016mute_initiator\030\034 \001(\t\022\023" - + "\n\013description\030% \001(\t\022@\n\014iam_bindings\030\' \003(" - + "\0132*.google.cloud.securitycenter.v1.IamBi" - + "nding\022\022\n\nnext_steps\030( \001(\t\032O\n\025SourcePrope" - + "rtiesEntry\022\013\n\003key\030\001 \001(\t\022%\n\005value\030\002 \001(\0132\026" - + ".google.protobuf.Value:\0028\001\032f\n\024ExternalSy" - + "stemsEntry\022\013\n\003key\030\001 \001(\t\022=\n\005value\030\002 \001(\0132." - + ".google.cloud.securitycenter.v1.External" - + "System:\0028\001\"8\n\005State\022\025\n\021STATE_UNSPECIFIED" - + "\020\000\022\n\n\006ACTIVE\020\001\022\014\n\010INACTIVE\020\002\"Q\n\010Severity" - + "\022\030\n\024SEVERITY_UNSPECIFIED\020\000\022\014\n\010CRITICAL\020\001" - + "\022\010\n\004HIGH\020\002\022\n\n\006MEDIUM\020\003\022\007\n\003LOW\020\004\"C\n\004Mute\022" - + "\024\n\020MUTE_UNSPECIFIED\020\000\022\t\n\005MUTED\020\001\022\013\n\007UNMU" - + "TED\020\002\022\r\n\tUNDEFINED\020\004\"\202\001\n\014FindingClass\022\035\n" - + "\031FINDING_CLASS_UNSPECIFIED\020\000\022\n\n\006THREAT\020\001" - + "\022\021\n\rVULNERABILITY\020\002\022\024\n\020MISCONFIGURATION\020" - + "\003\022\017\n\013OBSERVATION\020\004\022\r\n\tSCC_ERROR\020\005:\333\001\352A\327\001" - + "\n%securitycenter.googleapis.com/Finding\022" - + "@organizations/{organization}/sources/{s" - + "ource}/findings/{finding}\0224folders/{fold" - + "er}/sources/{source}/findings/{finding}\022" - + "6projects/{project}/sources/{source}/fin" - + "dings/{finding}B\332\001\n\"com.google.cloud.sec" - + "uritycenter.v1P\001ZLgoogle.golang.org/genp" - + "roto/googleapis/cloud/securitycenter/v1;" - + "securitycenter\252\002\036Google.Cloud.SecurityCe" - + "nter.V1\312\002\036Google\\Cloud\\SecurityCenter\\V1" - + "\352\002!Google::Cloud::SecurityCenter::V1b\006pr" - + "oto3" + + "everity\022\026\n\016canonical_name\030\016 \001(\t\022:\n\004mute\030" + + "\017 \001(\0162,.google.cloud.securitycenter.v1.F" + + "inding.Mute\022K\n\rfinding_class\030\021 \001(\01624.goo" + + "gle.cloud.securitycenter.v1.Finding.Find" + + "ingClass\022<\n\tindicator\030\022 \001(\0132).google.clo" + + "ud.securitycenter.v1.Indicator\022D\n\rvulner" + + "ability\030\024 \001(\0132-.google.cloud.securitycen" + + "ter.v1.Vulnerability\0229\n\020mute_update_time" + + "\030\025 \001(\0132\032.google.protobuf.TimestampB\003\340A\003\022" + + "[\n\020external_systems\030\026 \003(\0132<.google.cloud" + + ".securitycenter.v1.Finding.ExternalSyste" + + "msEntryB\003\340A\003\022A\n\014mitre_attack\030\031 \001(\0132+.goo" + + "gle.cloud.securitycenter.v1.MitreAttack\022" + + "6\n\006access\030\032 \001(\0132&.google.cloud.securityc" + + "enter.v1.Access\022?\n\013connections\030\037 \003(\0132*.g" + + "oogle.cloud.securitycenter.v1.Connection" + + "\022\026\n\016mute_initiator\030\034 \001(\t\022:\n\tprocesses\030\036 " + + "\003(\0132\'.google.cloud.securitycenter.v1.Pro" + + "cess\022?\n\013compliances\030\" \003(\0132*.google.cloud" + + ".securitycenter.v1.Compliance\022\023\n\013descrip" + + "tion\030% \001(\t\022B\n\014exfiltration\030& \001(\0132,.googl" + + "e.cloud.securitycenter.v1.Exfiltration\022@" + + "\n\014iam_bindings\030\' \003(\0132*.google.cloud.secu" + + "ritycenter.v1.IamBinding\022\022\n\nnext_steps\030(" + + " \001(\t\032O\n\025SourcePropertiesEntry\022\013\n\003key\030\001 \001" + + "(\t\022%\n\005value\030\002 \001(\0132\026.google.protobuf.Valu" + + "e:\0028\001\032f\n\024ExternalSystemsEntry\022\013\n\003key\030\001 \001" + + "(\t\022=\n\005value\030\002 \001(\0132..google.cloud.securit" + + "ycenter.v1.ExternalSystem:\0028\001\"8\n\005State\022\025" + + "\n\021STATE_UNSPECIFIED\020\000\022\n\n\006ACTIVE\020\001\022\014\n\010INA" + + "CTIVE\020\002\"Q\n\010Severity\022\030\n\024SEVERITY_UNSPECIF" + + "IED\020\000\022\014\n\010CRITICAL\020\001\022\010\n\004HIGH\020\002\022\n\n\006MEDIUM\020" + + "\003\022\007\n\003LOW\020\004\"C\n\004Mute\022\024\n\020MUTE_UNSPECIFIED\020\000" + + "\022\t\n\005MUTED\020\001\022\013\n\007UNMUTED\020\002\022\r\n\tUNDEFINED\020\004\"" + + "\202\001\n\014FindingClass\022\035\n\031FINDING_CLASS_UNSPEC" + + "IFIED\020\000\022\n\n\006THREAT\020\001\022\021\n\rVULNERABILITY\020\002\022\024" + + "\n\020MISCONFIGURATION\020\003\022\017\n\013OBSERVATION\020\004\022\r\n" + + "\tSCC_ERROR\020\005:\333\001\352A\327\001\n%securitycenter.goog" + + "leapis.com/Finding\022@organizations/{organ" + + "ization}/sources/{source}/findings/{find" + + "ing}\0224folders/{folder}/sources/{source}/" + + "findings/{finding}\0226projects/{project}/s" + + "ources/{source}/findings/{finding}B\332\001\n\"c" + + "om.google.cloud.securitycenter.v1P\001ZLgoo" + + "gle.golang.org/genproto/googleapis/cloud" + + "/securitycenter/v1;securitycenter\252\002\036Goog" + + "le.Cloud.SecurityCenter.V1\312\002\036Google\\Clou" + + "d\\SecurityCenter\\V1\352\002!Google::Cloud::Sec" + + "urityCenter::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -128,11 +136,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.FieldBehaviorProto.getDescriptor(), com.google.api.ResourceProto.getDescriptor(), com.google.cloud.securitycenter.v1.AccessProto.getDescriptor(), + com.google.cloud.securitycenter.v1.ComplianceProto.getDescriptor(), com.google.cloud.securitycenter.v1.ConnectionProto.getDescriptor(), + com.google.cloud.securitycenter.v1.ExfiltrationProto.getDescriptor(), com.google.cloud.securitycenter.v1.ExternalSystemProto.getDescriptor(), com.google.cloud.securitycenter.v1.IamBindingProto.getDescriptor(), com.google.cloud.securitycenter.v1.IndicatorProto.getDescriptor(), com.google.cloud.securitycenter.v1.MitreAttackProto.getDescriptor(), + com.google.cloud.securitycenter.v1.ProcessProto.getDescriptor(), com.google.cloud.securitycenter.v1.SecurityMarksOuterClass.getDescriptor(), com.google.cloud.securitycenter.v1.VulnerabilityProto.getDescriptor(), com.google.protobuf.StructProto.getDescriptor(), @@ -166,7 +177,10 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Access", "Connections", "MuteInitiator", + "Processes", + "Compliances", "Description", + "Exfiltration", "IamBindings", "NextSteps", }); @@ -195,11 +209,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.FieldBehaviorProto.getDescriptor(); com.google.api.ResourceProto.getDescriptor(); com.google.cloud.securitycenter.v1.AccessProto.getDescriptor(); + com.google.cloud.securitycenter.v1.ComplianceProto.getDescriptor(); com.google.cloud.securitycenter.v1.ConnectionProto.getDescriptor(); + com.google.cloud.securitycenter.v1.ExfiltrationProto.getDescriptor(); com.google.cloud.securitycenter.v1.ExternalSystemProto.getDescriptor(); com.google.cloud.securitycenter.v1.IamBindingProto.getDescriptor(); com.google.cloud.securitycenter.v1.IndicatorProto.getDescriptor(); com.google.cloud.securitycenter.v1.MitreAttackProto.getDescriptor(); + com.google.cloud.securitycenter.v1.ProcessProto.getDescriptor(); com.google.cloud.securitycenter.v1.SecurityMarksOuterClass.getDescriptor(); com.google.cloud.securitycenter.v1.VulnerabilityProto.getDescriptor(); com.google.protobuf.StructProto.getDescriptor(); diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttack.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttack.java index 67307d4b5..8078bc17e 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttack.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttack.java @@ -638,7 +638,6 @@ private Tactic(int value) { *
    * MITRE ATT&CK techniques that can be referenced by SCC findings.
    * See: https://attack.mitre.org/techniques/enterprise/
-   * Next ID: 31
    * 
* * Protobuf enum {@code google.cloud.securitycenter.v1.MitreAttack.Technique} @@ -954,6 +953,16 @@ public enum Technique implements com.google.protobuf.ProtocolMessageEnum { * DOMAIN_POLICY_MODIFICATION = 30; */ DOMAIN_POLICY_MODIFICATION(30), + /** + * + * + *
+     * T1562
+     * 
+ * + * IMPAIR_DEFENSES = 31; + */ + IMPAIR_DEFENSES(31), UNRECOGNIZED(-1), ; @@ -1267,6 +1276,16 @@ public enum Technique implements com.google.protobuf.ProtocolMessageEnum { * DOMAIN_POLICY_MODIFICATION = 30; */ public static final int DOMAIN_POLICY_MODIFICATION_VALUE = 30; + /** + * + * + *
+     * T1562
+     * 
+ * + * IMPAIR_DEFENSES = 31; + */ + public static final int IMPAIR_DEFENSES_VALUE = 31; public final int getNumber() { if (this == UNRECOGNIZED) { @@ -1354,6 +1373,8 @@ public static Technique forNumber(int value) { return DATA_DESTRUCTION; case 30: return DOMAIN_POLICY_MODIFICATION; + case 31: + return IMPAIR_DEFENSES; default: return null; } diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttackProto.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttackProto.java index b78d40e98..995687f5c 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttackProto.java +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/MitreAttackProto.java @@ -42,7 +42,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { java.lang.String[] descriptorData = { "\n1google/cloud/securitycenter/v1/mitre_a" + "ttack.proto\022\036google.cloud.securitycenter" - + ".v1\"\330\013\n\013MitreAttack\022J\n\016primary_tactic\030\001 " + + ".v1\"\355\013\n\013MitreAttack\022J\n\016primary_tactic\030\001 " + "\001(\01622.google.cloud.securitycenter.v1.Mit" + "reAttack.Tactic\022Q\n\022primary_techniques\030\002 " + "\003(\01625.google.cloud.securitycenter.v1.Mit" @@ -58,7 +58,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "\022\023\n\017DEFENSE_EVASION\020\007\022\025\n\021CREDENTIAL_ACCE" + "SS\020\t\022\r\n\tDISCOVERY\020\n\022\024\n\020LATERAL_MOVEMENT\020" + "\013\022\016\n\nCOLLECTION\020\014\022\027\n\023COMMAND_AND_CONTROL" - + "\020\004\022\020\n\014EXFILTRATION\020\r\022\n\n\006IMPACT\020\016\"\273\006\n\tTec" + + "\020\004\022\020\n\014EXFILTRATION\020\r\022\n\n\006IMPACT\020\016\"\320\006\n\tTec" + "hnique\022\031\n\025TECHNIQUE_UNSPECIFIED\020\000\022\023\n\017ACT" + "IVE_SCANNING\020\001\022\026\n\022SCANNING_IP_BLOCKS\020\002\022\031" + "\n\025INGRESS_TOOL_TRANSFER\020\003\022\016\n\nNATIVE_API\020" @@ -79,13 +79,14 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "FRASTRUCTURE\020\032\022%\n!EXPLOIT_PUBLIC_FACING_" + "APPLICATION\020\033\022!\n\035MODIFY_AUTHENTICATION_P" + "ROCESS\020\034\022\024\n\020DATA_DESTRUCTION\020\035\022\036\n\032DOMAIN" - + "_POLICY_MODIFICATION\020\036B\354\001\n\"com.google.cl" - + "oud.securitycenter.v1B\020MitreAttackProtoP" - + "\001ZLgoogle.golang.org/genproto/googleapis" - + "/cloud/securitycenter/v1;securitycenter\252" - + "\002\036Google.Cloud.SecurityCenter.V1\312\002\036Googl" - + "e\\Cloud\\SecurityCenter\\V1\352\002!Google::Clou" - + "d::SecurityCenter::V1b\006proto3" + + "_POLICY_MODIFICATION\020\036\022\023\n\017IMPAIR_DEFENSE" + + "S\020\037B\354\001\n\"com.google.cloud.securitycenter." + + "v1B\020MitreAttackProtoP\001ZLgoogle.golang.or" + + "g/genproto/googleapis/cloud/securitycent" + + "er/v1;securitycenter\252\002\036Google.Cloud.Secu" + + "rityCenter.V1\312\002\036Google\\Cloud\\SecurityCen" + + "ter\\V1\352\002!Google::Cloud::SecurityCenter::" + + "V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Process.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Process.java new file mode 100644 index 000000000..54cf3db62 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/Process.java @@ -0,0 +1,2674 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/process.proto + +package com.google.cloud.securitycenter.v1; + +/** + * + * + *
+ * Represents an operating system process.
+ * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Process} + */ +public final class Process extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.securitycenter.v1.Process) + ProcessOrBuilder { + private static final long serialVersionUID = 0L; + // Use Process.newBuilder() to construct. + private Process(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Process() { + libraries_ = java.util.Collections.emptyList(); + args_ = com.google.protobuf.LazyStringArrayList.EMPTY; + envVariables_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Process(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Process( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 26: + { + com.google.cloud.securitycenter.v1.File.Builder subBuilder = null; + if (binary_ != null) { + subBuilder = binary_.toBuilder(); + } + binary_ = + input.readMessage( + com.google.cloud.securitycenter.v1.File.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(binary_); + binary_ = subBuilder.buildPartial(); + } + + break; + } + case 34: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + libraries_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + libraries_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.File.parser(), extensionRegistry)); + break; + } + case 42: + { + com.google.cloud.securitycenter.v1.File.Builder subBuilder = null; + if (script_ != null) { + subBuilder = script_.toBuilder(); + } + script_ = + input.readMessage( + com.google.cloud.securitycenter.v1.File.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(script_); + script_ = subBuilder.buildPartial(); + } + + break; + } + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + args_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + args_.add(s); + break; + } + case 56: + { + argumentsTruncated_ = input.readBool(); + break; + } + case 66: + { + if (!((mutable_bitField0_ & 0x00000004) != 0)) { + envVariables_ = + new java.util.ArrayList< + com.google.cloud.securitycenter.v1.EnvironmentVariable>(); + mutable_bitField0_ |= 0x00000004; + } + envVariables_.add( + input.readMessage( + com.google.cloud.securitycenter.v1.EnvironmentVariable.parser(), + extensionRegistry)); + break; + } + case 72: + { + envVariablesTruncated_ = input.readBool(); + break; + } + case 80: + { + pid_ = input.readInt64(); + break; + } + case 88: + { + parentPid_ = input.readInt64(); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + libraries_ = java.util.Collections.unmodifiableList(libraries_); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + args_ = args_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000004) != 0)) { + envVariables_ = java.util.Collections.unmodifiableList(envVariables_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_Process_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_Process_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Process.class, + com.google.cloud.securitycenter.v1.Process.Builder.class); + } + + public static final int BINARY_FIELD_NUMBER = 3; + private com.google.cloud.securitycenter.v1.File binary_; + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return Whether the binary field is set. + */ + @java.lang.Override + public boolean hasBinary() { + return binary_ != null; + } + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return The binary. + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.File getBinary() { + return binary_ == null ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() : binary_; + } + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.FileOrBuilder getBinaryOrBuilder() { + return getBinary(); + } + + public static final int LIBRARIES_FIELD_NUMBER = 4; + private java.util.List libraries_; + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + @java.lang.Override + public java.util.List getLibrariesList() { + return libraries_; + } + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + @java.lang.Override + public java.util.List + getLibrariesOrBuilderList() { + return libraries_; + } + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + @java.lang.Override + public int getLibrariesCount() { + return libraries_.size(); + } + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.File getLibraries(int index) { + return libraries_.get(index); + } + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.FileOrBuilder getLibrariesOrBuilder(int index) { + return libraries_.get(index); + } + + public static final int SCRIPT_FIELD_NUMBER = 5; + private com.google.cloud.securitycenter.v1.File script_; + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return Whether the script field is set. + */ + @java.lang.Override + public boolean hasScript() { + return script_ != null; + } + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return The script. + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.File getScript() { + return script_ == null ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() : script_; + } + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.FileOrBuilder getScriptOrBuilder() { + return getScript(); + } + + public static final int ARGS_FIELD_NUMBER = 6; + private com.google.protobuf.LazyStringList args_; + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @return A list containing the args. + */ + public com.google.protobuf.ProtocolStringList getArgsList() { + return args_; + } + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @return The count of args. + */ + public int getArgsCount() { + return args_.size(); + } + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @param index The index of the element to return. + * @return The args at the given index. + */ + public java.lang.String getArgs(int index) { + return args_.get(index); + } + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @param index The index of the value to return. + * @return The bytes of the args at the given index. + */ + public com.google.protobuf.ByteString getArgsBytes(int index) { + return args_.getByteString(index); + } + + public static final int ARGUMENTS_TRUNCATED_FIELD_NUMBER = 7; + private boolean argumentsTruncated_; + /** + * + * + *
+   * True if `args` is incomplete.
+   * 
+ * + * bool arguments_truncated = 7; + * + * @return The argumentsTruncated. + */ + @java.lang.Override + public boolean getArgumentsTruncated() { + return argumentsTruncated_; + } + + public static final int ENV_VARIABLES_FIELD_NUMBER = 8; + private java.util.List envVariables_; + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + @java.lang.Override + public java.util.List + getEnvVariablesList() { + return envVariables_; + } + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + @java.lang.Override + public java.util.List + getEnvVariablesOrBuilderList() { + return envVariables_; + } + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + @java.lang.Override + public int getEnvVariablesCount() { + return envVariables_.size(); + } + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariable getEnvVariables(int index) { + return envVariables_.get(index); + } + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + @java.lang.Override + public com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder getEnvVariablesOrBuilder( + int index) { + return envVariables_.get(index); + } + + public static final int ENV_VARIABLES_TRUNCATED_FIELD_NUMBER = 9; + private boolean envVariablesTruncated_; + /** + * + * + *
+   * True if `env_variables` is incomplete.
+   * 
+ * + * bool env_variables_truncated = 9; + * + * @return The envVariablesTruncated. + */ + @java.lang.Override + public boolean getEnvVariablesTruncated() { + return envVariablesTruncated_; + } + + public static final int PID_FIELD_NUMBER = 10; + private long pid_; + /** + * + * + *
+   * The process id.
+   * 
+ * + * int64 pid = 10; + * + * @return The pid. + */ + @java.lang.Override + public long getPid() { + return pid_; + } + + public static final int PARENT_PID_FIELD_NUMBER = 11; + private long parentPid_; + /** + * + * + *
+   * The parent process id.
+   * 
+ * + * int64 parent_pid = 11; + * + * @return The parentPid. + */ + @java.lang.Override + public long getParentPid() { + return parentPid_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (binary_ != null) { + output.writeMessage(3, getBinary()); + } + for (int i = 0; i < libraries_.size(); i++) { + output.writeMessage(4, libraries_.get(i)); + } + if (script_ != null) { + output.writeMessage(5, getScript()); + } + for (int i = 0; i < args_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, args_.getRaw(i)); + } + if (argumentsTruncated_ != false) { + output.writeBool(7, argumentsTruncated_); + } + for (int i = 0; i < envVariables_.size(); i++) { + output.writeMessage(8, envVariables_.get(i)); + } + if (envVariablesTruncated_ != false) { + output.writeBool(9, envVariablesTruncated_); + } + if (pid_ != 0L) { + output.writeInt64(10, pid_); + } + if (parentPid_ != 0L) { + output.writeInt64(11, parentPid_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (binary_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getBinary()); + } + for (int i = 0; i < libraries_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, libraries_.get(i)); + } + if (script_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getScript()); + } + { + int dataSize = 0; + for (int i = 0; i < args_.size(); i++) { + dataSize += computeStringSizeNoTag(args_.getRaw(i)); + } + size += dataSize; + size += 1 * getArgsList().size(); + } + if (argumentsTruncated_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(7, argumentsTruncated_); + } + for (int i = 0; i < envVariables_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, envVariables_.get(i)); + } + if (envVariablesTruncated_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(9, envVariablesTruncated_); + } + if (pid_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(10, pid_); + } + if (parentPid_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(11, parentPid_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.cloud.securitycenter.v1.Process)) { + return super.equals(obj); + } + com.google.cloud.securitycenter.v1.Process other = + (com.google.cloud.securitycenter.v1.Process) obj; + + if (hasBinary() != other.hasBinary()) return false; + if (hasBinary()) { + if (!getBinary().equals(other.getBinary())) return false; + } + if (!getLibrariesList().equals(other.getLibrariesList())) return false; + if (hasScript() != other.hasScript()) return false; + if (hasScript()) { + if (!getScript().equals(other.getScript())) return false; + } + if (!getArgsList().equals(other.getArgsList())) return false; + if (getArgumentsTruncated() != other.getArgumentsTruncated()) return false; + if (!getEnvVariablesList().equals(other.getEnvVariablesList())) return false; + if (getEnvVariablesTruncated() != other.getEnvVariablesTruncated()) return false; + if (getPid() != other.getPid()) return false; + if (getParentPid() != other.getParentPid()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBinary()) { + hash = (37 * hash) + BINARY_FIELD_NUMBER; + hash = (53 * hash) + getBinary().hashCode(); + } + if (getLibrariesCount() > 0) { + hash = (37 * hash) + LIBRARIES_FIELD_NUMBER; + hash = (53 * hash) + getLibrariesList().hashCode(); + } + if (hasScript()) { + hash = (37 * hash) + SCRIPT_FIELD_NUMBER; + hash = (53 * hash) + getScript().hashCode(); + } + if (getArgsCount() > 0) { + hash = (37 * hash) + ARGS_FIELD_NUMBER; + hash = (53 * hash) + getArgsList().hashCode(); + } + hash = (37 * hash) + ARGUMENTS_TRUNCATED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getArgumentsTruncated()); + if (getEnvVariablesCount() > 0) { + hash = (37 * hash) + ENV_VARIABLES_FIELD_NUMBER; + hash = (53 * hash) + getEnvVariablesList().hashCode(); + } + hash = (37 * hash) + ENV_VARIABLES_TRUNCATED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getEnvVariablesTruncated()); + hash = (37 * hash) + PID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getPid()); + hash = (37 * hash) + PARENT_PID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getParentPid()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Process parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Process parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.securitycenter.v1.Process parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.cloud.securitycenter.v1.Process prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Represents an operating system process.
+   * 
+ * + * Protobuf type {@code google.cloud.securitycenter.v1.Process} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.securitycenter.v1.Process) + com.google.cloud.securitycenter.v1.ProcessOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_Process_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_Process_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.securitycenter.v1.Process.class, + com.google.cloud.securitycenter.v1.Process.Builder.class); + } + + // Construct using com.google.cloud.securitycenter.v1.Process.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getLibrariesFieldBuilder(); + getEnvVariablesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (binaryBuilder_ == null) { + binary_ = null; + } else { + binary_ = null; + binaryBuilder_ = null; + } + if (librariesBuilder_ == null) { + libraries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + librariesBuilder_.clear(); + } + if (scriptBuilder_ == null) { + script_ = null; + } else { + script_ = null; + scriptBuilder_ = null; + } + args_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + argumentsTruncated_ = false; + + if (envVariablesBuilder_ == null) { + envVariables_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + envVariablesBuilder_.clear(); + } + envVariablesTruncated_ = false; + + pid_ = 0L; + + parentPid_ = 0L; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.securitycenter.v1.ProcessProto + .internal_static_google_cloud_securitycenter_v1_Process_descriptor; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Process getDefaultInstanceForType() { + return com.google.cloud.securitycenter.v1.Process.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Process build() { + com.google.cloud.securitycenter.v1.Process result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Process buildPartial() { + com.google.cloud.securitycenter.v1.Process result = + new com.google.cloud.securitycenter.v1.Process(this); + int from_bitField0_ = bitField0_; + if (binaryBuilder_ == null) { + result.binary_ = binary_; + } else { + result.binary_ = binaryBuilder_.build(); + } + if (librariesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + libraries_ = java.util.Collections.unmodifiableList(libraries_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.libraries_ = libraries_; + } else { + result.libraries_ = librariesBuilder_.build(); + } + if (scriptBuilder_ == null) { + result.script_ = script_; + } else { + result.script_ = scriptBuilder_.build(); + } + if (((bitField0_ & 0x00000002) != 0)) { + args_ = args_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.args_ = args_; + result.argumentsTruncated_ = argumentsTruncated_; + if (envVariablesBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + envVariables_ = java.util.Collections.unmodifiableList(envVariables_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.envVariables_ = envVariables_; + } else { + result.envVariables_ = envVariablesBuilder_.build(); + } + result.envVariablesTruncated_ = envVariablesTruncated_; + result.pid_ = pid_; + result.parentPid_ = parentPid_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.cloud.securitycenter.v1.Process) { + return mergeFrom((com.google.cloud.securitycenter.v1.Process) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.securitycenter.v1.Process other) { + if (other == com.google.cloud.securitycenter.v1.Process.getDefaultInstance()) return this; + if (other.hasBinary()) { + mergeBinary(other.getBinary()); + } + if (librariesBuilder_ == null) { + if (!other.libraries_.isEmpty()) { + if (libraries_.isEmpty()) { + libraries_ = other.libraries_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureLibrariesIsMutable(); + libraries_.addAll(other.libraries_); + } + onChanged(); + } + } else { + if (!other.libraries_.isEmpty()) { + if (librariesBuilder_.isEmpty()) { + librariesBuilder_.dispose(); + librariesBuilder_ = null; + libraries_ = other.libraries_; + bitField0_ = (bitField0_ & ~0x00000001); + librariesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getLibrariesFieldBuilder() + : null; + } else { + librariesBuilder_.addAllMessages(other.libraries_); + } + } + } + if (other.hasScript()) { + mergeScript(other.getScript()); + } + if (!other.args_.isEmpty()) { + if (args_.isEmpty()) { + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureArgsIsMutable(); + args_.addAll(other.args_); + } + onChanged(); + } + if (other.getArgumentsTruncated() != false) { + setArgumentsTruncated(other.getArgumentsTruncated()); + } + if (envVariablesBuilder_ == null) { + if (!other.envVariables_.isEmpty()) { + if (envVariables_.isEmpty()) { + envVariables_ = other.envVariables_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureEnvVariablesIsMutable(); + envVariables_.addAll(other.envVariables_); + } + onChanged(); + } + } else { + if (!other.envVariables_.isEmpty()) { + if (envVariablesBuilder_.isEmpty()) { + envVariablesBuilder_.dispose(); + envVariablesBuilder_ = null; + envVariables_ = other.envVariables_; + bitField0_ = (bitField0_ & ~0x00000004); + envVariablesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getEnvVariablesFieldBuilder() + : null; + } else { + envVariablesBuilder_.addAllMessages(other.envVariables_); + } + } + } + if (other.getEnvVariablesTruncated() != false) { + setEnvVariablesTruncated(other.getEnvVariablesTruncated()); + } + if (other.getPid() != 0L) { + setPid(other.getPid()); + } + if (other.getParentPid() != 0L) { + setParentPid(other.getParentPid()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.cloud.securitycenter.v1.Process parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.securitycenter.v1.Process) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private com.google.cloud.securitycenter.v1.File binary_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + binaryBuilder_; + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return Whether the binary field is set. + */ + public boolean hasBinary() { + return binaryBuilder_ != null || binary_ != null; + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return The binary. + */ + public com.google.cloud.securitycenter.v1.File getBinary() { + if (binaryBuilder_ == null) { + return binary_ == null + ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() + : binary_; + } else { + return binaryBuilder_.getMessage(); + } + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public Builder setBinary(com.google.cloud.securitycenter.v1.File value) { + if (binaryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + binary_ = value; + onChanged(); + } else { + binaryBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public Builder setBinary(com.google.cloud.securitycenter.v1.File.Builder builderForValue) { + if (binaryBuilder_ == null) { + binary_ = builderForValue.build(); + onChanged(); + } else { + binaryBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public Builder mergeBinary(com.google.cloud.securitycenter.v1.File value) { + if (binaryBuilder_ == null) { + if (binary_ != null) { + binary_ = + com.google.cloud.securitycenter.v1.File.newBuilder(binary_) + .mergeFrom(value) + .buildPartial(); + } else { + binary_ = value; + } + onChanged(); + } else { + binaryBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public Builder clearBinary() { + if (binaryBuilder_ == null) { + binary_ = null; + onChanged(); + } else { + binary_ = null; + binaryBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public com.google.cloud.securitycenter.v1.File.Builder getBinaryBuilder() { + + onChanged(); + return getBinaryFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + public com.google.cloud.securitycenter.v1.FileOrBuilder getBinaryOrBuilder() { + if (binaryBuilder_ != null) { + return binaryBuilder_.getMessageOrBuilder(); + } else { + return binary_ == null + ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() + : binary_; + } + } + /** + * + * + *
+     * File information for the process executable.
+     * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + getBinaryFieldBuilder() { + if (binaryBuilder_ == null) { + binaryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder>( + getBinary(), getParentForChildren(), isClean()); + binary_ = null; + } + return binaryBuilder_; + } + + private java.util.List libraries_ = + java.util.Collections.emptyList(); + + private void ensureLibrariesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + libraries_ = new java.util.ArrayList(libraries_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + librariesBuilder_; + + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public java.util.List getLibrariesList() { + if (librariesBuilder_ == null) { + return java.util.Collections.unmodifiableList(libraries_); + } else { + return librariesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public int getLibrariesCount() { + if (librariesBuilder_ == null) { + return libraries_.size(); + } else { + return librariesBuilder_.getCount(); + } + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public com.google.cloud.securitycenter.v1.File getLibraries(int index) { + if (librariesBuilder_ == null) { + return libraries_.get(index); + } else { + return librariesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder setLibraries(int index, com.google.cloud.securitycenter.v1.File value) { + if (librariesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLibrariesIsMutable(); + libraries_.set(index, value); + onChanged(); + } else { + librariesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder setLibraries( + int index, com.google.cloud.securitycenter.v1.File.Builder builderForValue) { + if (librariesBuilder_ == null) { + ensureLibrariesIsMutable(); + libraries_.set(index, builderForValue.build()); + onChanged(); + } else { + librariesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder addLibraries(com.google.cloud.securitycenter.v1.File value) { + if (librariesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLibrariesIsMutable(); + libraries_.add(value); + onChanged(); + } else { + librariesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder addLibraries(int index, com.google.cloud.securitycenter.v1.File value) { + if (librariesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLibrariesIsMutable(); + libraries_.add(index, value); + onChanged(); + } else { + librariesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder addLibraries(com.google.cloud.securitycenter.v1.File.Builder builderForValue) { + if (librariesBuilder_ == null) { + ensureLibrariesIsMutable(); + libraries_.add(builderForValue.build()); + onChanged(); + } else { + librariesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder addLibraries( + int index, com.google.cloud.securitycenter.v1.File.Builder builderForValue) { + if (librariesBuilder_ == null) { + ensureLibrariesIsMutable(); + libraries_.add(index, builderForValue.build()); + onChanged(); + } else { + librariesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder addAllLibraries( + java.lang.Iterable values) { + if (librariesBuilder_ == null) { + ensureLibrariesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, libraries_); + onChanged(); + } else { + librariesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder clearLibraries() { + if (librariesBuilder_ == null) { + libraries_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + librariesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public Builder removeLibraries(int index) { + if (librariesBuilder_ == null) { + ensureLibrariesIsMutable(); + libraries_.remove(index); + onChanged(); + } else { + librariesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public com.google.cloud.securitycenter.v1.File.Builder getLibrariesBuilder(int index) { + return getLibrariesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public com.google.cloud.securitycenter.v1.FileOrBuilder getLibrariesOrBuilder(int index) { + if (librariesBuilder_ == null) { + return libraries_.get(index); + } else { + return librariesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public java.util.List + getLibrariesOrBuilderList() { + if (librariesBuilder_ != null) { + return librariesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(libraries_); + } + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public com.google.cloud.securitycenter.v1.File.Builder addLibrariesBuilder() { + return getLibrariesFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.File.getDefaultInstance()); + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public com.google.cloud.securitycenter.v1.File.Builder addLibrariesBuilder(int index) { + return getLibrariesFieldBuilder() + .addBuilder(index, com.google.cloud.securitycenter.v1.File.getDefaultInstance()); + } + /** + * + * + *
+     * File information for libraries loaded by the process.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + public java.util.List + getLibrariesBuilderList() { + return getLibrariesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + getLibrariesFieldBuilder() { + if (librariesBuilder_ == null) { + librariesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder>( + libraries_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + libraries_ = null; + } + return librariesBuilder_; + } + + private com.google.cloud.securitycenter.v1.File script_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + scriptBuilder_; + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return Whether the script field is set. + */ + public boolean hasScript() { + return scriptBuilder_ != null || script_ != null; + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return The script. + */ + public com.google.cloud.securitycenter.v1.File getScript() { + if (scriptBuilder_ == null) { + return script_ == null + ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() + : script_; + } else { + return scriptBuilder_.getMessage(); + } + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public Builder setScript(com.google.cloud.securitycenter.v1.File value) { + if (scriptBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + script_ = value; + onChanged(); + } else { + scriptBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public Builder setScript(com.google.cloud.securitycenter.v1.File.Builder builderForValue) { + if (scriptBuilder_ == null) { + script_ = builderForValue.build(); + onChanged(); + } else { + scriptBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public Builder mergeScript(com.google.cloud.securitycenter.v1.File value) { + if (scriptBuilder_ == null) { + if (script_ != null) { + script_ = + com.google.cloud.securitycenter.v1.File.newBuilder(script_) + .mergeFrom(value) + .buildPartial(); + } else { + script_ = value; + } + onChanged(); + } else { + scriptBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public Builder clearScript() { + if (scriptBuilder_ == null) { + script_ = null; + onChanged(); + } else { + script_ = null; + scriptBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public com.google.cloud.securitycenter.v1.File.Builder getScriptBuilder() { + + onChanged(); + return getScriptFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + public com.google.cloud.securitycenter.v1.FileOrBuilder getScriptOrBuilder() { + if (scriptBuilder_ != null) { + return scriptBuilder_.getMessageOrBuilder(); + } else { + return script_ == null + ? com.google.cloud.securitycenter.v1.File.getDefaultInstance() + : script_; + } + } + /** + * + * + *
+     * When the process represents the invocation of a script,
+     * `binary` provides information about the interpreter while `script`
+     * provides information about the script file provided to the
+     * interpreter.
+     * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder> + getScriptFieldBuilder() { + if (scriptBuilder_ == null) { + scriptBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.securitycenter.v1.File, + com.google.cloud.securitycenter.v1.File.Builder, + com.google.cloud.securitycenter.v1.FileOrBuilder>( + getScript(), getParentForChildren(), isClean()); + script_ = null; + } + return scriptBuilder_; + } + + private com.google.protobuf.LazyStringList args_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureArgsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + args_ = new com.google.protobuf.LazyStringArrayList(args_); + bitField0_ |= 0x00000002; + } + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @return A list containing the args. + */ + public com.google.protobuf.ProtocolStringList getArgsList() { + return args_.getUnmodifiableView(); + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @return The count of args. + */ + public int getArgsCount() { + return args_.size(); + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param index The index of the element to return. + * @return The args at the given index. + */ + public java.lang.String getArgs(int index) { + return args_.get(index); + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param index The index of the value to return. + * @return The bytes of the args at the given index. + */ + public com.google.protobuf.ByteString getArgsBytes(int index) { + return args_.getByteString(index); + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param index The index to set the value at. + * @param value The args to set. + * @return This builder for chaining. + */ + public Builder setArgs(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param value The args to add. + * @return This builder for chaining. + */ + public Builder addArgs(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param values The args to add. + * @return This builder for chaining. + */ + public Builder addAllArgs(java.lang.Iterable values) { + ensureArgsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, args_); + onChanged(); + return this; + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @return This builder for chaining. + */ + public Builder clearArgs() { + args_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Process arguments as JSON encoded strings.
+     * 
+ * + * repeated string args = 6; + * + * @param value The bytes of the args to add. + * @return This builder for chaining. + */ + public Builder addArgsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + return this; + } + + private boolean argumentsTruncated_; + /** + * + * + *
+     * True if `args` is incomplete.
+     * 
+ * + * bool arguments_truncated = 7; + * + * @return The argumentsTruncated. + */ + @java.lang.Override + public boolean getArgumentsTruncated() { + return argumentsTruncated_; + } + /** + * + * + *
+     * True if `args` is incomplete.
+     * 
+ * + * bool arguments_truncated = 7; + * + * @param value The argumentsTruncated to set. + * @return This builder for chaining. + */ + public Builder setArgumentsTruncated(boolean value) { + + argumentsTruncated_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * True if `args` is incomplete.
+     * 
+ * + * bool arguments_truncated = 7; + * + * @return This builder for chaining. + */ + public Builder clearArgumentsTruncated() { + + argumentsTruncated_ = false; + onChanged(); + return this; + } + + private java.util.List envVariables_ = + java.util.Collections.emptyList(); + + private void ensureEnvVariablesIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + envVariables_ = + new java.util.ArrayList( + envVariables_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.EnvironmentVariable, + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder, + com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder> + envVariablesBuilder_; + + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public java.util.List + getEnvVariablesList() { + if (envVariablesBuilder_ == null) { + return java.util.Collections.unmodifiableList(envVariables_); + } else { + return envVariablesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public int getEnvVariablesCount() { + if (envVariablesBuilder_ == null) { + return envVariables_.size(); + } else { + return envVariablesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public com.google.cloud.securitycenter.v1.EnvironmentVariable getEnvVariables(int index) { + if (envVariablesBuilder_ == null) { + return envVariables_.get(index); + } else { + return envVariablesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder setEnvVariables( + int index, com.google.cloud.securitycenter.v1.EnvironmentVariable value) { + if (envVariablesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvVariablesIsMutable(); + envVariables_.set(index, value); + onChanged(); + } else { + envVariablesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder setEnvVariables( + int index, com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder builderForValue) { + if (envVariablesBuilder_ == null) { + ensureEnvVariablesIsMutable(); + envVariables_.set(index, builderForValue.build()); + onChanged(); + } else { + envVariablesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder addEnvVariables(com.google.cloud.securitycenter.v1.EnvironmentVariable value) { + if (envVariablesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvVariablesIsMutable(); + envVariables_.add(value); + onChanged(); + } else { + envVariablesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder addEnvVariables( + int index, com.google.cloud.securitycenter.v1.EnvironmentVariable value) { + if (envVariablesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEnvVariablesIsMutable(); + envVariables_.add(index, value); + onChanged(); + } else { + envVariablesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder addEnvVariables( + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder builderForValue) { + if (envVariablesBuilder_ == null) { + ensureEnvVariablesIsMutable(); + envVariables_.add(builderForValue.build()); + onChanged(); + } else { + envVariablesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder addEnvVariables( + int index, com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder builderForValue) { + if (envVariablesBuilder_ == null) { + ensureEnvVariablesIsMutable(); + envVariables_.add(index, builderForValue.build()); + onChanged(); + } else { + envVariablesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder addAllEnvVariables( + java.lang.Iterable + values) { + if (envVariablesBuilder_ == null) { + ensureEnvVariablesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, envVariables_); + onChanged(); + } else { + envVariablesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder clearEnvVariables() { + if (envVariablesBuilder_ == null) { + envVariables_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + envVariablesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public Builder removeEnvVariables(int index) { + if (envVariablesBuilder_ == null) { + ensureEnvVariablesIsMutable(); + envVariables_.remove(index); + onChanged(); + } else { + envVariablesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder getEnvVariablesBuilder( + int index) { + return getEnvVariablesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder getEnvVariablesOrBuilder( + int index) { + if (envVariablesBuilder_ == null) { + return envVariables_.get(index); + } else { + return envVariablesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public java.util.List + getEnvVariablesOrBuilderList() { + if (envVariablesBuilder_ != null) { + return envVariablesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(envVariables_); + } + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder addEnvVariablesBuilder() { + return getEnvVariablesFieldBuilder() + .addBuilder(com.google.cloud.securitycenter.v1.EnvironmentVariable.getDefaultInstance()); + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder addEnvVariablesBuilder( + int index) { + return getEnvVariablesFieldBuilder() + .addBuilder( + index, com.google.cloud.securitycenter.v1.EnvironmentVariable.getDefaultInstance()); + } + /** + * + * + *
+     * Process environment variables.
+     * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + public java.util.List + getEnvVariablesBuilderList() { + return getEnvVariablesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.EnvironmentVariable, + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder, + com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder> + getEnvVariablesFieldBuilder() { + if (envVariablesBuilder_ == null) { + envVariablesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.securitycenter.v1.EnvironmentVariable, + com.google.cloud.securitycenter.v1.EnvironmentVariable.Builder, + com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder>( + envVariables_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + envVariables_ = null; + } + return envVariablesBuilder_; + } + + private boolean envVariablesTruncated_; + /** + * + * + *
+     * True if `env_variables` is incomplete.
+     * 
+ * + * bool env_variables_truncated = 9; + * + * @return The envVariablesTruncated. + */ + @java.lang.Override + public boolean getEnvVariablesTruncated() { + return envVariablesTruncated_; + } + /** + * + * + *
+     * True if `env_variables` is incomplete.
+     * 
+ * + * bool env_variables_truncated = 9; + * + * @param value The envVariablesTruncated to set. + * @return This builder for chaining. + */ + public Builder setEnvVariablesTruncated(boolean value) { + + envVariablesTruncated_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * True if `env_variables` is incomplete.
+     * 
+ * + * bool env_variables_truncated = 9; + * + * @return This builder for chaining. + */ + public Builder clearEnvVariablesTruncated() { + + envVariablesTruncated_ = false; + onChanged(); + return this; + } + + private long pid_; + /** + * + * + *
+     * The process id.
+     * 
+ * + * int64 pid = 10; + * + * @return The pid. + */ + @java.lang.Override + public long getPid() { + return pid_; + } + /** + * + * + *
+     * The process id.
+     * 
+ * + * int64 pid = 10; + * + * @param value The pid to set. + * @return This builder for chaining. + */ + public Builder setPid(long value) { + + pid_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The process id.
+     * 
+ * + * int64 pid = 10; + * + * @return This builder for chaining. + */ + public Builder clearPid() { + + pid_ = 0L; + onChanged(); + return this; + } + + private long parentPid_; + /** + * + * + *
+     * The parent process id.
+     * 
+ * + * int64 parent_pid = 11; + * + * @return The parentPid. + */ + @java.lang.Override + public long getParentPid() { + return parentPid_; + } + /** + * + * + *
+     * The parent process id.
+     * 
+ * + * int64 parent_pid = 11; + * + * @param value The parentPid to set. + * @return This builder for chaining. + */ + public Builder setParentPid(long value) { + + parentPid_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The parent process id.
+     * 
+ * + * int64 parent_pid = 11; + * + * @return This builder for chaining. + */ + public Builder clearParentPid() { + + parentPid_ = 0L; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.cloud.securitycenter.v1.Process) + } + + // @@protoc_insertion_point(class_scope:google.cloud.securitycenter.v1.Process) + private static final com.google.cloud.securitycenter.v1.Process DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.securitycenter.v1.Process(); + } + + public static com.google.cloud.securitycenter.v1.Process getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Process parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Process(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.cloud.securitycenter.v1.Process getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessOrBuilder.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessOrBuilder.java new file mode 100644 index 000000000..00904a14f --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessOrBuilder.java @@ -0,0 +1,312 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/process.proto + +package com.google.cloud.securitycenter.v1; + +public interface ProcessOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.securitycenter.v1.Process) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return Whether the binary field is set. + */ + boolean hasBinary(); + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + * + * @return The binary. + */ + com.google.cloud.securitycenter.v1.File getBinary(); + /** + * + * + *
+   * File information for the process executable.
+   * 
+ * + * .google.cloud.securitycenter.v1.File binary = 3; + */ + com.google.cloud.securitycenter.v1.FileOrBuilder getBinaryOrBuilder(); + + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + java.util.List getLibrariesList(); + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + com.google.cloud.securitycenter.v1.File getLibraries(int index); + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + int getLibrariesCount(); + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + java.util.List + getLibrariesOrBuilderList(); + /** + * + * + *
+   * File information for libraries loaded by the process.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.File libraries = 4; + */ + com.google.cloud.securitycenter.v1.FileOrBuilder getLibrariesOrBuilder(int index); + + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return Whether the script field is set. + */ + boolean hasScript(); + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + * + * @return The script. + */ + com.google.cloud.securitycenter.v1.File getScript(); + /** + * + * + *
+   * When the process represents the invocation of a script,
+   * `binary` provides information about the interpreter while `script`
+   * provides information about the script file provided to the
+   * interpreter.
+   * 
+ * + * .google.cloud.securitycenter.v1.File script = 5; + */ + com.google.cloud.securitycenter.v1.FileOrBuilder getScriptOrBuilder(); + + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @return A list containing the args. + */ + java.util.List getArgsList(); + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @return The count of args. + */ + int getArgsCount(); + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @param index The index of the element to return. + * @return The args at the given index. + */ + java.lang.String getArgs(int index); + /** + * + * + *
+   * Process arguments as JSON encoded strings.
+   * 
+ * + * repeated string args = 6; + * + * @param index The index of the value to return. + * @return The bytes of the args at the given index. + */ + com.google.protobuf.ByteString getArgsBytes(int index); + + /** + * + * + *
+   * True if `args` is incomplete.
+   * 
+ * + * bool arguments_truncated = 7; + * + * @return The argumentsTruncated. + */ + boolean getArgumentsTruncated(); + + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + java.util.List getEnvVariablesList(); + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + com.google.cloud.securitycenter.v1.EnvironmentVariable getEnvVariables(int index); + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + int getEnvVariablesCount(); + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + java.util.List + getEnvVariablesOrBuilderList(); + /** + * + * + *
+   * Process environment variables.
+   * 
+ * + * repeated .google.cloud.securitycenter.v1.EnvironmentVariable env_variables = 8; + */ + com.google.cloud.securitycenter.v1.EnvironmentVariableOrBuilder getEnvVariablesOrBuilder( + int index); + + /** + * + * + *
+   * True if `env_variables` is incomplete.
+   * 
+ * + * bool env_variables_truncated = 9; + * + * @return The envVariablesTruncated. + */ + boolean getEnvVariablesTruncated(); + + /** + * + * + *
+   * The process id.
+   * 
+ * + * int64 pid = 10; + * + * @return The pid. + */ + long getPid(); + + /** + * + * + *
+   * The parent process id.
+   * 
+ * + * int64 parent_pid = 11; + * + * @return The parentPid. + */ + long getParentPid(); +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessProto.java b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessProto.java new file mode 100644 index 000000000..342b225b8 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/java/com/google/cloud/securitycenter/v1/ProcessProto.java @@ -0,0 +1,102 @@ +/* + * 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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/cloud/securitycenter/v1/process.proto + +package com.google.cloud.securitycenter.v1; + +public final class ProcessProto { + private ProcessProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_Process_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_Process_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n,google/cloud/securitycenter/v1/process" + + ".proto\022\036google.cloud.securitycenter.v1\032)" + + "google/cloud/securitycenter/v1/file.prot" + + "o\"\347\002\n\007Process\0224\n\006binary\030\003 \001(\0132$.google.c" + + "loud.securitycenter.v1.File\0227\n\tlibraries" + + "\030\004 \003(\0132$.google.cloud.securitycenter.v1." + + "File\0224\n\006script\030\005 \001(\0132$.google.cloud.secu" + + "ritycenter.v1.File\022\014\n\004args\030\006 \003(\t\022\033\n\023argu" + + "ments_truncated\030\007 \001(\010\022J\n\renv_variables\030\010" + + " \003(\01323.google.cloud.securitycenter.v1.En" + + "vironmentVariable\022\037\n\027env_variables_trunc" + + "ated\030\t \001(\010\022\013\n\003pid\030\n \001(\003\022\022\n\nparent_pid\030\013 " + + "\001(\003\"0\n\023EnvironmentVariable\022\014\n\004name\030\001 \001(\t" + + "\022\013\n\003val\030\002 \001(\tB\350\001\n\"com.google.cloud.secur" + + "itycenter.v1B\014ProcessProtoP\001ZLgoogle.gol" + + "ang.org/genproto/googleapis/cloud/securi" + + "tycenter/v1;securitycenter\252\002\036Google.Clou" + + "d.SecurityCenter.V1\312\002\036Google\\Cloud\\Secur" + + "ityCenter\\V1\352\002!Google::Cloud::SecurityCe" + + "nter::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.cloud.securitycenter.v1.FileProto.getDescriptor(), + }); + internal_static_google_cloud_securitycenter_v1_Process_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_securitycenter_v1_Process_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_Process_descriptor, + new java.lang.String[] { + "Binary", + "Libraries", + "Script", + "Args", + "ArgumentsTruncated", + "EnvVariables", + "EnvVariablesTruncated", + "Pid", + "ParentPid", + }); + internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_securitycenter_v1_EnvironmentVariable_descriptor, + new java.lang.String[] { + "Name", "Val", + }); + com.google.cloud.securitycenter.v1.FileProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/compliance.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/compliance.proto new file mode 100644 index 000000000..ca1353b69 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/compliance.proto @@ -0,0 +1,39 @@ +// Copyright 2022 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.securitycenter.v1; + +option csharp_namespace = "Google.Cloud.SecurityCenter.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/v1;securitycenter"; +option java_multiple_files = true; +option java_outer_classname = "ComplianceProto"; +option java_package = "com.google.cloud.securitycenter.v1"; +option php_namespace = "Google\\Cloud\\SecurityCenter\\V1"; +option ruby_package = "Google::Cloud::SecurityCenter::V1"; + +// Contains compliance information about a security standard indicating unmet +// recommendations. +message Compliance { + // Refers to industry wide standards or benchmarks e.g. "cis", "pci", "owasp", + // etc. + string standard = 1; + + // Version of the standard/benchmark e.g. 1.1 + string version = 2; + + // Policies within the standard/benchmark e.g. A.12.4.1 + repeated string ids = 3; +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/exfiltration.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/exfiltration.proto new file mode 100644 index 000000000..14e644f66 --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/exfiltration.proto @@ -0,0 +1,52 @@ +// Copyright 2022 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.securitycenter.v1; + +option csharp_namespace = "Google.Cloud.SecurityCenter.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/v1;securitycenter"; +option java_multiple_files = true; +option java_outer_classname = "ExfiltrationProto"; +option java_package = "com.google.cloud.securitycenter.v1"; +option php_namespace = "Google\\Cloud\\SecurityCenter\\V1"; +option ruby_package = "Google::Cloud::SecurityCenter::V1"; + +// Exfiltration represents a data exfiltration attempt of one or more +// sources to one or more targets. Sources represent the source +// of data that is exfiltrated, and Targets represents the destination the +// data was copied to. +message Exfiltration { + // If there are multiple sources, then the data is considered "joined" between + // them. For instance, BigQuery can join multiple tables, and each + // table would be considered a source. + repeated ExfilResource sources = 1; + + // If there are multiple targets, each target would get a complete copy of the + // "joined" source data. + repeated ExfilResource targets = 2; +} + +// Resource that has been exfiltrated or exfiltrated_to. +message ExfilResource { + // Resource's URI (https://google.aip.dev/122#full-resource-names) + string name = 1; + + // Subcomponents of the asset that is exfiltrated - these could be + // URIs used during exfiltration, table names, databases, filenames, etc. + // For example, multiple tables may be exfiltrated from the same CloudSQL + // instance, or multiple files from the same Cloud Storage bucket. + repeated string components = 2; +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/file.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/file.proto new file mode 100644 index 000000000..97ba1d0bd --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/file.proto @@ -0,0 +1,52 @@ +// Copyright 2022 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.securitycenter.v1; + +option csharp_namespace = "Google.Cloud.SecurityCenter.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/v1;securitycenter"; +option java_multiple_files = true; +option java_outer_classname = "FileProto"; +option java_package = "com.google.cloud.securitycenter.v1"; +option php_namespace = "Google\\Cloud\\SecurityCenter\\V1"; +option ruby_package = "Google::Cloud::SecurityCenter::V1"; + +// File information about the related binary/library used by an executable, or +// the script used by a script interpreter +message File { + // Absolute path of the file as a JSON encoded string. + string path = 1; + + // Size of the file in bytes. + int64 size = 2; + + // SHA256 hash of the first hashed_size bytes of the file encoded as a + // hex string. If hashed_size == size, hash_sha256 represents the SHA256 hash + // of the entire file. + string sha256 = 3; + + // The length in bytes of the file prefix that was hashed. If + // hashed_size == size, any hashes reported represent the entire + // file. + int64 hashed_size = 4; + + // True when the hash covers only a prefix of the file. + bool partially_hashed = 5; + + // Prefix of the file contents as a JSON encoded string. + // (Currently only populated for Malicious Script Executed findings.) + string contents = 6; +} diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/finding.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/finding.proto index 20d920d24..e43a90c28 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/finding.proto +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/finding.proto @@ -19,11 +19,14 @@ package google.cloud.securitycenter.v1; import "google/api/field_behavior.proto"; import "google/api/resource.proto"; import "google/cloud/securitycenter/v1/access.proto"; +import "google/cloud/securitycenter/v1/compliance.proto"; import "google/cloud/securitycenter/v1/connection.proto"; +import "google/cloud/securitycenter/v1/exfiltration.proto"; import "google/cloud/securitycenter/v1/external_system.proto"; import "google/cloud/securitycenter/v1/iam_binding.proto"; import "google/cloud/securitycenter/v1/indicator.proto"; import "google/cloud/securitycenter/v1/mitre_attack.proto"; +import "google/cloud/securitycenter/v1/process.proto"; import "google/cloud/securitycenter/v1/security_marks.proto"; import "google/cloud/securitycenter/v1/vulnerability.proto"; import "google/protobuf/struct.proto"; @@ -251,11 +254,13 @@ message Finding { Vulnerability vulnerability = 20; // Output only. The most recent time this finding was muted or unmuted. - google.protobuf.Timestamp mute_update_time = 21 [(google.api.field_behavior) = OUTPUT_ONLY]; + google.protobuf.Timestamp mute_update_time = 21 + [(google.api.field_behavior) = OUTPUT_ONLY]; - // Output only. Third party SIEM/SOAR fields within SCC, contains external system - // information and external system finding fields. - map external_systems = 22 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. Third party SIEM/SOAR fields within SCC, contains external + // system information and external system finding fields. + map external_systems = 22 + [(google.api.field_behavior) = OUTPUT_ONLY]; // MITRE ATT&CK tactics and techniques related to this finding. // See: https://attack.mitre.org @@ -274,9 +279,19 @@ message Finding { // shouldn't set the value of mute. string mute_initiator = 28; + // Represents operating system processes associated with the Finding. + repeated Process processes = 30; + + // Contains compliance information for security standards associated to the + // finding. + repeated Compliance compliances = 34; + // Contains more detail about the finding. string description = 37; + // Represents exfiltration associated with the Finding. + Exfiltration exfiltration = 38; + // Represents IAM bindings associated with the Finding. repeated IamBinding iam_bindings = 39; diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/mitre_attack.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/mitre_attack.proto index bb315d5f2..c65f62f17 100644 --- a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/mitre_attack.proto +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/mitre_attack.proto @@ -78,7 +78,6 @@ message MitreAttack { // MITRE ATT&CK techniques that can be referenced by SCC findings. // See: https://attack.mitre.org/techniques/enterprise/ - // Next ID: 31 enum Technique { // Unspecified value. TECHNIQUE_UNSPECIFIED = 0; @@ -172,6 +171,9 @@ message MitreAttack { // T1484 DOMAIN_POLICY_MODIFICATION = 30; + + // T1562 + IMPAIR_DEFENSES = 31; } // The MITRE ATT&CK tactic most closely represented by this finding, if any. diff --git a/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/process.proto b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/process.proto new file mode 100644 index 000000000..185f0467f --- /dev/null +++ b/proto-google-cloud-securitycenter-v1/src/main/proto/google/cloud/securitycenter/v1/process.proto @@ -0,0 +1,70 @@ +// Copyright 2022 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 +// +// 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. + +syntax = "proto3"; + +package google.cloud.securitycenter.v1; + +import "google/cloud/securitycenter/v1/file.proto"; + +option csharp_namespace = "Google.Cloud.SecurityCenter.V1"; +option go_package = "google.golang.org/genproto/googleapis/cloud/securitycenter/v1;securitycenter"; +option java_multiple_files = true; +option java_outer_classname = "ProcessProto"; +option java_package = "com.google.cloud.securitycenter.v1"; +option php_namespace = "Google\\Cloud\\SecurityCenter\\V1"; +option ruby_package = "Google::Cloud::SecurityCenter::V1"; + +// Represents an operating system process. +message Process { + // File information for the process executable. + File binary = 3; + + // File information for libraries loaded by the process. + repeated File libraries = 4; + + // When the process represents the invocation of a script, + // `binary` provides information about the interpreter while `script` + // provides information about the script file provided to the + // interpreter. + File script = 5; + + // Process arguments as JSON encoded strings. + repeated string args = 6; + + // True if `args` is incomplete. + bool arguments_truncated = 7; + + // Process environment variables. + repeated EnvironmentVariable env_variables = 8; + + // True if `env_variables` is incomplete. + bool env_variables_truncated = 9; + + // The process id. + int64 pid = 10; + + // The parent process id. + int64 parent_pid = 11; +} + +// EnvironmentVariable is a name-value pair to store environment variables for +// Process. +message EnvironmentVariable { + // Environment variable name as a JSON encoded string. + string name = 1; + + // Environment variable value as a JSON encoded string. + string val = 2; +} diff --git a/proto-google-cloud-securitycenter-v1beta1/pom.xml b/proto-google-cloud-securitycenter-v1beta1/pom.xml index fc3f5a92f..2e94a62ea 100644 --- a/proto-google-cloud-securitycenter-v1beta1/pom.xml +++ b/proto-google-cloud-securitycenter-v1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-securitycenter-v1beta1 - 0.101.0 + 0.102.0 proto-google-cloud-securitycenter-v1beta1 PROTO library for proto-google-cloud-securitycenter-v1beta1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/proto-google-cloud-securitycenter-v1p1beta1/pom.xml b/proto-google-cloud-securitycenter-v1p1beta1/pom.xml index dd261d022..151191799 100644 --- a/proto-google-cloud-securitycenter-v1p1beta1/pom.xml +++ b/proto-google-cloud-securitycenter-v1p1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-securitycenter-v1p1beta1 - 0.101.0 + 0.102.0 proto-google-cloud-securitycenter-v1p1beta1 PROTO library for proto-google-cloud-securitycenter-v1p1beta1 com.google.cloud google-cloud-securitycenter-parent - 2.6.0 + 2.7.0 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 8f8808b02..4a713dda7 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,20 +29,20 @@ com.google.cloud google-cloud-securitycenter - 2.5.6 + 2.6.0 com.google.cloud google-cloud-pubsub - 1.118.0 + 1.119.1 com.google.protobuf protobuf-java-util - 3.20.1 + 3.21.2 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index d98796ff4..ee77a6289 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,19 +28,19 @@ com.google.cloud google-cloud-securitycenter - 2.5.6 + 2.6.0 com.google.cloud google-cloud-pubsub - 1.118.0 + 1.119.1 com.google.protobuf protobuf-java-util - 3.20.1 + 3.21.2 @@ -58,7 +58,7 @@ com.google.cloud google-cloud-bigquery - 2.11.2 + 2.13.6 test diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindings.java new file mode 100644 index 000000000..c6442a81f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindings.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_bulkmutefindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.longrunning.Operation; + +public class AsyncBulkMuteFindings { + + public static void main(String[] args) throws Exception { + asyncBulkMuteFindings(); + } + + public static void asyncBulkMuteFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BulkMuteFindingsRequest request = + BulkMuteFindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setFilter("filter-1274492040") + .setMuteAnnotation("muteAnnotation-2111042008") + .build(); + ApiFuture future = + securityCenterClient.bulkMuteFindingsCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_bulkmutefindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindingsLRO.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindingsLRO.java new file mode 100644 index 000000000..59ec5b8c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/AsyncBulkMuteFindingsLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_bulkmutefindings_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncBulkMuteFindingsLRO { + + public static void main(String[] args) throws Exception { + asyncBulkMuteFindingsLRO(); + } + + public static void asyncBulkMuteFindingsLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BulkMuteFindingsRequest request = + BulkMuteFindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setFilter("filter-1274492040") + .setMuteAnnotation("muteAnnotation-2111042008") + .build(); + OperationFuture future = + securityCenterClient.bulkMuteFindingsOperationCallable().futureCall(request); + // Do something. + BulkMuteFindingsResponse response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_bulkmutefindings_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindings.java new file mode 100644 index 000000000..2a6f935d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindings.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_bulkmutefindings_sync] +import com.google.cloud.securitycenter.v1.BulkMuteFindingsRequest; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncBulkMuteFindings { + + public static void main(String[] args) throws Exception { + syncBulkMuteFindings(); + } + + public static void syncBulkMuteFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BulkMuteFindingsRequest request = + BulkMuteFindingsRequest.newBuilder() + .setParent(FolderName.of("[FOLDER]").toString()) + .setFilter("filter-1274492040") + .setMuteAnnotation("muteAnnotation-2111042008") + .build(); + BulkMuteFindingsResponse response = securityCenterClient.bulkMuteFindingsAsync(request).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_bulkmutefindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsResourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsResourcename.java new file mode 100644 index 000000000..c4de3b477 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsResourcename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_bulkmutefindings_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncBulkMuteFindingsResourcename { + + public static void main(String[] args) throws Exception { + syncBulkMuteFindingsResourcename(); + } + + public static void syncBulkMuteFindingsResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName parent = FolderName.of("[FOLDER]"); + BulkMuteFindingsResponse response = securityCenterClient.bulkMuteFindingsAsync(parent).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_bulkmutefindings_resourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsString.java new file mode 100644 index 000000000..b439aa324 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/bulkmutefindings/SyncBulkMuteFindingsString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_bulkmutefindings_string_sync] +import com.google.cloud.securitycenter.v1.BulkMuteFindingsResponse; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncBulkMuteFindingsString { + + public static void main(String[] args) throws Exception { + syncBulkMuteFindingsString(); + } + + public static void syncBulkMuteFindingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = FolderName.of("[FOLDER]").toString(); + BulkMuteFindingsResponse response = securityCenterClient.bulkMuteFindingsAsync(parent).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_bulkmutefindings_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..0303ea32a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1_generated_securitycenterclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..444ebf044 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_create_setcredentialsprovider1_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityCenterSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1_generated_securitycenterclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..996234420 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_create_setendpoint_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder().setEndpoint(myEndpoint).build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1_generated_securitycenterclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/AsyncCreateBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/AsyncCreateBigQueryExport.java new file mode 100644 index 000000000..944fae5bc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/AsyncCreateBigQueryExport.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.CreateBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncCreateBigQueryExport { + + public static void main(String[] args) throws Exception { + asyncCreateBigQueryExport(); + } + + public static void asyncCreateBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateBigQueryExportRequest request = + CreateBigQueryExportRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setBigQueryExport(BigQueryExport.newBuilder().build()) + .setBigQueryExportId("bigQueryExportId1024198583") + .build(); + ApiFuture future = + securityCenterClient.createBigQueryExportCallable().futureCall(request); + // Do something. + BigQueryExport response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExport.java new file mode 100644 index 000000000..5a3e85856 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExport.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.CreateBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateBigQueryExport { + + public static void main(String[] args) throws Exception { + syncCreateBigQueryExport(); + } + + public static void syncCreateBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateBigQueryExportRequest request = + CreateBigQueryExportRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setBigQueryExport(BigQueryExport.newBuilder().build()) + .setBigQueryExportId("bigQueryExportId1024198583") + .build(); + BigQueryExport response = securityCenterClient.createBigQueryExport(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.java new file mode 100644 index 000000000..f30a70db0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportFoldernameBigqueryexportString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_foldernamebigqueryexportstring_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateBigQueryExportFoldernameBigqueryexportString { + + public static void main(String[] args) throws Exception { + syncCreateBigQueryExportFoldernameBigqueryexportString(); + } + + public static void syncCreateBigQueryExportFoldernameBigqueryexportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + BigQueryExport response = + securityCenterClient.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_foldernamebigqueryexportstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.java new file mode 100644 index 000000000..22ebe1bb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportOrganizationnameBigqueryexportString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_organizationnamebigqueryexportstring_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateBigQueryExportOrganizationnameBigqueryexportString { + + public static void main(String[] args) throws Exception { + syncCreateBigQueryExportOrganizationnameBigqueryexportString(); + } + + public static void syncCreateBigQueryExportOrganizationnameBigqueryexportString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + BigQueryExport response = + securityCenterClient.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_organizationnamebigqueryexportstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.java new file mode 100644 index 000000000..6488ecab7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportProjectnameBigqueryexportString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_projectnamebigqueryexportstring_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateBigQueryExportProjectnameBigqueryexportString { + + public static void main(String[] args) throws Exception { + syncCreateBigQueryExportProjectnameBigqueryexportString(); + } + + public static void syncCreateBigQueryExportProjectnameBigqueryexportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + BigQueryExport response = + securityCenterClient.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_projectnamebigqueryexportstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.java new file mode 100644 index 000000000..ea7afc7e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createbigqueryexport/SyncCreateBigQueryExportStringBigqueryexportString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createbigqueryexport_stringbigqueryexportstring_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateBigQueryExportStringBigqueryexportString { + + public static void main(String[] args) throws Exception { + syncCreateBigQueryExportStringBigqueryexportString(); + } + + public static void syncCreateBigQueryExportStringBigqueryexportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + String bigQueryExportId = "bigQueryExportId1024198583"; + BigQueryExport response = + securityCenterClient.createBigQueryExport(parent, bigQueryExport, bigQueryExportId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createbigqueryexport_stringbigqueryexportstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/AsyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000..fdc81fbc3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/AsyncCreateFinding.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class AsyncCreateFinding { + + public static void main(String[] args) throws Exception { + asyncCreateFinding(); + } + + public static void asyncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000..1b85f4867 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFinding.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createfinding_sync] +import com.google.cloud.securitycenter.v1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncCreateFinding { + + public static void main(String[] args) throws Exception { + syncCreateFinding(); + } + + public static void syncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + Finding response = securityCenterClient.createFinding(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000..68f11acc8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncCreateFindingSourcenameStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingSourcenameStringFinding(); + } + + public static void syncCreateFindingSourcenameStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000..140966924 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createfinding_stringstringfinding_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncCreateFindingStringStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingStringStringFinding(); + } + + public static void syncCreateFindingStringStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createfinding_stringstringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/AsyncCreateMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/AsyncCreateMuteConfig.java new file mode 100644 index 000000000..57c32d9fe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/AsyncCreateMuteConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.CreateMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncCreateMuteConfig { + + public static void main(String[] args) throws Exception { + asyncCreateMuteConfig(); + } + + public static void asyncCreateMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateMuteConfigRequest request = + CreateMuteConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setMuteConfig(MuteConfig.newBuilder().build()) + .setMuteConfigId("muteConfigId1689669942") + .build(); + ApiFuture future = + securityCenterClient.createMuteConfigCallable().futureCall(request); + // Do something. + MuteConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfig.java new file mode 100644 index 000000000..c8711891c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_sync] +import com.google.cloud.securitycenter.v1.CreateMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfig { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfig(); + } + + public static void syncCreateMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateMuteConfigRequest request = + CreateMuteConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setMuteConfig(MuteConfig.newBuilder().build()) + .setMuteConfigId("muteConfigId1689669942") + .build(); + MuteConfig response = securityCenterClient.createMuteConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.java new file mode 100644 index 000000000..28ed3bb0f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfig.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_foldernamemuteconfig_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigFoldernameMuteconfig { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigFoldernameMuteconfig(); + } + + public static void syncCreateMuteConfigFoldernameMuteconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_foldernamemuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.java new file mode 100644 index 000000000..514cd1d91 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigFoldernameMuteconfigString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_foldernamemuteconfigstring_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigFoldernameMuteconfigString { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigFoldernameMuteconfigString(); + } + + public static void syncCreateMuteConfigFoldernameMuteconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig, muteConfigId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_foldernamemuteconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.java new file mode 100644 index 000000000..89c4e8b64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfig.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_organizationnamemuteconfig_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigOrganizationnameMuteconfig { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigOrganizationnameMuteconfig(); + } + + public static void syncCreateMuteConfigOrganizationnameMuteconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_organizationnamemuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.java new file mode 100644 index 000000000..5148cacc0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigOrganizationnameMuteconfigString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_organizationnamemuteconfigstring_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigOrganizationnameMuteconfigString { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigOrganizationnameMuteconfigString(); + } + + public static void syncCreateMuteConfigOrganizationnameMuteconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig, muteConfigId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_organizationnamemuteconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.java new file mode 100644 index 000000000..ca1ba18a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfig.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_projectnamemuteconfig_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigProjectnameMuteconfig { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigProjectnameMuteconfig(); + } + + public static void syncCreateMuteConfigProjectnameMuteconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_projectnamemuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.java new file mode 100644 index 000000000..ec328ffad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigProjectnameMuteconfigString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_projectnamemuteconfigstring_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigProjectnameMuteconfigString { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigProjectnameMuteconfigString(); + } + + public static void syncCreateMuteConfigProjectnameMuteconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig, muteConfigId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_projectnamemuteconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfig.java new file mode 100644 index 000000000..35ef03af3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfig.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_stringmuteconfig_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigStringMuteconfig { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigStringMuteconfig(); + } + + public static void syncCreateMuteConfigStringMuteconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_stringmuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.java new file mode 100644 index 000000000..dcc0b2caf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createmuteconfig/SyncCreateMuteConfigStringMuteconfigString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createmuteconfig_stringmuteconfigstring_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateMuteConfigStringMuteconfigString { + + public static void main(String[] args) throws Exception { + syncCreateMuteConfigStringMuteconfigString(); + } + + public static void syncCreateMuteConfigStringMuteconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + String muteConfigId = "muteConfigId1689669942"; + MuteConfig response = securityCenterClient.createMuteConfig(parent, muteConfig, muteConfigId); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createmuteconfig_stringmuteconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java new file mode 100644 index 000000000..e180cb232 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncCreateNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncCreateNotificationConfig(); + } + + public static void asyncCreateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateNotificationConfigRequest request = + CreateNotificationConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setConfigId("configId-580140035") + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.createNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java new file mode 100644 index 000000000..c6547af1d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_sync] +import com.google.cloud.securitycenter.v1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateNotificationConfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfig(); + } + + public static void syncCreateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateNotificationConfigRequest request = + CreateNotificationConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setConfigId("configId-580140035") + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .build(); + NotificationConfig response = securityCenterClient.createNotificationConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java new file mode 100644 index 000000000..edcb7cdfb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_organizationnamenotificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateNotificationConfigOrganizationnameNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigOrganizationnameNotificationconfig(); + } + + public static void syncCreateNotificationConfigOrganizationnameNotificationconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, notificationConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_organizationnamenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java new file mode 100644 index 000000000..bd283204e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_organizationnamestringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateNotificationConfigOrganizationnameStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigOrganizationnameStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigOrganizationnameStringNotificationconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, configId, notificationConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_organizationnamestringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java new file mode 100644 index 000000000..44f21752a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_stringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateNotificationConfigStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigStringNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, notificationConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_stringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java new file mode 100644 index 000000000..8e27ff79f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createnotificationconfig_stringstringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncCreateNotificationConfigStringStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigStringStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigStringStringNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, configId, notificationConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createnotificationconfig_stringstringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/AsyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000..2e2d2bcf0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/AsyncCreateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class AsyncCreateSource { + + public static void main(String[] args) throws Exception { + asyncCreateSource(); + } + + public static void asyncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000..2eddbe703 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createsource_sync] +import com.google.cloud.securitycenter.v1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + Source response = securityCenterClient.createSource(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000..9a9a94d4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createsource_organizationnamesource_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncCreateSourceOrganizationnameSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceOrganizationnameSource(); + } + + public static void syncCreateSourceOrganizationnameSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createsource_organizationnamesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000..f3d5cfd39 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/createsource/SyncCreateSourceStringSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_createsource_stringsource_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncCreateSourceStringSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceStringSource(); + } + + public static void syncCreateSourceStringSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_createsource_stringsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/AsyncDeleteBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/AsyncDeleteBigQueryExport.java new file mode 100644 index 000000000..865d5cc4e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/AsyncDeleteBigQueryExport.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.DeleteBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteBigQueryExport { + + public static void main(String[] args) throws Exception { + asyncDeleteBigQueryExport(); + } + + public static void asyncDeleteBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteBigQueryExportRequest request = + DeleteBigQueryExportRequest.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .build(); + ApiFuture future = + securityCenterClient.deleteBigQueryExportCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.java new file mode 100644 index 000000000..8cc22eda3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExport.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.DeleteBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteBigQueryExport { + + public static void main(String[] args) throws Exception { + syncDeleteBigQueryExport(); + } + + public static void syncDeleteBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteBigQueryExportRequest request = + DeleteBigQueryExportRequest.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .build(); + securityCenterClient.deleteBigQueryExport(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.java new file mode 100644 index 000000000..52fcdd720 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportBigqueryexportname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_bigqueryexportname_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteBigQueryExportBigqueryexportname { + + public static void main(String[] args) throws Exception { + syncDeleteBigQueryExportBigqueryexportname(); + } + + public static void syncDeleteBigQueryExportBigqueryexportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + securityCenterClient.deleteBigQueryExport(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_bigqueryexportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.java new file mode 100644 index 000000000..e45486337 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletebigqueryexport/SyncDeleteBigQueryExportString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_string_sync] +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteBigQueryExportString { + + public static void main(String[] args) throws Exception { + syncDeleteBigQueryExportString(); + } + + public static void syncDeleteBigQueryExportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]").toString(); + securityCenterClient.deleteBigQueryExport(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletebigqueryexport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/AsyncDeleteMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/AsyncDeleteMuteConfig.java new file mode 100644 index 000000000..e04486687 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/AsyncDeleteMuteConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletemuteconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.DeleteMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteMuteConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteMuteConfig(); + } + + public static void asyncDeleteMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteMuteConfigRequest request = + DeleteMuteConfigRequest.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .build(); + ApiFuture future = securityCenterClient.deleteMuteConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletemuteconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.java new file mode 100644 index 000000000..bb4c5559e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletemuteconfig_sync] +import com.google.cloud.securitycenter.v1.DeleteMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteMuteConfig { + + public static void main(String[] args) throws Exception { + syncDeleteMuteConfig(); + } + + public static void syncDeleteMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteMuteConfigRequest request = + DeleteMuteConfigRequest.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .build(); + securityCenterClient.deleteMuteConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletemuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.java new file mode 100644 index 000000000..2e5c46b8d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigMuteconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletemuteconfig_muteconfigname_sync] +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteMuteConfigMuteconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteMuteConfigMuteconfigname(); + } + + public static void syncDeleteMuteConfigMuteconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + securityCenterClient.deleteMuteConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletemuteconfig_muteconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.java new file mode 100644 index 000000000..c61122977 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletemuteconfig/SyncDeleteMuteConfigString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletemuteconfig_string_sync] +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteMuteConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteMuteConfigString(); + } + + public static void syncDeleteMuteConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]").toString(); + securityCenterClient.deleteMuteConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletemuteconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java new file mode 100644 index 000000000..a2569af3d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteNotificationConfig(); + } + + public static void asyncDeleteNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteNotificationConfigRequest request = + DeleteNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + ApiFuture future = + securityCenterClient.deleteNotificationConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java new file mode 100644 index 000000000..91b0cd3f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_sync] +import com.google.cloud.securitycenter.v1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfig { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfig(); + } + + public static void syncDeleteNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteNotificationConfigRequest request = + DeleteNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + securityCenterClient.deleteNotificationConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000..cc1c094c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfigNotificationconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfigNotificationconfigname(); + } + + public static void syncDeleteNotificationConfigNotificationconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + securityCenterClient.deleteNotificationConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_notificationconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java new file mode 100644 index 000000000..55d9040a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_string_sync] +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfigString(); + } + + public static void syncDeleteNotificationConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString(); + securityCenterClient.deleteNotificationConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_deletenotificationconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/AsyncGetBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/AsyncGetBigQueryExport.java new file mode 100644 index 000000000..abcc7c333 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/AsyncGetBigQueryExport.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getbigqueryexport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.GetBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncGetBigQueryExport { + + public static void main(String[] args) throws Exception { + asyncGetBigQueryExport(); + } + + public static void asyncGetBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetBigQueryExportRequest request = + GetBigQueryExportRequest.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .build(); + ApiFuture future = + securityCenterClient.getBigQueryExportCallable().futureCall(request); + // Do something. + BigQueryExport response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getbigqueryexport_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExport.java new file mode 100644 index 000000000..d84f188fa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExport.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getbigqueryexport_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.GetBigQueryExportRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetBigQueryExport { + + public static void main(String[] args) throws Exception { + syncGetBigQueryExport(); + } + + public static void syncGetBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetBigQueryExportRequest request = + GetBigQueryExportRequest.newBuilder() + .setName( + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]") + .toString()) + .build(); + BigQueryExport response = securityCenterClient.getBigQueryExport(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getbigqueryexport_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.java new file mode 100644 index 000000000..7dd4b0b6b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportBigqueryexportname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getbigqueryexport_bigqueryexportname_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetBigQueryExportBigqueryexportname { + + public static void main(String[] args) throws Exception { + syncGetBigQueryExportBigqueryexportname(); + } + + public static void syncGetBigQueryExportBigqueryexportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BigQueryExportName name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]"); + BigQueryExport response = securityCenterClient.getBigQueryExport(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getbigqueryexport_bigqueryexportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportString.java new file mode 100644 index 000000000..6181d5736 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getbigqueryexport/SyncGetBigQueryExportString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getbigqueryexport_string_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.BigQueryExportName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetBigQueryExportString { + + public static void main(String[] args) throws Exception { + syncGetBigQueryExportString(); + } + + public static void syncGetBigQueryExportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + BigQueryExportName.ofOrganizationExportName("[ORGANIZATION]", "[EXPORT]").toString(); + BigQueryExport response = securityCenterClient.getBigQueryExport(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getbigqueryexport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000..ab71ffe61 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000..b31046286 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getiampolicy_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = securityCenterClient.getIamPolicy(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000..bd0143685 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getiampolicy_resourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000..3db986cd8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getiampolicy_string_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getiampolicy_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/AsyncGetMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/AsyncGetMuteConfig.java new file mode 100644 index 000000000..c5ddeda13 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/AsyncGetMuteConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getmuteconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GetMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncGetMuteConfig { + + public static void main(String[] args) throws Exception { + asyncGetMuteConfig(); + } + + public static void asyncGetMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetMuteConfigRequest request = + GetMuteConfigRequest.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .build(); + ApiFuture future = + securityCenterClient.getMuteConfigCallable().futureCall(request); + // Do something. + MuteConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getmuteconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfig.java new file mode 100644 index 000000000..9b9292da7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getmuteconfig_sync] +import com.google.cloud.securitycenter.v1.GetMuteConfigRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetMuteConfig { + + public static void main(String[] args) throws Exception { + syncGetMuteConfig(); + } + + public static void syncGetMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetMuteConfigRequest request = + GetMuteConfigRequest.newBuilder() + .setName( + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]") + .toString()) + .build(); + MuteConfig response = securityCenterClient.getMuteConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getmuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigMuteconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigMuteconfigname.java new file mode 100644 index 000000000..c14b7e199 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigMuteconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getmuteconfig_muteconfigname_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetMuteConfigMuteconfigname { + + public static void main(String[] args) throws Exception { + syncGetMuteConfigMuteconfigname(); + } + + public static void syncGetMuteConfigMuteconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + MuteConfigName name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]"); + MuteConfig response = securityCenterClient.getMuteConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getmuteconfig_muteconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigString.java new file mode 100644 index 000000000..cad370c97 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getmuteconfig/SyncGetMuteConfigString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getmuteconfig_string_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.MuteConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetMuteConfigString { + + public static void main(String[] args) throws Exception { + syncGetMuteConfigString(); + } + + public static void syncGetMuteConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + MuteConfigName.ofOrganizationMuteConfigName("[ORGANIZATION]", "[MUTE_CONFIG]").toString(); + MuteConfig response = securityCenterClient.getMuteConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getmuteconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java new file mode 100644 index 000000000..47acef37f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getnotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncGetNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncGetNotificationConfig(); + } + + public static void asyncGetNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetNotificationConfigRequest request = + GetNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + ApiFuture future = + securityCenterClient.getNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getnotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java new file mode 100644 index 000000000..2bb7672b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getnotificationconfig_sync] +import com.google.cloud.securitycenter.v1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetNotificationConfig { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfig(); + } + + public static void syncGetNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetNotificationConfigRequest request = + GetNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + NotificationConfig response = securityCenterClient.getNotificationConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000..507e2bad8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getnotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetNotificationConfigNotificationconfigname { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfigNotificationconfigname(); + } + + public static void syncGetNotificationConfigNotificationconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + NotificationConfig response = securityCenterClient.getNotificationConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getnotificationconfig_notificationconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java new file mode 100644 index 000000000..9969bd782 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getnotificationconfig_string_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.NotificationConfigName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetNotificationConfigString { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfigString(); + } + + public static void syncGetNotificationConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString(); + NotificationConfig response = securityCenterClient.getNotificationConfig(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getnotificationconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000..69bb59b2a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncGetOrganizationSettings(); + } + + public static void asyncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.getOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000..941a0314d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getorganizationsettings_sync] +import com.google.cloud.securitycenter.v1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettings(); + } + + public static void syncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000..dc5076afa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsOrganizationsettingsname { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsOrganizationsettingsname(); + } + + public static void syncGetOrganizationSettingsOrganizationsettingsname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000..7c6cde6ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getorganizationsettings_string_sync] +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsString { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsString(); + } + + public static void syncGetOrganizationSettingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = OrganizationSettingsName.of("[ORGANIZATION]").toString(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getorganizationsettings_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/AsyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000..226f27795 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/AsyncGetSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GetSourceRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.SourceName; + +public class AsyncGetSource { + + public static void main(String[] args) throws Exception { + asyncGetSource(); + } + + public static void asyncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + ApiFuture future = securityCenterClient.getSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000..c32bc11c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSource.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getsource_sync] +import com.google.cloud.securitycenter.v1.GetSourceRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncGetSource { + + public static void main(String[] args) throws Exception { + syncGetSource(); + } + + public static void syncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + Source response = securityCenterClient.getSource(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000..3b9ecdbc1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceSourcename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getsource_sourcename_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncGetSourceSourcename { + + public static void main(String[] args) throws Exception { + syncGetSourceSourcename(); + } + + public static void syncGetSourceSourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getsource_sourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000..c2e7f94fa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/getsource/SyncGetSourceString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_getsource_string_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncGetSourceString { + + public static void main(String[] args) throws Exception { + syncGetSourceString(); + } + + public static void syncGetSourceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_getsource_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000..895702ced --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssets.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssets { + + public static void main(String[] args) throws Exception { + asyncGroupAssets(); + } + + public static void asyncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupAssetsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000..e00f13d02 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupassets_paged_async] +import com.google.cloud.securitycenter.v1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupAssetsPaged(); + } + + public static void asyncGroupAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/SyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000..3a2053188 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupassets/SyncGroupAssets.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupassets_sync] +import com.google.cloud.securitycenter.v1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class SyncGroupAssets { + + public static void main(String[] args) throws Exception { + syncGroupAssets(); + } + + public static void syncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000..c13adfe19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindings.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindings { + + public static void main(String[] args) throws Exception { + asyncGroupFindings(); + } + + public static void asyncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupFindingsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000..d236895d6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupfindings_paged_async] +import com.google.cloud.securitycenter.v1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupFindingsPaged(); + } + + public static void asyncGroupFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000..bd0dcd08b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindings.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupfindings_sync] +import com.google.cloud.securitycenter.v1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class SyncGroupFindings { + + public static void main(String[] args) throws Exception { + syncGroupFindings(); + } + + public static void syncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000..8603c1231 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncGroupFindingsSourcenameString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsSourcenameString(); + } + + public static void syncGroupFindingsSourcenameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000..5eda0bedd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_groupfindings_stringstring_sync] +import com.google.cloud.securitycenter.v1.GroupResult; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; + +public class SyncGroupFindingsStringString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsStringString(); + } + + public static void syncGroupFindingsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_groupfindings_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000..04cb213bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssets.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssets { + + public static void main(String[] args) throws Exception { + asyncListAssets(); + } + + public static void asyncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listAssetsPagedCallable().futureCall(request); + // Do something. + for (ListAssetsResponse.ListAssetsResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000..98397f364 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/AsyncListAssetsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listassets_paged_async] +import com.google.cloud.securitycenter.v1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncListAssetsPaged(); + } + + public static void asyncListAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); + for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/SyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000..7b483d008 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listassets/SyncListAssets.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listassets_sync] +import com.google.cloud.securitycenter.v1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListAssets { + + public static void main(String[] args) throws Exception { + syncListAssets(); + } + + public static void syncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExports.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExports.java new file mode 100644 index 000000000..729a83509 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExports.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncListBigQueryExports { + + public static void main(String[] args) throws Exception { + asyncListBigQueryExports(); + } + + public static void asyncListBigQueryExports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListBigQueryExportsRequest request = + ListBigQueryExportsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + securityCenterClient.listBigQueryExportsPagedCallable().futureCall(request); + // Do something. + for (BigQueryExport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExportsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExportsPaged.java new file mode 100644 index 000000000..5e8de8ccb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/AsyncListBigQueryExportsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_paged_async] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsResponse; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.common.base.Strings; + +public class AsyncListBigQueryExportsPaged { + + public static void main(String[] args) throws Exception { + asyncListBigQueryExportsPaged(); + } + + public static void asyncListBigQueryExportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListBigQueryExportsRequest request = + ListBigQueryExportsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListBigQueryExportsResponse response = + securityCenterClient.listBigQueryExportsCallable().call(request); + for (BigQueryExport element : response.getBigQueryExportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExports.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExports.java new file mode 100644 index 000000000..8ff14d0e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExports.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListBigQueryExports { + + public static void main(String[] args) throws Exception { + syncListBigQueryExports(); + } + + public static void syncListBigQueryExports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListBigQueryExportsRequest request = + ListBigQueryExportsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (BigQueryExport element : + securityCenterClient.listBigQueryExports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsFoldername.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsFoldername.java new file mode 100644 index 000000000..0b4607868 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsFoldername.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_foldername_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListBigQueryExportsFoldername { + + public static void main(String[] args) throws Exception { + syncListBigQueryExportsFoldername(); + } + + public static void syncListBigQueryExportsFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + for (BigQueryExport element : securityCenterClient.listBigQueryExports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_foldername_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.java new file mode 100644 index 000000000..470fbb52b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsOrganizationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_organizationname_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListBigQueryExportsOrganizationname { + + public static void main(String[] args) throws Exception { + syncListBigQueryExportsOrganizationname(); + } + + public static void syncListBigQueryExportsOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (BigQueryExport element : securityCenterClient.listBigQueryExports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsProjectname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsProjectname.java new file mode 100644 index 000000000..ce8c0514f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_projectname_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListBigQueryExportsProjectname { + + public static void main(String[] args) throws Exception { + syncListBigQueryExportsProjectname(); + } + + public static void syncListBigQueryExportsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (BigQueryExport element : securityCenterClient.listBigQueryExports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsString.java new file mode 100644 index 000000000..ae18f64e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listbigqueryexports/SyncListBigQueryExportsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listbigqueryexports_string_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListBigQueryExportsString { + + public static void main(String[] args) throws Exception { + syncListBigQueryExportsString(); + } + + public static void syncListBigQueryExportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (BigQueryExport element : securityCenterClient.listBigQueryExports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listbigqueryexports_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000..be6119324 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindings.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (ListFindingsResponse.ListFindingsResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000..e6bd21b89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,67 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listfindings_paged_async] +import com.google.cloud.securitycenter.v1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); + for (ListFindingsResponse.ListFindingsResult element : + response.getListFindingsResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000..e715c470d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listfindings/SyncListFindings.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listfindings_sync] +import com.google.cloud.securitycenter.v1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ListFindingsResponse.ListFindingsResult element : + securityCenterClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigs.java new file mode 100644 index 000000000..aacc5b034 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ListMuteConfigsRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncListMuteConfigs { + + public static void main(String[] args) throws Exception { + asyncListMuteConfigs(); + } + + public static void asyncListMuteConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListMuteConfigsRequest request = + ListMuteConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + securityCenterClient.listMuteConfigsPagedCallable().futureCall(request); + // Do something. + for (MuteConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigsPaged.java new file mode 100644 index 000000000..0fe17ccbc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/AsyncListMuteConfigsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_paged_async] +import com.google.cloud.securitycenter.v1.ListMuteConfigsRequest; +import com.google.cloud.securitycenter.v1.ListMuteConfigsResponse; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.common.base.Strings; + +public class AsyncListMuteConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListMuteConfigsPaged(); + } + + public static void asyncListMuteConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListMuteConfigsRequest request = + ListMuteConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListMuteConfigsResponse response = + securityCenterClient.listMuteConfigsCallable().call(request); + for (MuteConfig element : response.getMuteConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigs.java new file mode 100644 index 000000000..c4a7f38a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_sync] +import com.google.cloud.securitycenter.v1.ListMuteConfigsRequest; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListMuteConfigs { + + public static void main(String[] args) throws Exception { + syncListMuteConfigs(); + } + + public static void syncListMuteConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListMuteConfigsRequest request = + ListMuteConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (MuteConfig element : securityCenterClient.listMuteConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsFoldername.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsFoldername.java new file mode 100644 index 000000000..e2dcb46d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsFoldername.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_foldername_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListMuteConfigsFoldername { + + public static void main(String[] args) throws Exception { + syncListMuteConfigsFoldername(); + } + + public static void syncListMuteConfigsFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + for (MuteConfig element : securityCenterClient.listMuteConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_foldername_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsOrganizationname.java new file mode 100644 index 000000000..d1c9e4ade --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsOrganizationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_organizationname_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListMuteConfigsOrganizationname { + + public static void main(String[] args) throws Exception { + syncListMuteConfigsOrganizationname(); + } + + public static void syncListMuteConfigsOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (MuteConfig element : securityCenterClient.listMuteConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsProjectname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsProjectname.java new file mode 100644 index 000000000..eaa075bf5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_projectname_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListMuteConfigsProjectname { + + public static void main(String[] args) throws Exception { + syncListMuteConfigsProjectname(); + } + + public static void syncListMuteConfigsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (MuteConfig element : securityCenterClient.listMuteConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsString.java new file mode 100644 index 000000000..6ead853dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listmuteconfigs/SyncListMuteConfigsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listmuteconfigs_string_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListMuteConfigsString { + + public static void main(String[] args) throws Exception { + syncListMuteConfigsString(); + } + + public static void syncListMuteConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (MuteConfig element : securityCenterClient.listMuteConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listmuteconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java new file mode 100644 index 000000000..8b89ce519 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class AsyncListNotificationConfigs { + + public static void main(String[] args) throws Exception { + asyncListNotificationConfigs(); + } + + public static void asyncListNotificationConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listNotificationConfigsPagedCallable().futureCall(request); + // Do something. + for (NotificationConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java new file mode 100644 index 000000000..7edab2ebf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_paged_async] +import com.google.cloud.securitycenter.v1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1.ListNotificationConfigsResponse; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.common.base.Strings; + +public class AsyncListNotificationConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListNotificationConfigsPaged(); + } + + public static void asyncListNotificationConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListNotificationConfigsResponse response = + securityCenterClient.listNotificationConfigsCallable().call(request); + for (NotificationConfig element : response.getNotificationConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java new file mode 100644 index 000000000..18009cc65 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_sync] +import com.google.cloud.securitycenter.v1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListNotificationConfigs { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigs(); + } + + public static void syncListNotificationConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java new file mode 100644 index 000000000..b33eb99a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_organizationname_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListNotificationConfigsOrganizationname { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigsOrganizationname(); + } + + public static void syncListNotificationConfigsOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java new file mode 100644 index 000000000..1a5ff84cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_string_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncListNotificationConfigsString { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigsString(); + } + + public static void syncListNotificationConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listnotificationconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000..7e852d5a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSources.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class AsyncListSources { + + public static void main(String[] args) throws Exception { + asyncListSources(); + } + + public static void asyncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listSourcesPagedCallable().futureCall(request); + // Do something. + for (Source element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000..6af7f38e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/AsyncListSourcesPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_paged_async] +import com.google.cloud.securitycenter.v1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.common.base.Strings; + +public class AsyncListSourcesPaged { + + public static void main(String[] args) throws Exception { + asyncListSourcesPaged(); + } + + public static void asyncListSourcesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); + for (Source element : response.getSourcesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000..354c82f92 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSources.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_sync] +import com.google.cloud.securitycenter.v1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncListSources { + + public static void main(String[] args) throws Exception { + syncListSources(); + } + + public static void syncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Source element : securityCenterClient.listSources(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesFoldername.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesFoldername.java new file mode 100644 index 000000000..44087573a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesFoldername.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_foldername_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncListSourcesFoldername { + + public static void main(String[] args) throws Exception { + syncListSourcesFoldername(); + } + + public static void syncListSourcesFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_foldername_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000..2ae71e950 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_organizationname_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncListSourcesOrganizationname { + + public static void main(String[] args) throws Exception { + syncListSourcesOrganizationname(); + } + + public static void syncListSourcesOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesProjectname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesProjectname.java new file mode 100644 index 000000000..1d4bbc0bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_projectname_sync] +import com.google.cloud.securitycenter.v1.ProjectName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncListSourcesProjectname { + + public static void main(String[] args) throws Exception { + syncListSourcesProjectname(); + } + + public static void syncListSourcesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000..8b48eaa0e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/listsources/SyncListSourcesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_listsources_string_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncListSourcesString { + + public static void main(String[] args) throws Exception { + syncListSourcesString(); + } + + public static void syncListSourcesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_listsources_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000..a0dc92c9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_runassetdiscovery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.longrunning.Operation; + +public class AsyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscovery(); + } + + public static void asyncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.runAssetDiscoveryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_runassetdiscovery_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000..6e296b223 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_runassetdiscovery_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncRunAssetDiscoveryLRO { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscoveryLRO(); + } + + public static void asyncRunAssetDiscoveryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + OperationFuture future = + securityCenterClient.runAssetDiscoveryOperationCallable().futureCall(request); + // Do something. + RunAssetDiscoveryResponse response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_runassetdiscovery_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000..9ee05cbe4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_runassetdiscovery_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscovery(); + } + + public static void syncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(request).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_runassetdiscovery_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000..a63bae642 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncRunAssetDiscoveryOrganizationname { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryOrganizationname(); + } + + public static void syncRunAssetDiscoveryOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000..dbc42e284 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_runassetdiscovery_string_sync] +import com.google.cloud.securitycenter.v1.OrganizationName; +import com.google.cloud.securitycenter.v1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncRunAssetDiscoveryString { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryString(); + } + + public static void syncRunAssetDiscoveryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_runassetdiscovery_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000..8651049b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/AsyncSetFindingState.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setfindingstate_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class AsyncSetFindingState { + + public static void main(String[] args) throws Exception { + asyncSetFindingState(); + } + + public static void asyncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.setFindingStateCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setfindingstate_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000..6079e61e8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingState.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setfindingstate_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingState { + + public static void main(String[] args) throws Exception { + syncSetFindingState(); + } + + public static void syncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + Finding response = securityCenterClient.setFindingState(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setfindingstate_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000..1557c8549 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateFindingnameFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateFindingnameFindingstateTimestamp(); + } + + public static void syncSetFindingStateFindingnameFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000..424140bf6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateStringFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateStringFindingstateTimestamp(); + } + + public static void syncSetFindingStateStringFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString(); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000..61af4e960 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000..1ea1f69e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setiampolicy_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = securityCenterClient.setIamPolicy(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000..52e226016 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000..8f22b1998 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/AsyncSetMute.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/AsyncSetMute.java new file mode 100644 index 000000000..a256f9716 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/AsyncSetMute.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setmute_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SetMuteRequest; + +public class AsyncSetMute { + + public static void main(String[] args) throws Exception { + asyncSetMute(); + } + + public static void asyncSetMute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetMuteRequest request = + SetMuteRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .build(); + ApiFuture future = securityCenterClient.setMuteCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setmute_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMute.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMute.java new file mode 100644 index 000000000..dc5a6e116 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMute.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setmute_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SetMuteRequest; + +public class SyncSetMute { + + public static void main(String[] args) throws Exception { + syncSetMute(); + } + + public static void syncSetMute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetMuteRequest request = + SetMuteRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .build(); + Finding response = securityCenterClient.setMute(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setmute_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteFindingnameFindingmute.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteFindingnameFindingmute.java new file mode 100644 index 000000000..1ddedd5c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteFindingnameFindingmute.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setmute_findingnamefindingmute_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncSetMuteFindingnameFindingmute { + + public static void main(String[] args) throws Exception { + syncSetMuteFindingnameFindingmute(); + } + + public static void syncSetMuteFindingnameFindingmute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.Mute mute = Finding.Mute.forNumber(0); + Finding response = securityCenterClient.setMute(name, mute); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setmute_findingnamefindingmute_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteStringFindingmute.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteStringFindingmute.java new file mode 100644 index 000000000..ec0536366 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/setmute/SyncSetMuteStringFindingmute.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_setmute_stringfindingmute_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.FindingName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncSetMuteStringFindingmute { + + public static void main(String[] args) throws Exception { + syncSetMuteStringFindingmute(); + } + + public static void syncSetMuteStringFindingmute() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString(); + Finding.Mute mute = Finding.Mute.forNumber(0); + Finding response = securityCenterClient.setMute(name, mute); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_setmute_stringfindingmute_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000..876842dac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + securityCenterClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_testiampermissions_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000..503f5defa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_testiampermissions_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_testiampermissions_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000..6099c89e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SourceName; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000..501f4b5b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_testiampermissions_stringliststring_sync] +import com.google.cloud.securitycenter.v1.FolderName; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_testiampermissions_stringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/AsyncUpdateBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/AsyncUpdateBigQueryExport.java new file mode 100644 index 000000000..a83c7bee8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/AsyncUpdateBigQueryExport.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateBigQueryExportRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateBigQueryExport { + + public static void main(String[] args) throws Exception { + asyncUpdateBigQueryExport(); + } + + public static void asyncUpdateBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateBigQueryExportRequest request = + UpdateBigQueryExportRequest.newBuilder() + .setBigQueryExport(BigQueryExport.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateBigQueryExportCallable().futureCall(request); + // Do something. + BigQueryExport response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExport.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExport.java new file mode 100644 index 000000000..5fc0c7c31 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExport.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateBigQueryExportRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBigQueryExport { + + public static void main(String[] args) throws Exception { + syncUpdateBigQueryExport(); + } + + public static void syncUpdateBigQueryExport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateBigQueryExportRequest request = + UpdateBigQueryExportRequest.newBuilder() + .setBigQueryExport(BigQueryExport.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + BigQueryExport response = securityCenterClient.updateBigQueryExport(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.java new file mode 100644 index 000000000..4ee5fb78c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatebigqueryexport/SyncUpdateBigQueryExportBigqueryexportFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_bigqueryexportfieldmask_sync] +import com.google.cloud.securitycenter.v1.BigQueryExport; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBigQueryExportBigqueryexportFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateBigQueryExportBigqueryexportFieldmask(); + } + + public static void syncUpdateBigQueryExportBigqueryexportFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + BigQueryExport bigQueryExport = BigQueryExport.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + BigQueryExport response = + securityCenterClient.updateBigQueryExport(bigQueryExport, updateMask); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatebigqueryexport_bigqueryexportfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/AsyncUpdateExternalSystem.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/AsyncUpdateExternalSystem.java new file mode 100644 index 000000000..1106adfe1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/AsyncUpdateExternalSystem.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateexternalsystem_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.ExternalSystem; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateExternalSystemRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateExternalSystem { + + public static void main(String[] args) throws Exception { + asyncUpdateExternalSystem(); + } + + public static void asyncUpdateExternalSystem() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateExternalSystemRequest request = + UpdateExternalSystemRequest.newBuilder() + .setExternalSystem(ExternalSystem.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateExternalSystemCallable().futureCall(request); + // Do something. + ExternalSystem response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateexternalsystem_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystem.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystem.java new file mode 100644 index 000000000..174f667e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystem.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateexternalsystem_sync] +import com.google.cloud.securitycenter.v1.ExternalSystem; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateExternalSystemRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateExternalSystem { + + public static void main(String[] args) throws Exception { + syncUpdateExternalSystem(); + } + + public static void syncUpdateExternalSystem() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateExternalSystemRequest request = + UpdateExternalSystemRequest.newBuilder() + .setExternalSystem(ExternalSystem.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ExternalSystem response = securityCenterClient.updateExternalSystem(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateexternalsystem_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.java new file mode 100644 index 000000000..3c0041128 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateexternalsystem/SyncUpdateExternalSystemExternalsystemFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateexternalsystem_externalsystemfieldmask_sync] +import com.google.cloud.securitycenter.v1.ExternalSystem; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateExternalSystemExternalsystemFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateExternalSystemExternalsystemFieldmask(); + } + + public static void syncUpdateExternalSystemExternalsystemFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ExternalSystem externalSystem = ExternalSystem.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ExternalSystem response = + securityCenterClient.updateExternalSystem(externalSystem, updateMask); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateexternalsystem_externalsystemfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000..613572319 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/AsyncUpdateFinding.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatefinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFinding { + + public static void main(String[] args) throws Exception { + asyncUpdateFinding(); + } + + public static void asyncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatefinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000..b0c7f133c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFinding.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatefinding_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFinding(); + } + + public static void syncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Finding response = securityCenterClient.updateFinding(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatefinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000..81831009a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatefinding_finding_sync] +import com.google.cloud.securitycenter.v1.Finding; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncUpdateFindingFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFindingFinding(); + } + + public static void syncUpdateFindingFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.updateFinding(finding); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatefinding_finding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/AsyncUpdateMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/AsyncUpdateMuteConfig.java new file mode 100644 index 000000000..dfca37599 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/AsyncUpdateMuteConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatemuteconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateMuteConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateMuteConfig(); + } + + public static void asyncUpdateMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateMuteConfigRequest request = + UpdateMuteConfigRequest.newBuilder() + .setMuteConfig(MuteConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateMuteConfigCallable().futureCall(request); + // Do something. + MuteConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatemuteconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfig.java new file mode 100644 index 000000000..a4af570e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatemuteconfig_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateMuteConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateMuteConfig { + + public static void main(String[] args) throws Exception { + syncUpdateMuteConfig(); + } + + public static void syncUpdateMuteConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateMuteConfigRequest request = + UpdateMuteConfigRequest.newBuilder() + .setMuteConfig(MuteConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + MuteConfig response = securityCenterClient.updateMuteConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatemuteconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.java new file mode 100644 index 000000000..112f89bb7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatemuteconfig/SyncUpdateMuteConfigMuteconfigFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatemuteconfig_muteconfigfieldmask_sync] +import com.google.cloud.securitycenter.v1.MuteConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateMuteConfigMuteconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateMuteConfigMuteconfigFieldmask(); + } + + public static void syncUpdateMuteConfigMuteconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + MuteConfig muteConfig = MuteConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + MuteConfig response = securityCenterClient.updateMuteConfig(muteConfig, updateMask); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatemuteconfig_muteconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java new file mode 100644 index 000000000..988888ec1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateNotificationConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateNotificationConfig(); + } + + public static void asyncUpdateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateNotificationConfigRequest request = + UpdateNotificationConfigRequest.newBuilder() + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java new file mode 100644 index 000000000..527c4b068 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateNotificationConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNotificationConfig { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfig(); + } + + public static void syncUpdateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateNotificationConfigRequest request = + UpdateNotificationConfigRequest.newBuilder() + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + NotificationConfig response = securityCenterClient.updateNotificationConfig(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java new file mode 100644 index 000000000..6b31ecd76 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_notificationconfig_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncUpdateNotificationConfigNotificationconfig { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfigNotificationconfig(); + } + + public static void syncUpdateNotificationConfigNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.updateNotificationConfig(notificationConfig); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_notificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java new file mode 100644 index 000000000..72ec82a7d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_notificationconfigfieldmask_sync] +import com.google.cloud.securitycenter.v1.NotificationConfig; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNotificationConfigNotificationconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfigNotificationconfigFieldmask(); + } + + public static void syncUpdateNotificationConfigNotificationconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + NotificationConfig response = + securityCenterClient.updateNotificationConfig(notificationConfig, updateMask); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatenotificationconfig_notificationconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..80cb585f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncUpdateOrganizationSettings(); + } + + public static void asyncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..7004bb783 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_sync] +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettings(); + } + + public static void syncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OrganizationSettings response = securityCenterClient.updateOrganizationSettings(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000..59b7db298 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] +import com.google.cloud.securitycenter.v1.OrganizationSettings; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; + +public class SyncUpdateOrganizationSettingsOrganizationsettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettingsOrganizationsettings(); + } + + public static void syncUpdateOrganizationSettingsOrganizationsettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettings organizationSettings = OrganizationSettings.newBuilder().build(); + OrganizationSettings response = + securityCenterClient.updateOrganizationSettings(organizationSettings); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000..2283acd79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityMarks; +import com.google.cloud.securitycenter.v1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + asyncUpdateSecurityMarks(); + } + + public static void asyncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateSecurityMarksCallable().futureCall(request); + // Do something. + SecurityMarks response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000..2ff9cd041 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityMarks; +import com.google.cloud.securitycenter.v1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarks(); + } + + public static void syncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000..5db60660e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.SecurityMarks; + +public class SyncUpdateSecurityMarksSecuritymarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarksSecuritymarks(); + } + + public static void syncUpdateSecurityMarksSecuritymarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SecurityMarks securityMarks = SecurityMarks.newBuilder().build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(securityMarks); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/AsyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000..2c2bf2e9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/AsyncUpdateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateSource { + + public static void main(String[] args) throws Exception { + asyncUpdateSource(); + } + + public static void asyncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000..d38c0e678 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesource_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; +import com.google.cloud.securitycenter.v1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSource { + + public static void main(String[] args) throws Exception { + syncUpdateSource(); + } + + public static void syncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Source response = securityCenterClient.updateSource(request); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000..95a923ad7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycenterclient/updatesource/SyncUpdateSourceSource.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycenterclient_updatesource_source_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1.Source; + +public class SyncUpdateSourceSource { + + public static void main(String[] args) throws Exception { + syncUpdateSourceSource(); + } + + public static void syncUpdateSourceSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.updateSource(source); + } + } +} +// [END securitycenter_v1_generated_securitycenterclient_updatesource_source_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycentersettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..2f743d249 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/securitycentersettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.samples; + +// [START securitycenter_v1_generated_securitycentersettings_createsource_sync] +import com.google.cloud.securitycenter.v1.SecurityCenterSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings.Builder securityCenterSettingsBuilder = + SecurityCenterSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1_generated_securitycentersettings_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..52d7f414c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.stub.samples; + +// [START securitycenter_v1_generated_securitycenterstubsettings_createsource_sync] +import com.google.cloud.securitycenter.v1.stub.SecurityCenterStubSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterStubSettings.Builder securityCenterSettingsBuilder = + SecurityCenterStubSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterStubSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1_generated_securitycenterstubsettings_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..fad6f8db2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..89f1d8669 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_create_setcredentialsprovider1_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..44720964d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_create_setendpoint_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder().setEndpoint(myEndpoint).build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000..bd107b490 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class AsyncCreateFinding { + + public static void main(String[] args) throws Exception { + asyncCreateFinding(); + } + + public static void asyncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000..6b8a4227b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFinding.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createfinding_sync] +import com.google.cloud.securitycenter.v1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncCreateFinding { + + public static void main(String[] args) throws Exception { + syncCreateFinding(); + } + + public static void syncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + Finding response = securityCenterClient.createFinding(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000..d998974d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncCreateFindingSourcenameStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingSourcenameStringFinding(); + } + + public static void syncCreateFindingSourcenameStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000..e0dfe8c53 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createfinding_stringstringfinding_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncCreateFindingStringStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingStringStringFinding(); + } + + public static void syncCreateFindingStringStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.of("[ORGANIZATION]", "[SOURCE]").toString(); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createfinding_stringstringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/AsyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000..1b3229e95 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/AsyncCreateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class AsyncCreateSource { + + public static void main(String[] args) throws Exception { + asyncCreateSource(); + } + + public static void asyncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000..fae418991 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createsource_sync] +import com.google.cloud.securitycenter.v1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + Source response = securityCenterClient.createSource(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000..20c0ebe90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createsource_organizationnamesource_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncCreateSourceOrganizationnameSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceOrganizationnameSource(); + } + + public static void syncCreateSourceOrganizationnameSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createsource_organizationnamesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000..23dc8c491 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_createsource_stringsource_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncCreateSourceStringSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceStringSource(); + } + + public static void syncCreateSourceStringSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_createsource_stringsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000..6f33f808a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000..7151eb372 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = securityCenterClient.getIamPolicy(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000..ad52ceed9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_resourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000..e6949873d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_string_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = OrganizationName.of("[ORGANIZATION]").toString(); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getiampolicy_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000..ee4e41d85 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class AsyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncGetOrganizationSettings(); + } + + public static void asyncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.getOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000..6a75281bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_sync] +import com.google.cloud.securitycenter.v1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettings(); + } + + public static void syncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000..818fdd430 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsOrganizationsettingsname { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsOrganizationsettingsname(); + } + + public static void syncGetOrganizationSettingsOrganizationsettingsname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000..91ad52288 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_string_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsString { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsString(); + } + + public static void syncGetOrganizationSettingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = OrganizationSettingsName.of("[ORGANIZATION]").toString(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getorganizationsettings_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/AsyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000..d39af64f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/AsyncGetSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class AsyncGetSource { + + public static void main(String[] args) throws Exception { + asyncGetSource(); + } + + public static void asyncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + ApiFuture future = securityCenterClient.getSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000..6d57e51f6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSource.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getsource_sync] +import com.google.cloud.securitycenter.v1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncGetSource { + + public static void main(String[] args) throws Exception { + syncGetSource(); + } + + public static void syncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + Source response = securityCenterClient.getSource(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000..815d8e553 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getsource_sourcename_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncGetSourceSourcename { + + public static void main(String[] args) throws Exception { + syncGetSourceSourcename(); + } + + public static void syncGetSourceSourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName name = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getsource_sourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000..7f6a383e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/getsource/SyncGetSourceString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_getsource_string_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncGetSourceString { + + public static void main(String[] args) throws Exception { + syncGetSourceString(); + } + + public static void syncGetSourceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = SourceName.of("[ORGANIZATION]", "[SOURCE]").toString(); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_getsource_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000..6313d3866 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssets { + + public static void main(String[] args) throws Exception { + asyncGroupAssets(); + } + + public static void asyncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupAssetsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000..57cb758be --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupassets_paged_async] +import com.google.cloud.securitycenter.v1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupAssetsPaged(); + } + + public static void asyncGroupAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/SyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000..08bc766f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupassets/SyncGroupAssets.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupassets_sync] +import com.google.cloud.securitycenter.v1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class SyncGroupAssets { + + public static void main(String[] args) throws Exception { + syncGroupAssets(); + } + + public static void syncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000..8646cd7dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindings { + + public static void main(String[] args) throws Exception { + asyncGroupFindings(); + } + + public static void asyncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupFindingsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000..deedcbc9e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupfindings_paged_async] +import com.google.cloud.securitycenter.v1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupFindingsPaged(); + } + + public static void asyncGroupFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000..16dbb8c45 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupfindings_sync] +import com.google.cloud.securitycenter.v1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.protobuf.Timestamp; + +public class SyncGroupFindings { + + public static void main(String[] args) throws Exception { + syncGroupFindings(); + } + + public static void syncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000..4d3b46116 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncGroupFindingsSourcenameString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsSourcenameString(); + } + + public static void syncGroupFindingsSourcenameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000..23a8d703d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_groupfindings_stringstring_sync] +import com.google.cloud.securitycenter.v1beta1.GroupResult; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; + +public class SyncGroupFindingsStringString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsStringString(); + } + + public static void syncGroupFindingsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.of("[ORGANIZATION]", "[SOURCE]").toString(); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_groupfindings_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000..4d18047e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssets.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssets { + + public static void main(String[] args) throws Exception { + asyncListAssets(); + } + + public static void asyncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listAssetsPagedCallable().futureCall(request); + // Do something. + for (ListAssetsResponse.ListAssetsResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000..377a46f1b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listassets_paged_async] +import com.google.cloud.securitycenter.v1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncListAssetsPaged(); + } + + public static void asyncListAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); + for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/SyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000..c7ac274b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listassets/SyncListAssets.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listassets_sync] +import com.google.cloud.securitycenter.v1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListAssets { + + public static void main(String[] args) throws Exception { + syncListAssets(); + } + + public static void syncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000..5b3811773 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindings.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (Finding element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000..f83e131a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listfindings_paged_async] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); + for (Finding element : response.getFindingsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000..01f5cf156 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listfindings/SyncListFindings.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listfindings_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Finding element : securityCenterClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000..df3cfd568 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSources.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listsources_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class AsyncListSources { + + public static void main(String[] args) throws Exception { + asyncListSources(); + } + + public static void asyncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listSourcesPagedCallable().futureCall(request); + // Do something. + for (Source element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listsources_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000..9a5a85e63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listsources_paged_async] +import com.google.cloud.securitycenter.v1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1beta1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.common.base.Strings; + +public class AsyncListSourcesPaged { + + public static void main(String[] args) throws Exception { + asyncListSourcesPaged(); + } + + public static void asyncListSourcesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); + for (Source element : response.getSourcesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listsources_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000..199a94c39 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSources.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listsources_sync] +import com.google.cloud.securitycenter.v1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncListSources { + + public static void main(String[] args) throws Exception { + syncListSources(); + } + + public static void syncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Source element : securityCenterClient.listSources(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listsources_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000..a4556b72c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listsources_organizationname_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncListSourcesOrganizationname { + + public static void main(String[] args) throws Exception { + syncListSourcesOrganizationname(); + } + + public static void syncListSourcesOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listsources_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000..21b53ccd7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/listsources/SyncListSourcesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_listsources_string_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncListSourcesString { + + public static void main(String[] args) throws Exception { + syncListSourcesString(); + } + + public static void syncListSourcesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_listsources_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000..588a9573f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.longrunning.Operation; + +public class AsyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscovery(); + } + + public static void asyncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.runAssetDiscoveryCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000..c788fe3c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncRunAssetDiscoveryLRO { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscoveryLRO(); + } + + public static void asyncRunAssetDiscoveryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + OperationFuture future = + securityCenterClient.runAssetDiscoveryOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000..be67bdf6b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscovery(); + } + + public static void syncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + securityCenterClient.runAssetDiscoveryAsync(request).get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000..43c993e74 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncRunAssetDiscoveryOrganizationname { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryOrganizationname(); + } + + public static void syncRunAssetDiscoveryOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000..1f7094c34 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_string_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncRunAssetDiscoveryString { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryString(); + } + + public static void syncRunAssetDiscoveryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_runassetdiscovery_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000..9447b8345 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.FindingName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class AsyncSetFindingState { + + public static void main(String[] args) throws Exception { + asyncSetFindingState(); + } + + public static void asyncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.setFindingStateCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000..c3e710d1c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.FindingName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingState { + + public static void main(String[] args) throws Exception { + syncSetFindingState(); + } + + public static void syncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName(FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + Finding response = securityCenterClient.setFindingState(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000..e809b3853 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.FindingName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateFindingnameFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateFindingnameFindingstateTimestamp(); + } + + public static void syncSetFindingStateFindingnameFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FindingName name = FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000..3f7313341 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.FindingName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateStringFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateStringFindingstateTimestamp(); + } + + public static void syncSetFindingStateStringFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = FindingName.of("[ORGANIZATION]", "[SOURCE]", "[FINDING]").toString(); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000..5ac3cea3f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000..66e240abe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = securityCenterClient.setIamPolicy(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000..5ca6e1536 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000..65586d877 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = OrganizationName.of("[ORGANIZATION]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000..a8b19f01b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + securityCenterClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000..08e674d9c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SourceName.of("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000..cece044b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.of("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000..8ba110764 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_stringliststring_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = OrganizationName.of("[ORGANIZATION]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_testiampermissions_stringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000..238434985 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatefinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFinding { + + public static void main(String[] args) throws Exception { + asyncUpdateFinding(); + } + + public static void asyncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatefinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000..7c311d9e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatefinding_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFinding(); + } + + public static void syncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Finding response = securityCenterClient.updateFinding(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatefinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000..da674e833 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatefinding_finding_sync] +import com.google.cloud.securitycenter.v1beta1.Finding; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class SyncUpdateFindingFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFindingFinding(); + } + + public static void syncUpdateFindingFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.updateFinding(finding); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatefinding_finding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..89a350a5c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncUpdateOrganizationSettings(); + } + + public static void asyncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..ca9e61374 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettings(); + } + + public static void syncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OrganizationSettings response = securityCenterClient.updateOrganizationSettings(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000..9c8af6b38 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] +import com.google.cloud.securitycenter.v1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; + +public class SyncUpdateOrganizationSettingsOrganizationsettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettingsOrganizationsettings(); + } + + public static void syncUpdateOrganizationSettingsOrganizationsettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettings organizationSettings = OrganizationSettings.newBuilder().build(); + OrganizationSettings response = + securityCenterClient.updateOrganizationSettings(organizationSettings); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000..bb1bf78d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1beta1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + asyncUpdateSecurityMarks(); + } + + public static void asyncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateSecurityMarksCallable().futureCall(request); + // Do something. + SecurityMarks response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000..b2b1fb54d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1beta1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarks(); + } + + public static void syncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000..e4e31da05 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.SecurityMarks; + +public class SyncUpdateSecurityMarksSecuritymarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarksSecuritymarks(); + } + + public static void syncUpdateSecurityMarksSecuritymarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SecurityMarks securityMarks = SecurityMarks.newBuilder().build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(securityMarks); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000..784c7c0fe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateSource { + + public static void main(String[] args) throws Exception { + asyncUpdateSource(); + } + + public static void asyncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000..68bb27920 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesource_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; +import com.google.cloud.securitycenter.v1beta1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSource { + + public static void main(String[] args) throws Exception { + syncUpdateSource(); + } + + public static void syncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Source response = securityCenterClient.updateSource(request); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000..e5d3144cc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycenterclient_updatesource_source_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1beta1.Source; + +public class SyncUpdateSourceSource { + + public static void main(String[] args) throws Exception { + syncUpdateSourceSource(); + } + + public static void syncUpdateSourceSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.updateSource(source); + } + } +} +// [END securitycenter_v1beta1_generated_securitycenterclient_updatesource_source_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycentersettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..9a86b6633 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/securitycentersettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1beta1.samples; + +// [START securitycenter_v1beta1_generated_securitycentersettings_createsource_sync] +import com.google.cloud.securitycenter.v1beta1.SecurityCenterSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings.Builder securityCenterSettingsBuilder = + SecurityCenterSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1beta1_generated_securitycentersettings_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..cde1aaa10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1beta1.stub.samples; + +// [START securitycenter_v1beta1_generated_securitycenterstubsettings_createsource_sync] +import com.google.cloud.securitycenter.v1beta1.stub.SecurityCenterStubSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterStubSettings.Builder securityCenterSettingsBuilder = + SecurityCenterStubSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterStubSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1beta1_generated_securitycenterstubsettings_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..b9239f558 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1p1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..14c0d53f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_create_setcredentialsprovider1_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder() + .setTransportChannelProvider( + SecurityCenterSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..0e9faceab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_create_setendpoint_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterSettings; +import com.google.cloud.securitycenter.v1p1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings securityCenterSettings = + SecurityCenterSettings.newBuilder().setEndpoint(myEndpoint).build(); + SecurityCenterClient securityCenterClient = SecurityCenterClient.create(securityCenterSettings); + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java new file mode 100644 index 000000000..155e97ec0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/AsyncCreateFinding.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class AsyncCreateFinding { + + public static void main(String[] args) throws Exception { + asyncCreateFinding(); + } + + public static void asyncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFinding.java new file mode 100644 index 000000000..cc47ac560 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFinding.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sync] +import com.google.cloud.securitycenter.v1p1beta1.CreateFindingRequest; +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncCreateFinding { + + public static void main(String[] args) throws Exception { + syncCreateFinding(); + } + + public static void syncCreateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateFindingRequest request = + CreateFindingRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFindingId("findingId439150212") + .setFinding(Finding.newBuilder().build()) + .build(); + Finding response = securityCenterClient.createFinding(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.java new file mode 100644 index 000000000..e2baf3651 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameFindingString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sourcenamefindingstring_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncCreateFindingSourcenameFindingString { + + public static void main(String[] args) throws Exception { + syncCreateFindingSourcenameFindingString(); + } + + public static void syncCreateFindingSourcenameFindingString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + Finding response = securityCenterClient.createFinding(parent, finding, findingId); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sourcenamefindingstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java new file mode 100644 index 000000000..b228feae3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingSourcenameStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncCreateFindingSourcenameStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingSourcenameStringFinding(); + } + + public static void syncCreateFindingSourcenameStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_sourcenamestringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.java new file mode 100644 index 000000000..b7d696af6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringFindingString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_stringfindingstring_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncCreateFindingStringFindingString { + + public static void main(String[] args) throws Exception { + syncCreateFindingStringFindingString(); + } + + public static void syncCreateFindingStringFindingString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + Finding finding = Finding.newBuilder().build(); + String findingId = "findingId439150212"; + Finding response = securityCenterClient.createFinding(parent, finding, findingId); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_stringfindingstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java new file mode 100644 index 000000000..799dc6a97 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createfinding/SyncCreateFindingStringStringFinding.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_stringstringfinding_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncCreateFindingStringStringFinding { + + public static void main(String[] args) throws Exception { + syncCreateFindingStringStringFinding(); + } + + public static void syncCreateFindingStringStringFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + String findingId = "findingId439150212"; + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.createFinding(parent, findingId, finding); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createfinding_stringstringfinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java new file mode 100644 index 000000000..0126f3dd7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/AsyncCreateNotificationConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class AsyncCreateNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncCreateNotificationConfig(); + } + + public static void asyncCreateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateNotificationConfigRequest request = + CreateNotificationConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setConfigId("configId-580140035") + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.createNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java new file mode 100644 index 000000000..62a039bfb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.CreateNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncCreateNotificationConfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfig(); + } + + public static void syncCreateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateNotificationConfigRequest request = + CreateNotificationConfigRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setConfigId("configId-580140035") + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .build(); + NotificationConfig response = securityCenterClient.createNotificationConfig(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java new file mode 100644 index 000000000..4c8536f71 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameNotificationconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_organizationnamenotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncCreateNotificationConfigOrganizationnameNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigOrganizationnameNotificationconfig(); + } + + public static void syncCreateNotificationConfigOrganizationnameNotificationconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, notificationConfig); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_organizationnamenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java new file mode 100644 index 000000000..79c228b5f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigOrganizationnameStringNotificationconfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_organizationnamestringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncCreateNotificationConfigOrganizationnameStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigOrganizationnameStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigOrganizationnameStringNotificationconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, configId, notificationConfig); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_organizationnamestringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java new file mode 100644 index 000000000..5562a91a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringNotificationconfig.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_stringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncCreateNotificationConfigStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigStringNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, notificationConfig); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_stringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java new file mode 100644 index 000000000..cb1ca7e72 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createnotificationconfig/SyncCreateNotificationConfigStringStringNotificationconfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_stringstringnotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncCreateNotificationConfigStringStringNotificationconfig { + + public static void main(String[] args) throws Exception { + syncCreateNotificationConfigStringStringNotificationconfig(); + } + + public static void syncCreateNotificationConfigStringStringNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + String configId = "configId-580140035"; + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.createNotificationConfig(parent, configId, notificationConfig); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createnotificationconfig_stringstringnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/AsyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/AsyncCreateSource.java new file mode 100644 index 000000000..d5adb99b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/AsyncCreateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class AsyncCreateSource { + + public static void main(String[] args) throws Exception { + asyncCreateSource(); + } + + public static void asyncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.createSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSource.java new file mode 100644 index 000000000..30f4a1fe5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createsource_sync] +import com.google.cloud.securitycenter.v1p1beta1.CreateSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + CreateSourceRequest request = + CreateSourceRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setSource(Source.newBuilder().build()) + .build(); + Source response = securityCenterClient.createSource(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java new file mode 100644 index 000000000..98bad43dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceOrganizationnameSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createsource_organizationnamesource_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncCreateSourceOrganizationnameSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceOrganizationnameSource(); + } + + public static void syncCreateSourceOrganizationnameSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createsource_organizationnamesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java new file mode 100644 index 000000000..c8e89a945 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/createsource/SyncCreateSourceStringSource.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_createsource_stringsource_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncCreateSourceStringSource { + + public static void main(String[] args) throws Exception { + syncCreateSourceStringSource(); + } + + public static void syncCreateSourceStringSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.createSource(parent, source); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_createsource_stringsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java new file mode 100644 index 000000000..08dbb8096 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/AsyncDeleteNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteNotificationConfig(); + } + + public static void asyncDeleteNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteNotificationConfigRequest request = + DeleteNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + ApiFuture future = + securityCenterClient.deleteNotificationConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java new file mode 100644 index 000000000..5f125933f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.DeleteNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfig { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfig(); + } + + public static void syncDeleteNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + DeleteNotificationConfigRequest request = + DeleteNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + securityCenterClient.deleteNotificationConfig(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000..c00e150dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigNotificationconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfigNotificationconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfigNotificationconfigname(); + } + + public static void syncDeleteNotificationConfigNotificationconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + securityCenterClient.deleteNotificationConfig(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_notificationconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java new file mode 100644 index 000000000..3b3e947b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/deletenotificationconfig/SyncDeleteNotificationConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNotificationConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteNotificationConfigString(); + } + + public static void syncDeleteNotificationConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString(); + securityCenterClient.deleteNotificationConfig(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_deletenotificationconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 000000000..657b8158e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 000000000..6f6d9480a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = securityCenterClient.getIamPolicy(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java new file mode 100644 index 000000000..d4feef0da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyResourcename.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_resourcename_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyResourcename { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyResourcename(); + } + + public static void syncGetIamPolicyResourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_resourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java new file mode 100644 index 000000000..6a08effa9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getiampolicy/SyncGetIamPolicyString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.FolderName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicyString { + + public static void main(String[] args) throws Exception { + syncGetIamPolicyString(); + } + + public static void syncGetIamPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy response = securityCenterClient.getIamPolicy(resource); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getiampolicy_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java new file mode 100644 index 000000000..66248040a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/AsyncGetNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class AsyncGetNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncGetNotificationConfig(); + } + + public static void asyncGetNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetNotificationConfigRequest request = + GetNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + ApiFuture future = + securityCenterClient.getNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java new file mode 100644 index 000000000..d2fef798b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.GetNotificationConfigRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetNotificationConfig { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfig(); + } + + public static void syncGetNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetNotificationConfigRequest request = + GetNotificationConfigRequest.newBuilder() + .setName( + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString()) + .build(); + NotificationConfig response = securityCenterClient.getNotificationConfig(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java new file mode 100644 index 000000000..c8b494003 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigNotificationconfigname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_notificationconfigname_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetNotificationConfigNotificationconfigname { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfigNotificationconfigname(); + } + + public static void syncGetNotificationConfigNotificationconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfigName name = + NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]"); + NotificationConfig response = securityCenterClient.getNotificationConfig(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_notificationconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java new file mode 100644 index 000000000..e2a8deabc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getnotificationconfig/SyncGetNotificationConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfigName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetNotificationConfigString { + + public static void main(String[] args) throws Exception { + syncGetNotificationConfigString(); + } + + public static void syncGetNotificationConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = NotificationConfigName.of("[ORGANIZATION]", "[NOTIFICATION_CONFIG]").toString(); + NotificationConfig response = securityCenterClient.getNotificationConfig(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getnotificationconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java new file mode 100644 index 000000000..ced3e3a23 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/AsyncGetOrganizationSettings.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class AsyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncGetOrganizationSettings(); + } + + public static void asyncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.getOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java new file mode 100644 index 000000000..bd9df50fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettings.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_sync] +import com.google.cloud.securitycenter.v1p1beta1.GetOrganizationSettingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettings(); + } + + public static void syncGetOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetOrganizationSettingsRequest request = + GetOrganizationSettingsRequest.newBuilder() + .setName(OrganizationSettingsName.of("[ORGANIZATION]").toString()) + .build(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java new file mode 100644 index 000000000..55d0d4717 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsOrganizationsettingsname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsOrganizationsettingsname { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsOrganizationsettingsname(); + } + + public static void syncGetOrganizationSettingsOrganizationsettingsname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettingsName name = OrganizationSettingsName.of("[ORGANIZATION]"); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_organizationsettingsname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java new file mode 100644 index 000000000..663444438 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getorganizationsettings/SyncGetOrganizationSettingsString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettingsName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncGetOrganizationSettingsString { + + public static void main(String[] args) throws Exception { + syncGetOrganizationSettingsString(); + } + + public static void syncGetOrganizationSettingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = OrganizationSettingsName.of("[ORGANIZATION]").toString(); + OrganizationSettings response = securityCenterClient.getOrganizationSettings(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getorganizationsettings_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/AsyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/AsyncGetSource.java new file mode 100644 index 000000000..caf50489d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/AsyncGetSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getsource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class AsyncGetSource { + + public static void main(String[] args) throws Exception { + asyncGetSource(); + } + + public static void asyncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + ApiFuture future = securityCenterClient.getSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getsource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSource.java new file mode 100644 index 000000000..a60c517d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSource.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getsource_sync] +import com.google.cloud.securitycenter.v1p1beta1.GetSourceRequest; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncGetSource { + + public static void main(String[] args) throws Exception { + syncGetSource(); + } + + public static void syncGetSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GetSourceRequest request = + GetSourceRequest.newBuilder() + .setName(SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .build(); + Source response = securityCenterClient.getSource(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java new file mode 100644 index 000000000..9312e47f7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceSourcename.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getsource_sourcename_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncGetSourceSourcename { + + public static void main(String[] args) throws Exception { + syncGetSourceSourcename(); + } + + public static void syncGetSourceSourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getsource_sourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceString.java new file mode 100644 index 000000000..b506eaab7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/getsource/SyncGetSourceString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_getsource_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncGetSourceString { + + public static void main(String[] args) throws Exception { + syncGetSourceString(); + } + + public static void syncGetSourceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + Source response = securityCenterClient.getSource(name); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_getsource_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java new file mode 100644 index 000000000..2e2d74265 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssets.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssets { + + public static void main(String[] args) throws Exception { + asyncGroupAssets(); + } + + public static void asyncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupAssetsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java new file mode 100644 index 000000000..1cc7768e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/AsyncGroupAssetsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupAssetsPaged(); + } + + public static void asyncGroupAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupAssetsResponse response = securityCenterClient.groupAssetsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/SyncGroupAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/SyncGroupAssets.java new file mode 100644 index 000000000..5b4e242c5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupassets/SyncGroupAssets.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_sync] +import com.google.cloud.securitycenter.v1p1beta1.GroupAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class SyncGroupAssets { + + public static void main(String[] args) throws Exception { + syncGroupAssets(); + } + + public static void syncGroupAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupAssetsRequest request = + GroupAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setCompareDuration(Duration.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java new file mode 100644 index 000000000..4b4e88efd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindings.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindings { + + public static void main(String[] args) throws Exception { + asyncGroupFindings(); + } + + public static void asyncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.groupFindingsPagedCallable().futureCall(request); + // Do something. + for (GroupResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java new file mode 100644 index 000000000..d1c602f5c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/AsyncGroupFindingsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class AsyncGroupFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncGroupFindingsPaged(); + } + + public static void asyncGroupFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + GroupFindingsResponse response = securityCenterClient.groupFindingsCallable().call(request); + for (GroupResult element : response.getGroupByResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java new file mode 100644 index 000000000..1b8942f30 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindings.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_sync] +import com.google.cloud.securitycenter.v1p1beta1.GroupFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.Timestamp; + +public class SyncGroupFindings { + + public static void main(String[] args) throws Exception { + syncGroupFindings(); + } + + public static void syncGroupFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + GroupFindingsRequest request = + GroupFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setGroupBy("groupBy293428022") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (GroupResult element : securityCenterClient.groupFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java new file mode 100644 index 000000000..1c7f66d01 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsSourcenameString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncGroupFindingsSourcenameString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsSourcenameString(); + } + + public static void syncGroupFindingsSourcenameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_sourcenamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java new file mode 100644 index 000000000..6571341b2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/groupfindings/SyncGroupFindingsStringString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_stringstring_sync] +import com.google.cloud.securitycenter.v1p1beta1.GroupResult; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncGroupFindingsStringString { + + public static void main(String[] args) throws Exception { + syncGroupFindingsStringString(); + } + + public static void syncGroupFindingsStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + String groupBy = "groupBy293428022"; + for (GroupResult element : securityCenterClient.groupFindings(parent, groupBy).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_groupfindings_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssets.java new file mode 100644 index 000000000..f7853ddb1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssets.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssets { + + public static void main(String[] args) throws Exception { + asyncListAssets(); + } + + public static void asyncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listAssetsPagedCallable().futureCall(request); + // Do something. + for (ListAssetsResponse.ListAssetsResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java new file mode 100644 index 000000000..7900d6e59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/AsyncListAssetsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListAssetsPaged { + + public static void main(String[] args) throws Exception { + asyncListAssetsPaged(); + } + + public static void asyncListAssetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListAssetsResponse response = securityCenterClient.listAssetsCallable().call(request); + for (ListAssetsResponse.ListAssetsResult element : response.getListAssetsResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssets.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssets.java new file mode 100644 index 000000000..3e01f528d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssets.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListAssets { + + public static void main(String[] args) throws Exception { + syncListAssets(); + } + + public static void syncListAssets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListAssetsRequest request = + ListAssetsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsFoldername.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsFoldername.java new file mode 100644 index 000000000..93fa81c04 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsFoldername.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_foldername_sync] +import com.google.cloud.securitycenter.v1p1beta1.FolderName; +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListAssetsFoldername { + + public static void main(String[] args) throws Exception { + syncListAssetsFoldername(); + } + + public static void syncListAssetsFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_foldername_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsOrganizationname.java new file mode 100644 index 000000000..126f01b2a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsOrganizationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_organizationname_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListAssetsOrganizationname { + + public static void main(String[] args) throws Exception { + syncListAssetsOrganizationname(); + } + + public static void syncListAssetsOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsProjectname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsProjectname.java new file mode 100644 index 000000000..0933c3e5c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsProjectname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_projectname_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.ProjectName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListAssetsProjectname { + + public static void main(String[] args) throws Exception { + syncListAssetsProjectname(); + } + + public static void syncListAssetsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsString.java new file mode 100644 index 000000000..1a0394669 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listassets/SyncListAssetsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listassets_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListAssetsResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListAssetsString { + + public static void main(String[] args) throws Exception { + syncListAssetsString(); + } + + public static void syncListAssetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (ListAssetsResponse.ListAssetsResult element : + securityCenterClient.listAssets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listassets_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindings.java new file mode 100644 index 000000000..8bfe7503b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindings.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindings { + + public static void main(String[] args) throws Exception { + asyncListFindings(); + } + + public static void asyncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listFindingsPagedCallable().futureCall(request); + // Do something. + for (ListFindingsResponse.ListFindingsResult element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java new file mode 100644 index 000000000..bc61ecd98 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/AsyncListFindingsPaged.java @@ -0,0 +1,67 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.common.base.Strings; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncListFindingsPaged { + + public static void main(String[] args) throws Exception { + asyncListFindingsPaged(); + } + + public static void asyncListFindingsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListFindingsResponse response = securityCenterClient.listFindingsCallable().call(request); + for (ListFindingsResponse.ListFindingsResult element : + response.getListFindingsResultsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindings.java new file mode 100644 index 000000000..189954bb9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindings.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncListFindings { + + public static void main(String[] args) throws Exception { + syncListFindings(); + } + + public static void syncListFindings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListFindingsRequest request = + ListFindingsRequest.newBuilder() + .setParent( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .setReadTime(Timestamp.newBuilder().build()) + .setCompareDuration(Duration.newBuilder().build()) + .setFieldMask(FieldMask.newBuilder().build()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (ListFindingsResponse.ListFindingsResult element : + securityCenterClient.listFindings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsSourcename.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsSourcename.java new file mode 100644 index 000000000..16a33f015 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsSourcename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_sourcename_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncListFindingsSourcename { + + public static void main(String[] args) throws Exception { + syncListFindingsSourcename(); + } + + public static void syncListFindingsSourcename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SourceName parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + for (ListFindingsResponse.ListFindingsResult element : + securityCenterClient.listFindings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_sourcename_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsString.java new file mode 100644 index 000000000..b34b26366 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listfindings/SyncListFindingsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListFindingsResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; + +public class SyncListFindingsString { + + public static void main(String[] args) throws Exception { + syncListFindingsString(); + } + + public static void syncListFindingsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString(); + for (ListFindingsResponse.ListFindingsResult element : + securityCenterClient.listFindings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listfindings_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java new file mode 100644 index 000000000..c26244fe1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigs.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class AsyncListNotificationConfigs { + + public static void main(String[] args) throws Exception { + asyncListNotificationConfigs(); + } + + public static void asyncListNotificationConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listNotificationConfigsPagedCallable().futureCall(request); + // Do something. + for (NotificationConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java new file mode 100644 index 000000000..61c649ccf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/AsyncListNotificationConfigsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsResponse; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.common.base.Strings; + +public class AsyncListNotificationConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListNotificationConfigsPaged(); + } + + public static void asyncListNotificationConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListNotificationConfigsResponse response = + securityCenterClient.listNotificationConfigsCallable().call(request); + for (NotificationConfig element : response.getNotificationConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java new file mode 100644 index 000000000..3bc416451 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigs.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListNotificationConfigsRequest; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListNotificationConfigs { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigs(); + } + + public static void syncListNotificationConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListNotificationConfigsRequest request = + ListNotificationConfigsRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java new file mode 100644 index 000000000..bc8d18cb4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsOrganizationname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_organizationname_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListNotificationConfigsOrganizationname { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigsOrganizationname(); + } + + public static void syncListNotificationConfigsOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java new file mode 100644 index 000000000..b5aae5797 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listnotificationconfigs/SyncListNotificationConfigsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncListNotificationConfigsString { + + public static void main(String[] args) throws Exception { + syncListNotificationConfigsString(); + } + + public static void syncListNotificationConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (NotificationConfig element : + securityCenterClient.listNotificationConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listnotificationconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSources.java new file mode 100644 index 000000000..c0ff8d205 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSources.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class AsyncListSources { + + public static void main(String[] args) throws Exception { + asyncListSources(); + } + + public static void asyncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + ApiFuture future = + securityCenterClient.listSourcesPagedCallable().futureCall(request); + // Do something. + for (Source element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java new file mode 100644 index 000000000..8f4900ae6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/AsyncListSourcesPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_paged_async] +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesResponse; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.common.base.Strings; + +public class AsyncListSourcesPaged { + + public static void main(String[] args) throws Exception { + asyncListSourcesPaged(); + } + + public static void asyncListSourcesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + while (true) { + ListSourcesResponse response = securityCenterClient.listSourcesCallable().call(request); + for (Source element : response.getSourcesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSources.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSources.java new file mode 100644 index 000000000..716ca95ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSources.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_sync] +import com.google.cloud.securitycenter.v1p1beta1.ListSourcesRequest; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncListSources { + + public static void main(String[] args) throws Exception { + syncListSources(); + } + + public static void syncListSources() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ListSourcesRequest request = + ListSourcesRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + for (Source element : securityCenterClient.listSources(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesFoldername.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesFoldername.java new file mode 100644 index 000000000..52799cf99 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesFoldername.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_foldername_sync] +import com.google.cloud.securitycenter.v1p1beta1.FolderName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncListSourcesFoldername { + + public static void main(String[] args) throws Exception { + syncListSourcesFoldername(); + } + + public static void syncListSourcesFoldername() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FolderName parent = FolderName.of("[FOLDER]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_foldername_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java new file mode 100644 index 000000000..22d44b9d3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesOrganizationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_organizationname_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncListSourcesOrganizationname { + + public static void main(String[] args) throws Exception { + syncListSourcesOrganizationname(); + } + + public static void syncListSourcesOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesProjectname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesProjectname.java new file mode 100644 index 000000000..6ae2cadc8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_projectname_sync] +import com.google.cloud.securitycenter.v1p1beta1.ProjectName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncListSourcesProjectname { + + public static void main(String[] args) throws Exception { + syncListSourcesProjectname(); + } + + public static void syncListSourcesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesString.java new file mode 100644 index 000000000..cfa3be8b3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/listsources/SyncListSourcesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_listsources_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncListSourcesString { + + public static void main(String[] args) throws Exception { + syncListSourcesString(); + } + + public static void syncListSourcesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + for (Source element : securityCenterClient.listSources(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_listsources_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java new file mode 100644 index 000000000..ad3a6b27e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscovery.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.longrunning.Operation; + +public class AsyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscovery(); + } + + public static void asyncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + ApiFuture future = + securityCenterClient.runAssetDiscoveryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java new file mode 100644 index 000000000..60c8c3944 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/AsyncRunAssetDiscoveryLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Empty; + +public class AsyncRunAssetDiscoveryLRO { + + public static void main(String[] args) throws Exception { + asyncRunAssetDiscoveryLRO(); + } + + public static void asyncRunAssetDiscoveryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + OperationFuture future = + securityCenterClient.runAssetDiscoveryOperationCallable().futureCall(request); + // Do something. + RunAssetDiscoveryResponse response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java new file mode 100644 index 000000000..6cf20f904 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscovery.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryRequest; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncRunAssetDiscovery { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscovery(); + } + + public static void syncRunAssetDiscovery() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + RunAssetDiscoveryRequest request = + RunAssetDiscoveryRequest.newBuilder() + .setParent(OrganizationName.of("[ORGANIZATION]").toString()) + .build(); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(request).get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java new file mode 100644 index 000000000..4bd79677c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryOrganizationname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncRunAssetDiscoveryOrganizationname { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryOrganizationname(); + } + + public static void syncRunAssetDiscoveryOrganizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_organizationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java new file mode 100644 index 000000000..9793e94d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/runassetdiscovery/SyncRunAssetDiscoveryString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_string_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationName; +import com.google.cloud.securitycenter.v1p1beta1.RunAssetDiscoveryResponse; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncRunAssetDiscoveryString { + + public static void main(String[] args) throws Exception { + syncRunAssetDiscoveryString(); + } + + public static void syncRunAssetDiscoveryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String parent = OrganizationName.of("[ORGANIZATION]").toString(); + RunAssetDiscoveryResponse response = + securityCenterClient.runAssetDiscoveryAsync(parent).get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_runassetdiscovery_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java new file mode 100644 index 000000000..ff29de42c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/AsyncSetFindingState.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.FindingName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class AsyncSetFindingState { + + public static void main(String[] args) throws Exception { + asyncSetFindingState(); + } + + public static void asyncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.setFindingStateCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java new file mode 100644 index 000000000..9bb761c2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingState.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.FindingName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SetFindingStateRequest; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingState { + + public static void main(String[] args) throws Exception { + syncSetFindingState(); + } + + public static void syncSetFindingState() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetFindingStateRequest request = + SetFindingStateRequest.newBuilder() + .setName( + FindingName.ofOrganizationSourceFindingName( + "[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + Finding response = securityCenterClient.setFindingState(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java new file mode 100644 index 000000000..b9659db7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateFindingnameFindingstateTimestamp.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.FindingName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateFindingnameFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateFindingnameFindingstateTimestamp(); + } + + public static void syncSetFindingStateFindingnameFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + FindingName name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]"); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_findingnamefindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java new file mode 100644 index 000000000..30d152846 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setfindingstate/SyncSetFindingStateStringFindingstateTimestamp.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.FindingName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.Timestamp; + +public class SyncSetFindingStateStringFindingstateTimestamp { + + public static void main(String[] args) throws Exception { + syncSetFindingStateStringFindingstateTimestamp(); + } + + public static void syncSetFindingStateStringFindingstateTimestamp() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String name = + FindingName.ofOrganizationSourceFindingName("[ORGANIZATION]", "[SOURCE]", "[FINDING]") + .toString(); + Finding.State state = Finding.State.forNumber(0); + Timestamp startTime = Timestamp.newBuilder().build(); + Finding response = securityCenterClient.setFindingState(name, state, startTime); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setfindingstate_stringfindingstatetimestamp_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 000000000..7d6ee8d41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 000000000..e52356bbf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = securityCenterClient.setIamPolicy(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java new file mode 100644 index 000000000..3e4e77396 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyResourcenamePolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyResourcenamePolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyResourcenamePolicy(); + } + + public static void syncSetIamPolicyResourcenamePolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_resourcenamepolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java new file mode 100644 index 000000000..ca0336f1d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/setiampolicy/SyncSetIamPolicyStringPolicy.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] +import com.google.cloud.securitycenter.v1p1beta1.FolderName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.iam.v1.Policy; + +public class SyncSetIamPolicyStringPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicyStringPolicy(); + } + + public static void syncSetIamPolicyStringPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + Policy policy = Policy.newBuilder().build(); + Policy response = securityCenterClient.setIamPolicy(resource, policy); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_setiampolicy_stringpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 000000000..66eef9648 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + securityCenterClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 000000000..6588b315d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource( + SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = securityCenterClient.testIamPermissions(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java new file mode 100644 index 000000000..82245e7c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsResourcenameListstring.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] +import com.google.api.resourcenames.ResourceName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SourceName; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsResourcenameListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsResourcenameListstring(); + } + + public static void syncTestIamPermissionsResourcenameListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + ResourceName resource = SourceName.ofOrganizationSourceName("[ORGANIZATION]", "[SOURCE]"); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_resourcenameliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java new file mode 100644 index 000000000..ab8500175 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/testiampermissions/SyncTestIamPermissionsStringListstring.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_stringliststring_sync] +import com.google.cloud.securitycenter.v1p1beta1.FolderName; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; +import java.util.List; + +public class SyncTestIamPermissionsStringListstring { + + public static void main(String[] args) throws Exception { + syncTestIamPermissionsStringListstring(); + } + + public static void syncTestIamPermissionsStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + String resource = FolderName.of("[FOLDER]").toString(); + List permissions = new ArrayList<>(); + TestIamPermissionsResponse response = + securityCenterClient.testIamPermissions(resource, permissions); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_testiampermissions_stringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java new file mode 100644 index 000000000..cad8a1312 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/AsyncUpdateFinding.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateFinding { + + public static void main(String[] args) throws Exception { + asyncUpdateFinding(); + } + + public static void asyncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateFindingCallable().futureCall(request); + // Do something. + Finding response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java new file mode 100644 index 000000000..aa3b273f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFinding.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateFindingRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFinding(); + } + + public static void syncUpdateFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateFindingRequest request = + UpdateFindingRequest.newBuilder() + .setFinding(Finding.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Finding response = securityCenterClient.updateFinding(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java new file mode 100644 index 000000000..c0c59d54b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFinding.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_finding_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncUpdateFindingFinding { + + public static void main(String[] args) throws Exception { + syncUpdateFindingFinding(); + } + + public static void syncUpdateFindingFinding() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Finding finding = Finding.newBuilder().build(); + Finding response = securityCenterClient.updateFinding(finding); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_finding_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.java new file mode 100644 index 000000000..0178689cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatefinding/SyncUpdateFindingFindingFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_findingfieldmask_sync] +import com.google.cloud.securitycenter.v1p1beta1.Finding; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateFindingFindingFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateFindingFindingFieldmask(); + } + + public static void syncUpdateFindingFindingFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Finding finding = Finding.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Finding response = securityCenterClient.updateFinding(finding, updateMask); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatefinding_findingfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java new file mode 100644 index 000000000..b4aec5ca2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/AsyncUpdateNotificationConfig.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateNotificationConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateNotificationConfig(); + } + + public static void asyncUpdateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateNotificationConfigRequest request = + UpdateNotificationConfigRequest.newBuilder() + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateNotificationConfigCallable().futureCall(request); + // Do something. + NotificationConfig response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java new file mode 100644 index 000000000..ee5ff4e8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateNotificationConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNotificationConfig { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfig(); + } + + public static void syncUpdateNotificationConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateNotificationConfigRequest request = + UpdateNotificationConfigRequest.newBuilder() + .setNotificationConfig(NotificationConfig.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + NotificationConfig response = securityCenterClient.updateNotificationConfig(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java new file mode 100644 index 000000000..89c12fa15 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfig.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_notificationconfig_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncUpdateNotificationConfigNotificationconfig { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfigNotificationconfig(); + } + + public static void syncUpdateNotificationConfigNotificationconfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + NotificationConfig response = + securityCenterClient.updateNotificationConfig(notificationConfig); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_notificationconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java new file mode 100644 index 000000000..60be3cfb5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatenotificationconfig/SyncUpdateNotificationConfigNotificationconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_notificationconfigfieldmask_sync] +import com.google.cloud.securitycenter.v1p1beta1.NotificationConfig; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNotificationConfigNotificationconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateNotificationConfigNotificationconfigFieldmask(); + } + + public static void syncUpdateNotificationConfigNotificationconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + NotificationConfig notificationConfig = NotificationConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + NotificationConfig response = + securityCenterClient.updateNotificationConfig(notificationConfig, updateMask); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatenotificationconfig_notificationconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..8d735bf7f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/AsyncUpdateOrganizationSettings.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + asyncUpdateOrganizationSettings(); + } + + public static void asyncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateOrganizationSettingsCallable().futureCall(request); + // Do something. + OrganizationSettings response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java new file mode 100644 index 000000000..2d866ccab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettings.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.UpdateOrganizationSettingsRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOrganizationSettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettings(); + } + + public static void syncUpdateOrganizationSettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateOrganizationSettingsRequest request = + UpdateOrganizationSettingsRequest.newBuilder() + .setOrganizationSettings(OrganizationSettings.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OrganizationSettings response = securityCenterClient.updateOrganizationSettings(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java new file mode 100644 index 000000000..95167830e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updateorganizationsettings/SyncUpdateOrganizationSettingsOrganizationsettings.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] +import com.google.cloud.securitycenter.v1p1beta1.OrganizationSettings; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; + +public class SyncUpdateOrganizationSettingsOrganizationsettings { + + public static void main(String[] args) throws Exception { + syncUpdateOrganizationSettingsOrganizationsettings(); + } + + public static void syncUpdateOrganizationSettingsOrganizationsettings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + OrganizationSettings organizationSettings = OrganizationSettings.newBuilder().build(); + OrganizationSettings response = + securityCenterClient.updateOrganizationSettings(organizationSettings); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updateorganizationsettings_organizationsettings_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java new file mode 100644 index 000000000..571a07271 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/AsyncUpdateSecurityMarks.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class AsyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + asyncUpdateSecurityMarks(); + } + + public static void asyncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + securityCenterClient.updateSecurityMarksCallable().futureCall(request); + // Do something. + SecurityMarks response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java new file mode 100644 index 000000000..dda031b9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarks.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityMarks; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSecurityMarksRequest; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; + +public class SyncUpdateSecurityMarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarks(); + } + + public static void syncUpdateSecurityMarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSecurityMarksRequest request = + UpdateSecurityMarksRequest.newBuilder() + .setSecurityMarks(SecurityMarks.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setStartTime(Timestamp.newBuilder().build()) + .build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java new file mode 100644 index 000000000..3ad3e87ac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarks.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityMarks; + +public class SyncUpdateSecurityMarksSecuritymarks { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarksSecuritymarks(); + } + + public static void syncUpdateSecurityMarksSecuritymarks() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SecurityMarks securityMarks = SecurityMarks.newBuilder().build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(securityMarks); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarks_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.java new file mode 100644 index 000000000..4958aa18a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesecuritymarks/SyncUpdateSecurityMarksSecuritymarksFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarksfieldmask_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.SecurityMarks; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSecurityMarksSecuritymarksFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateSecurityMarksSecuritymarksFieldmask(); + } + + public static void syncUpdateSecurityMarksSecuritymarksFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + SecurityMarks securityMarks = SecurityMarks.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + SecurityMarks response = securityCenterClient.updateSecurityMarks(securityMarks, updateMask); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesecuritymarks_securitymarksfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java new file mode 100644 index 000000000..ce7d450ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/AsyncUpdateSource.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateSource { + + public static void main(String[] args) throws Exception { + asyncUpdateSource(); + } + + public static void asyncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = securityCenterClient.updateSourceCallable().futureCall(request); + // Do something. + Source response = future.get(); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_async] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSource.java new file mode 100644 index 000000000..ab56c23d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSource.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.cloud.securitycenter.v1p1beta1.UpdateSourceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSource { + + public static void main(String[] args) throws Exception { + syncUpdateSource(); + } + + public static void syncUpdateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + UpdateSourceRequest request = + UpdateSourceRequest.newBuilder() + .setSource(Source.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Source response = securityCenterClient.updateSource(request); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java new file mode 100644 index 000000000..000c19b3b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSource.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_source_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; + +public class SyncUpdateSourceSource { + + public static void main(String[] args) throws Exception { + syncUpdateSourceSource(); + } + + public static void syncUpdateSourceSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Source source = Source.newBuilder().build(); + Source response = securityCenterClient.updateSource(source); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_source_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSourceFieldmask.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSourceFieldmask.java new file mode 100644 index 000000000..83521b026 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycenterclient/updatesource/SyncUpdateSourceSourceFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_sourcefieldmask_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient; +import com.google.cloud.securitycenter.v1p1beta1.Source; +import com.google.protobuf.FieldMask; + +public class SyncUpdateSourceSourceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateSourceSourceFieldmask(); + } + + public static void syncUpdateSourceSourceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) { + Source source = Source.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Source response = securityCenterClient.updateSource(source, updateMask); + } + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterclient_updatesource_sourcefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycentersettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycentersettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..f2f56e394 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/securitycentersettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.samples; + +// [START securitycenter_v1p1beta1_generated_securitycentersettings_createsource_sync] +import com.google.cloud.securitycenter.v1p1beta1.SecurityCenterSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterSettings.Builder securityCenterSettingsBuilder = + SecurityCenterSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1p1beta1_generated_securitycentersettings_createsource_sync] diff --git a/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java new file mode 100644 index 000000000..7d988d9cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/securitycenter/v1p1beta1/stub/securitycenterstubsettings/createsource/SyncCreateSource.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.v1p1beta1.stub.samples; + +// [START securitycenter_v1p1beta1_generated_securitycenterstubsettings_createsource_sync] +import com.google.cloud.securitycenter.v1p1beta1.stub.SecurityCenterStubSettings; +import java.time.Duration; + +public class SyncCreateSource { + + public static void main(String[] args) throws Exception { + syncCreateSource(); + } + + public static void syncCreateSource() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + SecurityCenterStubSettings.Builder securityCenterSettingsBuilder = + SecurityCenterStubSettings.newBuilder(); + securityCenterSettingsBuilder + .createSourceSettings() + .setRetrySettings( + securityCenterSettingsBuilder + .createSourceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + SecurityCenterStubSettings securityCenterSettings = securityCenterSettingsBuilder.build(); + } +} +// [END securitycenter_v1p1beta1_generated_securitycenterstubsettings_createsource_sync] diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 8e0197adb..3435e4218 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -41,7 +41,7 @@ com.google.cloud google-cloud-securitycenter - 2.5.6 + 2.6.0 @@ -58,7 +58,7 @@ com.google.protobuf protobuf-java-util - 3.20.1 + 3.21.2 diff --git a/versions.txt b/versions.txt index d10576eb4..23924a1e7 100644 --- a/versions.txt +++ b/versions.txt @@ -1,10 +1,10 @@ # Format: # module:released-version:current-version -google-cloud-securitycenter:2.6.0:2.6.0 -grpc-google-cloud-securitycenter-v1:2.6.0:2.6.0 -grpc-google-cloud-securitycenter-v1beta1:0.101.0:0.101.0 -grpc-google-cloud-securitycenter-v1p1beta1:0.101.0:0.101.0 -proto-google-cloud-securitycenter-v1:2.6.0:2.6.0 -proto-google-cloud-securitycenter-v1beta1:0.101.0:0.101.0 -proto-google-cloud-securitycenter-v1p1beta1:0.101.0:0.101.0 +google-cloud-securitycenter:2.7.0:2.7.0 +grpc-google-cloud-securitycenter-v1:2.7.0:2.7.0 +grpc-google-cloud-securitycenter-v1beta1:0.102.0:0.102.0 +grpc-google-cloud-securitycenter-v1p1beta1:0.102.0:0.102.0 +proto-google-cloud-securitycenter-v1:2.7.0:2.7.0 +proto-google-cloud-securitycenter-v1beta1:0.102.0:0.102.0 +proto-google-cloud-securitycenter-v1p1beta1:0.102.0:0.102.0